$ show google-deepmind/alphagenome
AlphaGenome is a Python client library and SDK for interacting with Google DeepMind's AlphaGenome cloud service, a deep learning model that predicts molecular properties (gene expression, splicing, chromatin accessibility, histone marks, contact maps) from DNA sequence. The library provides gRPC-based clients for sequence, interval, and variant prediction, along with precomputed variant scores via the Atlas service. It includes rich data containers (TrackData, JunctionData), modular visualization components (tracks, transcripts, sashimi plots), and interpretation tools like in-silico mutagenesis. The repository also contains a set of Colab notebooks demonstrating end-to-end workflows for variant scoring, haplotype analysis, splicing quantification, and batch processing. The architecture is a thin client layer over a remote API, with protobuf definitions for service contracts and tensor serialization. Core modules handle genomic data types (Interval, Variant, Transcript), gene annotation parsing, ontology mapping, and efficient tensor packing. The variant scoring framework is extensible via dataclass-based scorers (center mask, gene mask LFC, splicing, polyadenylation) and includes utilities to tidy AnnData results into pandas DataFrames. Visualization is component-based, allowing composition of tracks, contact maps, and annotations into publication-quality figures. While primarily an application library, the repo has a strong data research character due to its focus on genomic analysis and the included notebooks. The code is well-structured, with extensive unit tests and CI/CD pipelines. However, it is tightly coupled to the AlphaGenome API and protobuf definitions, limiting standalone reuse. The most reusable components are the data containers (TrackData, JunctionData), tensor packing utilities, and the variant scorer dataclass pattern, which could be extracted for other genomic scoring tasks.
The LLM identified 5 files worth highlighting for reuse:
TrackData is a generic container for multi-track genomic arrays with resolution, interval metadata, and rich slicing/filtering/resampling methods. It supports up/downsampling, reverse complement, concatenation, and interleaving. This component is self-contained and could be reused in any genomic data pipeline that needs to store and manipulate track-level signals (e.g., ATAC-seq, RNA-seq) with coordinate-aware operations.
Defines frozen dataclasses for variant scorers (CenterMaskScorer, GeneMaskLFCScorer, etc.) with validation, proto conversion, and name/is_signed properties. Includes a registry pattern (RECOMMENDED_VARIANT_SCORERS) and tidy_scores/tidy_anndata functions to convert AnnData results into tidy DataFrames. The scorer dataclass pattern is reusable for any domain requiring configurable, composable scoring functions with metadata.
Provides pack_tensor and unpack_tensor functions for efficient conversion between NumPy arrays and protobuf Tensor messages, with configurable chunking and zstd compression. This is a standalone utility that can be reused in any system needing to serialize large numerical arrays over gRPC or other binary protocols.
Implements DnaClient, a gRPC client for the AlphaGenome model service with methods for sequence, interval, and variant prediction. Includes a retry_rpc decorator with exponential backoff and jitter, and handles streaming responses with TensorChunk reassembly. The retry pattern and streaming client architecture are reusable for any gRPC-based prediction service.
Provides a component-based plotting system with abstract base classes (AbstractComponent, AbstractAnnotation) and concrete implementations (Tracks, OverlaidTracks, ContactMaps, TranscriptAnnotation, Sashimi). The plot() function composes these components into a matplotlib figure. This pattern is reusable for building modular, customizable genomic visualizations.