AlphaGenome PyTorch

A PyTorch port of AlphaGenome, the DNA sequence model from Google DeepMind that predicts hundreds of genomic tracks at single base-pair resolution from sequences up to 1M bp.
We strive to make it an accessible, readable, and hackable implementation — for integrating into existing PyTorch pipelines, fine-tuning on custom datasets, and building on top of.
Installation
Installation from PyPI:
pip install alphagenome-pytorch
Installation from repo:
pip install git+https://github.com/genomicsxai/alphagenome-pytorch
For fine-tuning (incl. BigWig data loading):
pip install alphagenome-pytorch[finetuning] # adds pyBigWig, pyfaidx
For DeepLIFT attribution:
pip install alphagenome-pytorch[attribution] # adds tangermeme
Use with coding agents
If you use a coding agent, docs/alphagenome-usage.md is an
agent-agnostic guide to running the model and pulling out predictions for a specific
assay, cell type, or resolution, and docs/finetuning/
covers fine-tuning.
For Claude Code, install them as a plugin so the agent picks them up automatically in any
project:
/plugin marketplace add genomicsxai/alphagenome-pytorch
/plugin install alphagenome@alphagenome
This adds two skills — one for predictions, one for fine-tuning — so you can ask things
like "get DNase predictions from GM12878 at 128bp", "write a wrapper to get all the
K562 predictions", or "fine-tune on my ATAC BigWigs with LoRA".
Quick Start
import torch
import numpy as np
from alphagenome_pytorch import AlphaGenome
# Load pretrained model
model = AlphaGenome.from_pretrained('alphagenome.pt', device='cuda')
# Create one-hot encoded DNA sequence in NLC format (batch=1, length=131072, channels=4)
# Channels: A=0, C=1, G=2, T=3
sequence = np.random.randint(0, 4, size=(1, 131072))
dna_onehot = torch.tensor(np.eye(4)[sequence], dtype=torch.float32).cuda()
# Inference (handles dtype casting, returns float32 outputs)
outputs = model.predict(dna_onehot, organism_index=0) # organism: 0=human, 1=mouse
The weights for this port are available on Hugging Face.
Output structure
Each genomic-track head returns a dict mapping resolution → tensor:
outputs['atac'][1] # (1, 131072, 256) ATAC-seq at 1 bp
outputs['atac'][128] # (1, 1024, 256) ATAC-seq at 128 bp
outputs['dnase'][1] # (1, 131072, 384) DNase at 1 bp
outputs['cage'][128] # (1, 1024, 640) CAGE at 128 bp
outputs['chip_histone'][128] # (1, 1024, 1152) ChIP-hist at 128 bp only
Contact maps are returned as a single tensor (no resolution dict):
outputs['contact_maps'] # (1, 64, 64, 28) 3D chromatin contacts
Splice heads return dicts of tensors:
outputs['splice_sites']['probs'] # (1, 131072, 5) splice site classes
Padding
Track dimensions are padded (e.g. ATAC has 167 real human
tracks but the tensor has 256 channels). Real tracks come first; the rest
are zeros. Use named_outputs=True to auto-strip padding:
from alphagenome_pytorch.named_outputs import NamedOutputs, TrackMetadataCatalog
catalog = TrackMetadataCatalog.load_builtin(organism=0)
model.set_track_metadata_catalog(catalog)
named = model.predict(dna_onehot, organism_index=0, named_outputs=True)
named.atac[1].shape # (1, 131072, 167) — padding removed
named.atac[1].tracks[-1].track_name # 'UBERON:0015143 ATAC-seq'
# Filter by metadata
named.rna_seq[128].select(strand='+')
named.chip_tf[128].select(transcription_factor='CTCF')
named.atac[1].select(biosample_type='tissue', ontology_curie='UBERON:0015143')
Extracting Embeddings
Use model.encode() to get embeddings without running prediction heads — useful for
building custom heads or analyzing representations:
# Get embeddings (128bp only for efficiency)
emb = model.encode(dna_onehot, organism_index=0, resolutions=(128,))
emb['embeddings_128bp'] # (B, 1024, 3072) at 128bp
Fine-tuning
Train a new head on your data with frozen trunk (linear probing) or with LoRA adapters:
from alphagenome_pytorch import (
AlphaGenome, TransferConfig, load_trunk, prepare_for_transfer,
)