alphagenome-single-variant-analysis
Original:🇺🇸 English
Translated
7 scriptsChecked / no sensitive code detected
Analyzes genetic variant effects on gene expression (RNA-seq), chromatin accessibility (DNASE), histone marks (ChIP), and transcription factors using the AlphaGenome API. Use when the user asks about non-coding variant effects, pathogenicity, clinical significance, disease associations, functional effects, gene expression changes, splicing disruption, or regulatory effects in promoters and enhancers. Also use for resolving biological terms to tissue/cell-type ontologies (UBERON/CL) or analyzing variants in chr:pos:ref>alt format.
6installs
Added on
NPX Install
npx skill4agent add google-deepmind/science-skills alphagenome-single-variant-analysisTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Variant Analysis using AlphaGenome
Prerequisites
-
: Read the
uvskill and follow its Setup instructions to ensureuvis installed and on PATH.uv -
User Notification: If LICENSE_NOTIFICATION.txt does not already exist in this skill directory then (1) prominently notify the user to check the terms at https://deepmind.google.com/science/alphagenome/, then (2) create the file recording the notification text and timestamp.
-
file: Make sure the
.envfile exists in your home directory. Create one if it does not exist..env -
: This skill requires an API key to function. You must ask the user for an API key if this skill looks relevant to their request and you do not have one in .env. The user can sign up at https://deepmind.google.com/science/alphagenome/. Do NOT ask the user to paste their key into the chat (this would leak the key into the agent's context). Instead, explain that a key is necessary to use AlphaGenome and give the user this command substituting
ALPHAGENOME_API_KEYwith the resolved literal path to theENV_FILEfile:.envbashprintf "Enter AlphaGenome API key (typing hidden): " && read -s key && echo && echo "ALPHAGENOME_API_KEY=$key" >> "ENV_FILE" && echo "Saved."The scripts load credentials automatically via. NEVER read, print, or inspect thedotenvfile or its variables (e.g. no.env,cat,grep,echo, orprintenvon keys). Credentials must stay out of the agent's context.os.environ.getWhen running in sandbox,will be a no-op, and instead the sandbox will read credentials and inject them directly.dotenv.load_dotenv()
Core Rules
- NEVER run or
python3directly. The system Python does not necessarily have pandas, numpy, and other key dependencies. ALWAYS usepython3 -cto run ALL Python code — including scripts, ad-hoc analysis files, and one-liners. Do not attempt touv runor create new venvs —pip installmanages an isolated environment automatically.uv - Offline Only: NEVER use external APIs (e.g., MyGene.info, Ensembl REST)
for gene/transcript lookup. Use with the local GTF. If it fails, fix the environment/paths, do not switch to external APIs.
lookup_gene_info.py - API Key is required: must be set before running any script (in sandbox, credentials are injected automatically).
ALPHAGENOME_API_KEY - Notification: If this skill is used, ensure this is mentioned in the output.
- Report Format: Always use the templates in for generating analysis reports, and ensure to include the table of top hits from the discovery scan.
docs/report-templates.md
Environment Setup & Troubleshooting
Python Environment
All scripts must be executed using , which manages an isolated virtual
environment with the correct dependencies via .
uv runuvbash
uv run <script_name> [args...]For ad-hoc scripts (e.g., inline analysis code saved to a temp file), pass the
full path instead of a short name:
bash
uv run --project $SKILL_DIR /tmp/my_analysis.py --arg1 val1[!NOTE] The first invocation resolves and installs dependencies (~10s). Subsequent runs use the cached environment and start instantly. The cache lives in.~/.cache/uv/
Common Issues
- Column Names: and metadata often use
tidy_scores(notgene_name) andgene_symbol(notoutput_type). Always inspectmodalitybefore filtering.df.columns - Large Genes: Genes > 500kb (e.g., ) break the
USH2Aview. Usewhole_geneor manual regional windows instead.--view detail - Sashimi Strand Error: does NOT accept a
plot_components.Sashimiargument directly. Filter input tracks instead.strand - KeyError: 'ontology_curie': Not all tracks have . Check
ontology_curiebefore filtering.track.metadata.columns - Python Path: If occurs, ensure you are using
exec: "python": executable file not foundinstead of bareuv run/python.python3 - NotImplementedError (pandas): "iLocation based boolean indexing on an
integer type is not available". This occurs when using boolean masks with
on integer-indexed DataFrames in newer pandas versions. Fix: Convert boolean masks to integer indices using
.iloc.np.flatnonzero(mask) - GTF Feather Case Sensitivity: The AlphaGenome GTF Feather file uses
Capitalized column names (,
Feature,Start,End) unlike standard GTF files. Always checkStrandif getting KeyErrors.df.columns - ontology filtering:
score_variantdoes NOT acceptscore_variantas an argument. You must filter the returned AnnData objects manually by inspectingontology_termscolumns. In contrast,adata.varDOES acceptpredict_variantdirectly.ontology_terms - Sashimi Zoom Logic: To ensure "skipping" arcs are visible, expand the zoom to include the flanking exons rather than relying on junction overlap alone.
- Junction Scores: Raw objects from
Junctionmay be simple Intervals. Usepredictionto retrieve objects with thejunction_data.get_junctions_to_plot(predictions=..., name=...)(abundance/score) attribute..k - Not Found: If
uv, follow the installation instructions in Prerequisites.exec: uv: not found - Registry Authentication Error (401): If fails with 401 Unauthorized for a private registry, set
uvbefore running the script.UV_INDEX_URL=https://pypi.org/simple
References
- alphagenome-api.md — API reference and code patterns
- interpretation-guide.md — Interpretation guide, score magnitude rules, ISM, and checklist.
- report-templates.md — Full report templates
- — Single-variant visualization template (Ref/Alt comparisons, Splicing).
scripts/visualize_variant_effects.py- Splicing Zoom Strategy: Uses a Hybrid Approach for optimal
visibility:
- Base Interval: Variant +/- 1 downstream and upstream exon (Structural Context).
- Junction Expansion: Expands to include the full span of any significant splicing junction (e.g., exon skipping events that span multiple exons).
- Anchor Enforcement: Ensures the exons anchoring these long junctions are fully visible. Lesson: Simple fixed windows (e.g., 2kb) or nearest-exon logic often fail for skipping events. Always use the observed junction data to drive zoom levels.
- Splicing Zoom Strategy: Uses a Hybrid Approach for optimal
visibility:
- — Splicing analysis examples
examples/splicing/ - — ncRNA structure limitation case study
examples/model_limitation_RNU4ATAC/ - — 3' UTR / Polyadenylation case study
examples/polyadenylation_HBA2/ - — Regulatory variant examples
examples/regulatory/ - — Negative results (mathematical artefact)
examples/negative_result_GATA4/ - — Negative results (proxies)
examples/negative_result_TGFB3/ - — Gene & transcript lookup
scripts/lookup_gene_info.py - — Ontology term resolution (UBERON/CL IDs)
scripts/resolve_ontology_terms.py
Code Patterns
Broad Discovery Scan
Use across differential scorers only to discover unexpected
tissue effects.
score_variantpython
from alphagenome.models import dna_client
from alphagenome.models import variant_scorers
from alphagenome.data import genome
import os
import pandas as pd
# Setup API Key and Client
dna_model = dna_client.create(api_key=os.environ.get('ALPHAGENOME_API_KEY'),
address='dns:///gdmscience.googleapis.com:443')
# Define Variant (example)
variant_str = "chr2:1234:A>C"
chrom, pos_str, ref_alt = variant_str.split(':')
ref, alt = ref_alt.split('>')
pos = int(pos_str)
# Use supported sequence length (e.g., 2**20 for optimal performance)
SEQ_LENGTH = 2**20
interval = genome.Interval(chrom, pos - SEQ_LENGTH // 2, pos + SEQ_LENGTH // 2)
variant = genome.Variant(chrom, pos, ref, alt)
scorers = [
variant_scorers.RECOMMENDED_VARIANT_SCORERS[m]
for m in variant_scorers.RECOMMENDED_VARIANT_SCORERS
if "ACTIVE" not in m and "CAGE" not in m and "PROCAP" not in m
]
print(f"Scoring variant {variant_str}...")
scores_list = dna_model.score_variant(interval=interval, variant=variant, variant_scorers=scorers)
# Process and Display Results
all_dfs = []
for score_adata in scores_list:
df = variant_scorers.tidy_scores([score_adata], match_gene_strand=True)
if df is not None:
all_dfs.append(df)
if all_dfs:
df = pd.concat(all_dfs)
significant = df[df['quantile_score'].abs() > 0.995]
ranked = significant.sort_values('raw_score', key=abs, ascending=False)
print("Top Significant Hits:")
print(ranked[['biosample_name', 'gene_name', 'output_type', 'quantile_score', 'raw_score']])Extended Search for Disease-Relevant Tissues
python
# Define keywords based on disease context
disease_keywords = ["liver", "hepatocyte"]
# Filter for any match
mask = df['biosample_name'].str.contains('|'.join(disease_keywords), case=False, na=False)
relevant_hits = df[mask].sort_values('raw_score', key=abs, ascending=False)
print(f"\n--- Extended Analysis (Keywords: {disease_keywords}) ---")
print(relevant_hits.head(20)[['biosample_name', 'output_type', 'raw_score', 'quantile_score']])Workflow Checklist
Variant Analysis Progress:
- [ ] Step 0: Review Golden Examples (MANDATORY)
- [ ] Step 1: Create Output Folder and Setup
- [ ] Step 2: Parse User Query & Research
- [ ] Step 3: Resolve Tissues & Modalities
- [ ] Step 4: Visualize & Save Plots
- [ ] Step 5: Analyze Predictions (view plots, no code). MANDATORY: Read [interpretation-guide.md](docs/interpretation-guide.md) before interpreting results.
- [ ] Step 6: Write Report, save it as `report.md` (MANDATORY)
- [ ] Step 7: Self-Critique (view `report.md` to verify links & claims)
- [ ] Step 8: Make artifact out of `report.md`Multi-Variant Workflow
If multiple variants are specified, spawn sub-agents to run each variant
analysis and then synthesize each into a single report.
report.mdScript Reference
| Script | Purpose |
|---|---|
| Comprehensive gene and transcript lookup using |
| : : GTF data : | |
| Biological terms → UBERON/CL/EFO IDs |
| REF/ALT visualization (expression, regulatory, |
| : : splicing) : | |
| In-Silico Mutagenesis SeqLogo generation |
| Quantitative splicing analysis (delta scores, |
| : : junctions) : | |
| Genomic track visualization for a region |