swaruplab/operon/comparative-genomics-introgression-detection

Claude Code and agent skill by swaruplab/operon

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Detect introgression and admixture between species or populations using Dsuite (Malinsky 2021 fast D-statistics), Patterson's D / ABBA-BABA test (Green 2010; Durand 2011), f4-ratio and f-branch statistic (Malinsky 2018), TreeMix (Pickrell & Pritchard 2012), HyDe (Blischak 2018), QuIBL (Edelman 2019), sprime (Browning 2018), Twisst (Martin 2017), PhyloNet (Solis-Lemus 2017) for explicit phylogenetic networks, and qpAdm / qpGraph (Patterson 2012; Lipson 2013). Distinguish introgression from incomplete lineage sorting (ILS), ancestral structure, ghost-lineage admixture, and rate variation. Use when testing inter-species gene flow, dating admixture events, identifying introgressed segments, building phylogenetic networks for reticulate evolution, or applying the ABBAclustering (Koppetsch-Malinsky-Matschiner 2024) framework for divergent-species gene flow.

Install

npx vskill@latest install swaruplab/operon/comparative-genomics-introgression-detection

SKILL.md

The same SKILL.md was published earlier as swaruplab/operon/comparative-genomics-introgression-detection.

Version Compatibility

Reference examples tested with: Dsuite 0.5+ (millanek/Dsuite; Malinsky 2021 Mol Ecol Res 21:584; ABBAclustering option from Koppetsch-Malinsky-Matschiner 2024 Syst Biol), HyDe 0.4.3+ (Blischak 2018 Syst Biol 67:821), QuIBL (Edelman 2019 Science 366:594), TreeMix 1.13+ (Pickrell & Pritchard 2012 PLoS Genet 8:e1002967), sprime (Browning 2018 Cell 173:53), Twisst (Martin & Van Belleghem 2017 Genetics 206:429), PhyloNet 3.8.2+ (NakhlehLab/PhyloNet; Than-Ruths-Nakhleh 2008 BMC Bioinf 9:322) and PhyloNetworks 0.16+ (JuliaPhylo/PhyloNetworks; Solis-Lemus & Ane 2017 PLoS Comp Biol 13:e1005485), qpAdm / qpGraph (AdmixTools v2.0+; Maier 2023), ADMIXTOOLS2 R wrapper (Maier 2023 eLife 12:e85492), MaCS-like simulators (msprime 1.3+ for testing), bcftools 1.21+, samtools 1.21+, vcftools 0.1.16+, R 4.4+. See upstream Dsuite docs for visualization helpers.

Before using code patterns, verify installed versions match. If versions differ:

  • CLI: Dsuite --version; treemix --help; qpDstat --help (AdmixTools)
  • Python: pip show msprime hyde
  • R: packageVersion('admixtools')

If code throws Dsuite SETS file format error, TreeMix matrix singular, qpAdm rotation failed, these tools share strict input requirements: Dsuite needs a SETS file mapping samples to populations + an outgroup; TreeMix needs allele-frequency matrix; qpAdm needs ind / snp / geno trio (EIGENSTRAT format).

Introgression and Admixture Detection

"Has there been gene flow between these species / populations?" -> Tests for inter-population admixture span site-frequency (ABBA-BABA, f4), tree-topology (Dsuite f-branch, QuIBL, Twisst), explicit-network (PhyloNet), and gene-trajectory (sprime, hapne) approaches. The fundamental confounder is incomplete lineage sorting (ILS): under a symmetric tree with no gene flow, the ABBA and BABA patterns occur with equal frequency from ancestral polymorphism. A significant D-statistic indicates EITHER (a) introgression, OR (b) ancestral structure, OR (c) sampling from a ghost lineage -- additional evidence is required to distinguish (Green 2010 Science 328:710; Durand 2011 MBE 28:2239; Eriksson & Manica 2012 PNAS 109:13956). For high-confidence claims, combine D-statistic with f-branch mapping (assigns admixture to specific branches), Twisst / QuIBL topology-weighting, and TreeMix migration edges.

  • CLI: Dsuite Dtrios -- standard D-statistic for trios of populations
  • CLI: Dsuite Fbranch -- assign admixture signal to specific tree branches
  • CLI: treemix -i freq.gz -k 1000 -m 0 -o out -- migration edges
  • CLI: qpAdm (AdmixTools) -- rotation-based admixture proportion testing
  • R: admixtools::qpadm() modern wrapper
  • CLI: HyDe -i sequences -t taxa.txt --hyptest -- hybridization detection at site level
  • CLI: python QuIBL.py inputfile.txt (config file with treefile path + parameters) -- topology weighting for ILS vs introgression

Algorithmic Taxonomy

Tool / StatisticApproachOutputStrengthFails when
Patterson's D / ABBA-BABA (Green 2010 Science 328:710; Durand 2011 MBE 28:2239)Counts ABBA vs BABA site patterns in fixed tree (((P1, P2), P3), Out)D = (ABBA - BABA) / (ABBA + BABA)Standard introgression test; tractableD > 0 means EITHER admixture OR ancestral structure OR ghost lineage
Dsuite Dtrios (Malinsky 2021 Mol Ecol Res 21:584)Fast D for all population triosD + jackknife SE + p-valueScales to many populations; integrated with phylogenetic treeInherits ABBA-BABA assumptions; symmetric tree only
f4-ratio statistic (Patterson 2012 Genetics 192:1065)Quartet-based admixture proportionAdmixture proportion alphaCleaner than D for inferring admixture amountRequires correct phylogeny; ILS confound
Dsuite Fbranch (Malinsky 2018 Nat Eco Evo 2:1940)Tree-aware f4-ratio mappingBranch-specific admixture signalBest at distinguishing admixture among related lineagesTree must be reliable; ghost branches not detectable
ABBAclustering (Koppetsch-Malinsky-Matschiner 2024 Syst Biol)Dsuite option for divergent-species gene flowCluster-based admixtureDesigned for cases where standard ABBA-BABA failsNewer; specific use case
TreeMix (Pickrell & Pritchard 2012 PLoS Genet 8:e1002967)ML tree with migration edges from drift covarianceTree + migration edges with weightsVisualizes complex admixtureMigration-edge selection subjective; allele-frequency-based
qpAdm (Patterson 2012; AdmixTools v2.0; Maier 2023 eLife 12:e85492)Tests if target derives from sources via rotationPass/fail per source set + admixture proportionRobust statistical framework; rotation controlSource population sampling critical
qpGraph (Patterson 2012)ML phylogenetic graph with admixtureBest-fit graph with admixture nodesQuantitative; explicit tree+admixture modelComputationally heavy; manual graph topology design
HyDe (Blischak 2018 Syst Biol 67:821)Site-level hybridization detectionPer-site / per-locus hybrid evidenceSensitive to recent hybridizationLess specific to ancient admixture
QuIBL (Edelman 2019 Science 366:594)Topology weighting on gene treesPer-tree-weight relative to alternativeDistinguishes ILS from introgression at locus levelPer-locus inference; cross-validation needed
Twisst (Martin & Van Belleghem 2017 Genetics 206:429)Topology weighting on phylogenetic treesTree topology weights per genomic windowVisualize topology variation across genomeComputational cost; tree-window decisions
PhyloNetworks (Solis-Lemus & Ane 2017 PLoS Comp Biol 13:e1005485; Julia, JuliaPhylo/PhyloNetworks)SNaQ pseudo-likelihood network inference from gene trees / concordance factorsExplicit reticulation networkModern Julia ecosystem; SNaQ scales wellDifferent software than the Java "PhyloNet"
PhyloNet (Than-Ruths-Nakhleh 2008 BMC Bioinf 9:322; Java, NakhlehLab/PhyloNet)ML / MP / Bayesian network inferenceExplicit reticulation networkMature Java tool; many inference modesComputationally heavy; Maven build
sprime (Browning 2018 Cell 173:53)Per-individual archaic introgression detectionIntrogressed haplotype tractsDesigned for archaic-human-like casesSpecific to closely related introgression source
Relate (Speidel 2019 Nat Genet 51:1321) + hapne (Fournier 2023 Nat Commun 14:7517)Phasing-aware genealogy + introgression haplotype datingIntrogressed segments + ages from tract-length distributionModern haplotype-aware methodsRequire phased data; Relate genealogy precedes hapne dating
F3 statistic (Patterson 2012)Three-population test for admixtureF3 with SESpecifically detects admixture (vs negative drift)F3 < 0 indicates admixture; mixed signals
F4-statistic (Patterson 2012)Four-population testF4 + p-valueGeneralizes D; allows variable outgroup distanceSymmetric assumption

Methodology evolves; verify the Dsuite documentation and Malinsky 2024 review (eLife) before locking on a single approach. The combination of (1) Dsuite D + Fbranch + (2) Twisst / QuIBL + (3) network method (PhyloNet) is the modern best practice for publication-grade introgression claims.

Decision Tree by Experimental Scenario

ScenarioRecommended approachWhy
Test for introgression between two species, outgroup availableDsuite Dtrios + FbranchStandard ABBA-BABA + tree-aware branch mapping
Multi-population complex admixture inferenceTreeMix + qpAdmMigration edges + rotation tests
Distinguish introgression from ILSQuIBL + Twisst across many lociTopology weighting at locus level
Date the admixture eventRelate (Speidel 2019) + hapne (Fournier 2023) + Twisst window analysisGenealogy reconstruction + haplotype-length-distribution dating + topology
Quantify admixture proportion alphaf4-ratio (Patterson 2012) or qpAdmStandard framework
Identify introgressed genomic regionssprime + TwisstPer-individual + per-window
Explicit phylogenetic networkPhyloNet with model selection (DLRS-NL or InferNetwork_MP)Quantitative reticulation
Test for ghost-lineage admixtureqpGraph manual topology + AdmixTools rotationCompare alternative graphs
Recent hybridizationHyDe + per-individual analysisSite-level hybrid evidence
Ancient introgressionDsuite + qpAdm; Patterson f-statistics for archaicTree-aware methods preferred
Plant-plant hybridization with parental polyploidyHyDe + sprime + chromosome-level analysisPolyploid context
Human-archaic introgression (Neanderthal, Denisovan)sprime + qpAdm + ChromoPainterSample-specific haplotype analysis
Cichlid radiationDsuite + TreeMix + QuIBL (Malinsky 2018 Nat Eco Evo 2:1940)Established workflow
Drosophila species groupDsuite + Twisst + qpAdmStandard workflow
Genomic regions of introgression vs vertical inheritanceTwisst per-window + chromosome paintingVisualization of variation across genome
Test for introgression direction (P1 -> P2 vs P2 -> P1)qpAdm rotation; Twisst directionality from phasingqpAdm handles direction better than D
Symmetric phylogeny violation (no clear outgroup)f3 statistic + qpGraph topologyAvoid D-statistic if outgroup unclear
Suspect ABBA-BABA ILS-confoundedSwitch to QuIBL or Twisst for locus-level discriminationThese distinguish ILS from introgression

Per-Method Failure Modes

ILS confounded with introgression in D-statistic

Trigger: D-statistic significantly different from zero for a population trio.

Mechanism: Under symmetric phylogeny with no gene flow, ABBA and BABA patterns occur with equal frequency from ancestral polymorphism (ILS). Random allele sorting in descendant lineages produces the same site patterns as introgression. D > 0 is therefore consistent with introgression OR with asymmetric ILS OR with ancestral structure (Eriksson & Manica 2012 PNAS 109:13956).

Symptom: Many tested trios show D > 0 with low effect size; Twisst / QuIBL on the same loci shows mixed topologies; phylogenetic distance to outgroup is large.

Fix: Use Dsuite f-branch (Malinsky 2018) to assign admixture to specific branches; verify with QuIBL or Twisst topology weighting at the locus level. ABBAclustering (Koppetsch-Malinsky-Matschiner 2024) specifically handles divergent-species gene flow.

Ghost lineage admixture mimicking signal

Trigger: Inferring P1 -> P2 admixture without considering that the admixed lineage could come from an unsampled extinct sister to P3.

Mechanism: D > 0 with P3 as donor is identical to D > 0 with a ghost sister of P3 as donor. The data cannot distinguish without explicit modeling.

Symptom: Hypothesized donor population doesn't match expected geography or ecology; qpGraph cannot fit a parsimonious admixture model without invoking ghost lineages.

Fix: Build qpGraph with potential ghost lineages explicitly; report multiple compatible scenarios; consult known paleontology / biogeography to constrain possibilities. The Neanderthal-Denisovan-anatomically-modern-human framework is heavily ghost-lineage-aware (Slon 2018; Mafessoni 2020).

Ancestral structure (population subdivision before admixture)

Trigger: Significant D-statistic in a recently diverged radiation.

Mechanism: Ancestral subdivision in the ancestor of (P1, P2, P3) produces D > 0 from biased ancestral allele inheritance, not from gene flow between descendants.

Symptom: D positive across multiple trios but pattern not consistent with simple admixture; effect size differs from f-statistic predictions; rapid radiation context.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
99
Repository forks
11
7-day trend score
28

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/swaruplab/operon/comparative-genomics-introgression-detection/badge)](https://verified-skill.com/skills/swaruplab/operon/comparative-genomics-introgression-detection)

Something wrong with this skill or its page? Tell us.