systems-biology/context-specific-models/SKILL.md
Builds tissue-, cell-type-, and condition-specific metabolic models by integrating transcriptomic or proteomic data into a generic genome-scale model, using extraction algorithms (GIMME, iMAT, INIT/tINIT, MADE, E-Flux, CORDA, FASTCORE) via troppo and corda in Python or the COBRA Toolbox/RAVEN in MATLAB. Use when pruning a generic model to a context, choosing an extraction method and expression threshold, mapping expression through GPR rules to reactions, deciding whether an objective is required (GIMME vs iMAT), avoiding the growth-objective trap for non-proliferating tissue, or judging how much of a context-specific model is real signal versus an artifact of the threshold and method.
npx skillsauth add GPTomics/bioSkills bio-systems-biology-context-specific-modelsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reference examples tested with: COBRApy 0.29+, corda 0.5+, numpy 1.26+, pandas 2.2+, Python 3.10+
Before using code patterns, verify installed versions match. If versions differ:
pip show <package> then help(module.function) to check signaturesIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Note: COBRApy core does NOT implement GIMME/iMAT/INIT. Real Python implementations live in troppo (multi-method) and corda (CORDA); the reference multi-method implementations are the MATLAB COBRA Toolbox createTissueSpecificModel and RAVEN (INIT/tINIT). Do not expect a cobra.flux_analysis.gimme(); it does not exist.
"Build a liver-specific metabolic model from my expression data" -> Prune/constrain a generic genome-scale model to the reactions an extraction algorithm judges active in that context, given omics data mapped through GPR rules and a threshold.
corda.CORDA (CORDA), troppo (GIMME/iMAT/tINIT/FASTCORE/CORDA); MATLAB: COBRA Toolbox createTissueSpecificModel, RAVEN (COBRApy for downstream FBA)Two facts govern every context-specific model:
A corollary trap: GIMME-family methods require a protected objective (usually biomass). For a differentiated, non-proliferating tissue (hepatocyte, neuron), forcing a growth objective is a category error - those cells are not making copies of themselves. Use an objective-free method (iMAT) or a task-based one (tINIT) for non-growing tissue, or define a genuine maintenance/functional task instead of biomass.
| Method | Objective/task required? | Expression handling | Best implementation | When | |--------|--------------------------|---------------------|---------------------|------| | GIMME (Becker & Palsson 2008) | Yes (biomass/task) | discrete threshold; penalize below-threshold flux | troppo (Py); COBRA Toolbox (MATLAB) | proliferating cells with a real objective | | iMAT (Shlomi 2008; Zur 2010) | No | discrete high/low buckets (MILP) | troppo (Py); COBRA Toolbox (MATLAB) | non-growing human tissue; the common default | | INIT / tINIT (Agren 2012/2014) | tINIT: metabolic TASKS | protein/HPA evidence + net accumulation | RAVEN (MATLAB) | task-guaranteed, functional tissue models | | MADE (Jensen & Papin 2011) | No | differential significance, no absolute threshold; needs >=2 conditions | MATLAB (TIGER) | comparative/time-course designs | | E-Flux (Colijn 2009) | No | expression sets continuous flux BOUNDS (no discretization) | custom (simple) | quick continuous constraint; no on/off decision | | CORDA (Schultz & Qutub 2016) | No | 5 confidence classes; dependency-rescued | corda (Python, turnkey) | cancer/tissue models; "concise not minimal" | | FASTCORE (Vlassis 2014) | core reaction set | core + minimal consistent extension | troppo (Py); COBRA Toolbox | fast, compact, given a trusted core |
Honest tooling reality: the most complete, best-validated implementations are MATLAB (COBRA Toolbox / RAVEN). In Python, troppo is the multi-method option and corda is the most turnkey native implementation. Steering a user to "just use COBRApy" for iMAT/GIMME sends them into reimplementing an algorithm.
Goal: Convert per-gene expression into a per-reaction activity score that respects enzyme logic.
Approach: Evaluate the GPR with min for AND (a complex is limited by its scarcest subunit) and max for OR (any isozyme suffices). This min/max convention is standard but lossy - it discards the quantitative contribution of all but the limiting/dominant gene.
def reaction_activity(rxn, gene_expr, default=0.0):
'''Aggregate gene expression to a reaction score: min over AND (complex), max over OR (isozyme).'''
if not rxn.genes:
return default
values = [gene_expr.get(g.id, default) for g in rxn.genes]
return max(values) # simplified OR; a full parser applies min within each AND-clause first
Goal: Reconstruct a context-specific model that keeps as many high-confidence reactions as possible while excluding absent ones, rescuing reactions that high-confidence ones depend on.
Approach: Translate expression into CORDA's five confidence classes (-1 absent, 0 unknown, 1 low, 2 medium, 3 high) via the GPR, then let CORDA build a "concise but not minimal" model.
from corda import CORDA, reaction_confidence
# gene_conf maps gene id -> confidence in {-1, 0, 1, 2, 3}; derive it from expression quantiles.
gene_conf = {g.id: 2 for g in model.genes}
rxn_conf = {r.id: reaction_confidence(r, gene_conf) for r in model.reactions} # pass the Reaction, not its GPR string
opt = CORDA(model, rxn_conf)
opt.build()
context_model = opt.cobra_model('liver') # verify the exact accessor for the installed corda version
Goal: Show the objective-protected pruning idea GIMME encodes, for teaching - not as a substitute for a validated implementation.
Approach: Require the objective to stay above a floor, then penalize/limit flux through reactions whose genes are all below the expression threshold. A faithful GIMME solves a single LP with an inconsistency score; this stub only illustrates the shape and must not be reported as GIMME output.
import numpy as np
def gimme_style_stub(model, gene_expr, low_quantile=0.25, growth_floor=0.1):
'''Illustrative only. For real GIMME/iMAT use troppo or the COBRA Toolbox.'''
cutoff = np.quantile(list(gene_expr.values()), low_quantile)
low = {g for g, v in gene_expr.items() if v < cutoff}
ctx = model.copy()
biomass = str(model.objective.expression).split('*')[1].split()[0]
ctx.reactions.get_by_id(biomass).lower_bound = growth_floor # protect the objective
for rxn in ctx.reactions:
genes = {g.id for g in rxn.genes}
if genes and genes <= low:
rxn.bounds = (max(rxn.lower_bound, -1.0), min(rxn.upper_bound, 1.0))
return ctx
# The single on/off threshold moves the model more than the algorithm does. Options:
# - Global: one cutoff across all genes/samples (simple; ignores gene-specific expression ranges).
# - Local: a per-gene cutoff (e.g. a gene is "on" relative to its own distribution across samples).
# - StanDep (Joshi 2020): clusters genes by expression pattern and thresholds per cluster; captures
# housekeeping vs peaky genes that a single global cutoff mishandles.
# Always run a sensitivity check: rebuild at 2-3 thresholds and report which reactions/pathways are
# stable vs threshold-dependent. Report proteomics-derived scores separately; protein is closer to
# flux capacity than mRNA but still not flux.
# - Single-cell input: scRNA-seq zeros are dominated by technical DROPOUT, which inverts the
# "absence is a strong constraint" logic (a zero may be an unobserved, not an absent, transcript).
# Aggregate to pseudobulk or metacells PER CELL TYPE before extraction (or use a single-cell-native
# method); do not threshold individual cells. See single-cell/cell-annotation.
| Symptom | Cause | Fix |
|---------|-------|-----|
| AttributeError: cobra.flux_analysis has no gimme | COBRApy ships no GIMME/iMAT/INIT | use troppo/corda (Python) or COBRA Toolbox/RAVEN (MATLAB) |
| Context model of a neuron/hepatocyte cannot satisfy biomass | GIMME-family objective forced on non-proliferating tissue | use iMAT (objective-free) or tINIT (task-based); do not protect biomass |
| Two analysts get different tissue models from the same data | threshold/method/objective differ | fix and report all three; run a threshold sensitivity sweep |
| Reaction present in data but pruned out | presence is a weak signal; the method judged it inactive in context | expected; do not over-trust presence, and check the GPR aggregation |
| Absent transcript but reaction kept | absence is only a moderate constraint; a dependency rescued it (CORDA) | inspect opt.redundancies/dependency rescue; decide if the rescue is justified |
| Model predicts overflow/Warburg poorly | expression pruning has no enzyme-capacity budget | use enzyme-constrained models (GECKO/sMOMENT) with proteomics |
development
Installs 425 bioinformatics skills covering sequence analysis, RNA-seq, single-cell, variant calling, metagenomics, structural biology, and 56 more categories. Use when setting up bioinformatics capabilities or when a bioinformatics task requires specialized skills not yet installed.
testing
Chains a somatic (tumor-normal) SNV/indel and structural-variant pipeline end to end with GATK Mutect2 (or Strelka2), wiring the somatic-specific machinery - panel-of-normals and gnomAD germline-resource priors, GetPileupSummaries/CalculateContamination, and LearnReadOrientationModel FFPE/oxoG orientation-bias filtering fed into FilterMutectCalls. Use when calling somatic mutations from a tumor-normal pair (or tumor-only with PoN caveats), deciding which artifact filter removes which class of false positive, reasoning about VAF/purity/ploidy and clonal-vs-subclonal detection, adding somatic SV/CNV or TMB/MSI/signatures, or routing variants to AMP/ASCO/CAP tier and oncogenicity interpretation (never germline ACMG).
development
End-to-end pooled and single-cell CRISPR screen analysis from FASTQ to hit genes. Orchestrates library design QC, guide counting, six-stage screen QC (plasmid Gini, replicate Pearson, CEGv2 PR-AUC, copy-number artifact), method-appropriate hit calling across MAGeCK RRA/MLE, BAGEL2, drugZ, JACKS, and Chronos, cancer-cell-line copy-number correction (CRISPRcleanR / Chronos), batch correction for multi-batch screens, and the specialized branches for combinatorial paralog screens, single-cell Perturb-seq, base-editor variant-function screens, prime-editor screens, and in vivo bottleneck-aware screens. Use when analyzing any pooled CRISPR screen end-to-end, matching the hit-calling method to the experimental design, integrating copy-number correction into the pipeline, or branching the workflow for single-cell, combinatorial, base-editor, prime-editor, or in vivo variants.
development
Transcribe DNA to RNA and translate to protein using Biopython, with NCBI codon-table selection, CDS validation, and six-frame ORF finding. Use when converting a CDS or ORF to its amino-acid sequence, selecting a non-standard (mitochondrial, bacterial, ciliate) genetic code, validating a coding sequence, or scanning all reading frames.