Skip to main content

AlphaGenome

Project description

AlphaGenome (wip)

Implementation of AlphaGenome, Deepmind's updated genomic attention model

Appreciation

  • Miquel Anglada-Girotto for contributing the organism, output embedding, loss functions, and all the splicing prediction heads!

Install

$ pip install alphagenome-pytorch

Usage

The main unet transformer, without any heads

import torch
from alphagenome_pytorch import AlphaGenome

model = AlphaGenome()

dna = torch.randint(0, 5, (2, 8192))

# organism_index - 0 for human, 1 for mouse - can be changed with `num_organisms` on `AlphaGenome`

embeds_1bp, embeds_128bp, embeds_pair = model(dna, organism_index = 0) # (2, 8192, 1536), (2, 64, 3072), (2, 4, 4, 128)

Adding all types of output heads (thanks to @MiqG)

import torch
from alphagenome_pytorch import AlphaGenome, publication_heads_config

model = AlphaGenome()

model.add_heads(
    'human',
    num_tracks_1bp = 10,
    num_tracks_128bp = 10,
    num_tracks_contacts = 128,
    num_splicing_contexts = 64, # 2 strands x num. CURIE conditions
)

dna = torch.randint(0, 5, (2, 8192))

organism_index = torch.tensor([0, 1]) # the organism that each sequence belongs to
splice_donor_idx = torch.tensor([[10, 100, 34], [24, 546, 870]])
splice_acceptor_idx = torch.tensor([[15, 103, 87], [56, 653, 900]])

# get sequence embeddings

embeddings_1bp, embeddings_128bp, embeddings_pair = model(dna, organism_index, return_embeds = True) # (2, 8192, 1536), (2, 64, 3072), (2, 4, 4, 128)

# get track predictions

out = model(
    dna,
    organism_index,
    splice_donor_idx = splice_donor_idx,
    splice_acceptor_idx = splice_acceptor_idx
)

for organism, outputs in out.items():
    for out_head, out_values in outputs.items():
        print(organism, out_head, out_values.shape)

# human 1bp_tracks torch.Size([2, 8192, 10])
# human 128bp_tracks torch.Size([2, 64, 10])
# human contact_head torch.Size([2, 4, 4, 128])
# human splice_logits torch.Size([2, 8192, 5])
# human splice_usage torch.Size([2, 8192, 64])
# human splice_juncs torch.Size([2, 3, 3, 64])

# initialize published AlphaGenome for human and mouse
model = AlphaGenome()
model.add_heads(**publication_heads_config['human'])
model.add_heads(**publication_heads_config['mouse'])
model.total_parameters # 259,459,534 (vs ~450 million trainable parameters)

Training

test minimal architecture

# loss quickly decreases and stabilizes at around 1349651
# this minimal model (576,444 parameters) can be run with cpu

python train_dummy.py --config_file=configs/dummy.yaml

Contributing

First install locally with the following

$ pip install '.[test]' # or uv pip install . '[test]'

Then make your changes, add a test to tests/test_alphagenome.py

$ pytest tests

That's it

Vibe coding with some attention network is totally welcomed, if it works

Citations

@article {avsec2025alphagenome,
    title   = {AlphaGenome: advancing regulatory variant effect prediction with a unified DNA sequence model},
    author  = {Avsec, {\v Z}iga and Latysheva, Natasha and Cheng, Jun and Novati, Guido and Taylor, Kyle R. and Ward, Tom and Bycroft, Clare and Nicolaisen, Lauren and Arvaniti, Eirini and Pan, Joshua and Thomas, Raina and Dutordoir, Vincent and Perino, Matteo and De, Soham and Karollus, Alexander and Gayoso, Adam and Sargeant, Toby and Mottram, Anne and Wong, Lai Hong and Drot{\'a}r, Pavol and Kosiorek, Adam and Senior, Andrew and Tanburn, Richard and Applebaum, Taylor and Basu, Souradeep and Hassabis, Demis and Kohli, Pushmeet},
    elocation-id = {2025.06.25.661532},
    year    = {2025},
    doi     = {10.1101/2025.06.25.661532},
    publisher = {Cold Spring Harbor Laboratory},
    URL     = {https://www.biorxiv.org/content/early/2025/06/27/2025.06.25.661532},
    eprint  = {https://www.biorxiv.org/content/early/2025/06/27/2025.06.25.661532.full.pdf},
    journal = {bioRxiv}
}
@misc{gopalakrishnan2025decouplingwhatwherepolar,
    title   = {Decoupling the "What" and "Where" With Polar Coordinate Positional Embeddings}, 
    author  = {Anand Gopalakrishnan and Robert Csordás and Jürgen Schmidhuber and Michael C. Mozer},
    year    = {2025},
    eprint  = {2509.10534},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/2509.10534}, 
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alphagenome_pytorch-0.2.0.tar.gz (505.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alphagenome_pytorch-0.2.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file alphagenome_pytorch-0.2.0.tar.gz.

File metadata

  • Download URL: alphagenome_pytorch-0.2.0.tar.gz
  • Upload date:
  • Size: 505.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for alphagenome_pytorch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8bd0fb20604c6c645c1bba73f30284499a30da96735c3532c6e3af030d007f33
MD5 6f5bc6353d2b13fd36abc1a1fee4a3fb
BLAKE2b-256 9f91e59dcc0df888b9228490bf04ab78df0a252d9cbc68acc24a6d0d3d6c5b80

See more details on using hashes here.

File details

Details for the file alphagenome_pytorch-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for alphagenome_pytorch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b052aead9ee93981aa365a7407567f179626a59e95a5e6107e8a8f018cfa112d
MD5 0a817f457fd7df01cf5a473e5b37ef41
BLAKE2b-256 13d24328de2cd8ebda18adceb2b9194a34f88b0a56471070b17db35029a5fd2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page