[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EEAH3BMJASNS7HTQ6C0XQP":3,"skill-same:01M7EEAH3BMJASNS7HTQ6C0XQP":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7EEAH3BMJASNS7HTQ6C0XQP","bio-metagenomics-strain-tracking",null,"Resolves and compares bacterial strains below the species level from shotgun metagenomes with inStrain (popANI\u002FconANI microdiversity), StrainPhlAn (marker-SNV consensus phylogeny and nGD), MIDAS2, metaSNV, and StrainGE, plus genome-vs-genome ANI (skani\u002FfastANI\u002FMASH) for isolate\u002FMAG comparison. Covers why a strain is a threshold not a thing, why ANI answers same-genome while popANI\u002FnGD answer same-population-in-situ, the 99.999% popANI and per-species nGD definitions, the coverage detection limit (absence is not absence), why sharing is not transmission direction, and mapping to the dataset's own dRep MAGs. Use when detecting shared strains, tracking transmission, resolving within-host strain dynamics, or deconvoluting co-occurring strains. For pure-culture isolate outbreak SNP trees see epidemiological-genomics; for MAG assembly see genome-assembly\u002Fmetagenome-assembly.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-metagenomics-strain-tracking\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-metagenomics-strain-tracking\ndescription: Resolves and compares bacterial strains below the species level from shotgun metagenomes with inStrain (popANI\u002FconANI microdiversity), StrainPhlAn (marker-SNV consensus phylogeny and nGD), MIDAS2, metaSNV, and StrainGE, plus genome-vs-genome ANI (skani\u002FfastANI\u002FMASH) for isolate\u002FMAG comparison. Covers why a strain is a threshold not a thing, why ANI answers same-genome while popANI\u002FnGD answer same-population-in-situ, the 99.999% popANI and per-species nGD definitions, the coverage detection limit (absence is not absence), why sharing is not transmission direction, and mapping to the dataset's own dRep MAGs. Use when detecting shared strains, tracking transmission, resolving within-host strain dynamics, or deconvoluting co-occurring strains. For pure-culture isolate outbreak SNP trees see epidemiological-genomics; for MAG assembly see genome-assembly\u002Fmetagenome-assembly.\ntool_type: mixed\nprimary_tool: inStrain\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"metagenomics\u002Fstrain-tracking\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n## Version Compatibility\n\nReference examples tested with: inStrain 1.8+, StrainPhlAn\u002FMetaPhlAn 4.1+, dRep 3.4+, skani 0.2+, Bowtie2 2.5+, samtools 1.19+, pandas 2.2+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `inStrain profile -h`, `strainphlan -h`, `skani dist -h` to confirm flags and defaults\n- Python: `pip show \u003Cpackage>` then `help(module.function)` to check signatures\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\nThe mapping REFERENCE defines the answer. Map to genomes present in the sample set (dRep-dereplicated MAGs from this dataset), not generic database genomes - a distant reference inflates apparent SNVs and corrupts popANI. Record the reference set, the popANI\u002FnGD threshold, the minimum coverage and breadth, and the co-detection rate; the \"strain\" is defined by these, not by nature.\n\n# Strain Tracking\n\n**\"Is the same strain in samples A and B?\"** -> Compare per-position SNV populations (not consensus genomes) at adequate depth - because a strain is defined by the chosen threshold, and ANI cannot resolve the difference that matters.\n- CLI: `inStrain profile sample.bam reps.fasta -o sample.IS -s reps.stb -p 8` then `inStrain compare`\n\nScope: in-situ strain resolution, sharing, and deconvolution from a community. Pure-culture isolate outbreak SNP\u002FcgMLST trees -> epidemiological-genomics. MAG assembly\u002Fbinning -> genome-assembly\u002Fmetagenome-assembly. Species presence\u002Fabundance -> kraken-classification, metaphlan-profiling.\n\n## The Single Most Important Modern Insight -- A Strain Is a Threshold, Not a Thing\n\nThere is no universal definition of a metagenomic strain. A strain is an operational construct fixed by the reference mapped to, the genome fraction comparable at adequate depth, and the cutoff drawn. inStrain's popANI >= 99.999% over >= 50% of the genome IS the strain definition; Valles-Colomer's per-species nGD threshold IS the strain definition. Changing the cutoff changes how many strains exist. Two corollaries:\n\n1. **ANI answers \"same genome?\"; popANI\u002FnGD answer \"same population, in situ?\"** Genome-to-genome ANI (MASH\u002Fskani\u002FfastANI) saturates - two genuinely distinct, separately transmissible strains routinely share >99.9% ANI, and ANI's resolution floor sits above the difference that matters. Strain sharing cannot be done with an ANI number; it needs microdiversity-aware, position-level concordance.\n2. **Detecting a shared strain is a narrow statement:** across the genome fraction both samples covered at >= 5x, their SNV populations were >= 99.999% concordant. That is not proof an organism was transmitted between two people - the threshold certifies genomic identity within a coverage window, nothing more.\n\n## The Three Tasks (Do Not Conflate)\n\n| Task | Question | Tools |\n|------|----------|-------|\n| Identification | which known reference strain is present? | StrainGST, sourmash gather, MIDAS |\n| Tracking \u002F sharing | is the SAME strain in samples A and B? | inStrain compare, StrainPhlAn, MIDAS2, metaSNV, SameStr |\n| Deconvolution | how many strains coexist in ONE sample, what are their haplotypes? | DESMAN, Strainberry, strainFlye, Strainy |\n\nGenome-to-genome ANI (MASH\u002Fskani\u002FfastANI) is a fourth, orthogonal task - \"are these two assembled genomes the same?\" - isolate\u002FMAG comparison and dereplication, NOT in-situ strain resolution.\n\n## Tool Taxonomy\n\n| Tool | Citation | Mechanism \u002F role | When |\n|------|----------|------------------|------|\n| inStrain | Olm 2021 *Nat Biotechnol* 39:727 | popANI\u002FconANI microdiversity from reads mapped to MAGs | the reference standard for shared-strain detection |\n| StrainPhlAn | Truong 2017 *Genome Res* 27:626 | marker-SNV consensus -> phylogeny -> nGD | large cross-sample marker surveys, no assembly needed |\n| MIDAS2 | Zhao 2023 *Bioinformatics* 39:btac713 | UHGG pan-genome SNV + gene CNV | accessory-genome strain signal at scale |\n| StrainGE | van Dijk 2022 *Genome Biol* 23:74 | k-mer search + low-coverage variant calling | low-abundance strains down to 0.5x coverage |\n| metaSNV v2 | Van Rossum 2022 *Bioinformatics* 38:1162 | SNV distances + subspecies clustering | subspecies structure across samples |\n| skani | Shaw 2023 *Nat Methods* 20:1661 | sparse-chaining ANI | genome-vs-genome ANI; robust on fragmented MAGs (prefer over fastANI) |\n| Strainberry \u002F strainFlye | Vicedomini 2021 *Nat Commun* 12:4485; Fedarko 2022 *Genome Res* 32:2119 | long-read haplotype separation | deconvolute co-occurring strains (-> genome-assembly) |\n\n## Decision Tree by Scenario\n\n| Scenario | Recommended | Why |\n|----------|-------------|-----|\n| Is a strain shared between two metagenomes? | inStrain compare (popANI) | microdiversity-aware; the field standard |\n| Cross-sample transmission survey, many samples | StrainPhlAn (per-species nGD) | marker-based, scalable, no assembly |\n| Low-abundance pathogen (\u003C 1% \u002F \u003C 5x) | StrainGE | detects\u002Fcompares down to 0.5x |\n| Accessory-genome \u002F pan-genome strain signal | MIDAS2 | adds gene-content axis SNV tools miss |\n| Separate co-occurring strains into haplotypes | DESMAN (many samples) or long-read Strainberry\u002FstrainFlye | SNV tools do not partition a mixture |\n| Compare two assembled genomes \u002F dereplicate | skani (or fastANI) | genome-vs-genome ANI, not in-situ strains |\n| Pure-culture isolate outbreak tree | -> epidemiological-genomics | cgMLST\u002FSNP-distance on one genome per sample |\n\n## inStrain: popANI vs conANI\n\n**Goal:** Decide whether two metagenomes share a strain without being fooled by which allele happens to be the majority.\n\n**Approach:** dRep the dataset's MAGs into representative genomes, map reads to the concatenated references, profile each sample, then compare on popANI (microdiversity-aware) over the co-covered genome fraction.\n\n```bash\n# 1. dRep -> representative genomes (97-99% ANI); concatenate; build scaffold-to-bin (.stb).\n# 2. Map reads to the concatenated reps - your OWN MAGs, not database genomes.\nbowtie2 -x reps -1 r1.fq.gz -2 r2.fq.gz | samtools sort -o sampleA.bam\ninStrain profile sampleA.bam reps.fasta -o sampleA.IS -s reps.stb -g genes.fna -p 8\ninStrain profile sampleB.bam reps.fasta -o sampleB.IS -s reps.stb -g genes.fna -p 8\ninStrain compare -i sampleA.IS sampleB.IS -o compare.out -s reps.stb -p 8\n```\n\nconANI calls a difference whenever the consensus base differs - confounded by within-sample microdiversity (a minor-allele flip fakes a difference). popANI calls a difference only if the two samples share NO alleles at all, including minor ones, so popANI >= conANI always and is what detects shared strains consensus tools miss. Read genome-level calls from `genomeWide_compare.tsv` (breadth column `percent_compared`); the per-scaffold `comparisonsTable.tsv` uses `percent_genome_compared`.\n\n## StrainPhlAn: Marker SNVs and nGD\n\n```bash\nmetaphlan sample.fq.gz --input_type fastq -s sample.sam.bz2 --bowtie2out sample.bz2 -o profile.tsv  # need the SAM (-s)\nsample2markers.py -i sams\u002F*.sam.bz2 -o consensus_markers -n 8\nextract_markers.py -c t__SGB1877 -o clade_markers\u002F\nstrainphlan -s consensus_markers\u002F*.json -m clade_markers\u002Ft__SGB1877.fna \\\n    -r reference_genomes\u002F*.fna.bz2 -o output -c t__SGB1877 \\\n    --marker_in_n_samples_perc 80 --sample_with_n_markers 20 --nproc 8  # 4.0 named this --marker_in_n_samples\n```\n\nThe output tree gives a pairwise nGD (normalized genetic distance). There is no universal nGD strain cutoff - derive a per-species threshold from the data (same-individual-different-timepoint pairs fall below it, unrelated pairs above), as in Valles-Colomer 2023. Low coverage means too few markers pass the filters and the sample is dropped from the species tree silently - so a missing shared-strain call is not evidence of no shared strain.\n\n## Genome-vs-Genome ANI (Isolate\u002FMAG Comparison, NOT In-Situ Strains)\n\n```bash\nskani dist genomeA.fasta genomeB.fasta   # prefer skani over fastANI: robust on fragmented MAGs\n```\n\n~95% ANI is the species boundary (Jain 2018 *Nat Commun* 9:5114). ANI saturates above that and cannot resolve same-vs-different strain - use it to compare isolates\u002FMAGs and to dereplicate, never to call transmission.\n\n## Per-Method Failure Modes\n\n### ANI distance reported as strain resolution\n**Trigger:** \"MASH distance \u003C 0.001 = same strain\" or \"fastANI > 99% = same strain.\" **Mechanism:** ANI operates on consensus genomes, saturates above 99.9%, and ignores microdiversity. **Symptom:** distinct transmissible strains called identical; transmission inferred from an ANI number. **Fix:** use ANI for isolate\u002FMAG comparison; use inStrain popANI \u002F StrainPhlAn nGD for strain sharing.\n\n### Coverage detection limit (absence is not absence)\n**Trigger:** concluding \"no transmission\" or \"strain turnover.\" **Mechanism:** a shared strain can only be called for a species detected at adequate depth in BOTH samples (inStrain >= 5x and >= 50% breadth; StrainPhlAn enough markers). **Symptom:** a coverage dropout misread as biological absence; sharing rates biased to abundant taxa. **Fix:** report co-detection rates alongside sharing rates; use StrainGE for low-abundance targets.\n\n### Sharing read as transmission direction\n**Trigger:** narrating \"A infected B.\" **Mechanism:** a shared strain is an undirected edge. **Symptom:** directionality claimed from one cross-sectional comparison. **Fix:** direction comes from timepoints, contact metadata, or a known index case - the published landscapes infer it from study design, not the genomic comparison.\n\n### Wrong reference genome\n**Trigger:** mapping to a generic database genome. **Mechanism:** a distant reference inflates apparent SNVs. **Symptom:** corrupted popANI; spurious differences. **Fix:** map to dRep-dereplicated MAGs from the sample set.\n\n### Asking a SNV tool to deconvolute a mixture\n**Trigger:** \"what are the two strains here?\" from inStrain. **Mechanism:** SNV\u002Fmarker tools characterize population diversity; they do not partition it into haplotypes. **Symptom:** a category error. **Fix:** use DESMAN (many samples) or long-read Strainberry\u002FstrainFlye\u002FStrainy for haplotype separation.\n\n## Quantitative Thresholds\n\n| Threshold | Source | Rationale |\n|-----------|--------|-----------|\n| popANI >= 99.999% same strain | Olm 2021 *Nat Biotechnol* 39:727 | empirical shared-strain cutoff; IS the operational definition |\n| percent_compared >= 50% (genome-level breadth) | Olm 2021 *Nat Biotechnol* 39:727 | a genome below 50% breadth is not confidently present |\n| min_cov 5x | Olm 2021 *Nat Biotechnol* 39:727 | lowest coverage at which sub-50% minor alleles are reliable |\n| StrainGE detection ~0.5x | van Dijk 2022 *Genome Biol* 23:74 | tracks low-abundance strains below the inStrain floor |\n| Per-species nGD threshold (derive it) | Valles-Colomer 2023 *Nature* 614:125 | no universal cutoff; separate within-host timepoints from unrelated |\n| ~95% ANI species boundary | Jain 2018 *Nat Commun* 9:5114 | ANI saturates above this; cannot resolve strains |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Everything looks like one strain | ANI\u002FMASH used for strain calls | switch to inStrain popANI \u002F StrainPhlAn nGD |\n| Sample missing from the StrainPhlAn tree | too few markers passed filters at low coverage | report co-detection; do not read absence as no-sharing |\n| popANI implausibly low across the board | mapped to a distant database reference | map to dRep MAGs from the dataset |\n| inStrain compare gives no genomes | \u003C 50% breadth or \u003C 5x in one sample | deepen sequencing or use StrainGE for that taxon |\n| \"Who infected whom\" asked of one timepoint | sharing is undirected | need longitudinal\u002Fepi design for direction |\n\n## References\n\n- Olm MR, Crits-Christoph A, Bouma-Gregson K, et al. 2021. inStrain profiles population microdiversity from metagenomic data and sensitively detects shared microbial strains. *Nat Biotechnol* 39:727-736.\n- Truong DT, Tett A, Pasolli E, Huttenhower C, Segata N. 2017. Microbial strain-level population structure and genetic diversity from metagenomes. *Genome Res* 27:626-638.\n- Zhao C, Dimitrov B, Goldman M, Nayfach S, Pollard KS. 2023. MIDAS2: Metagenomic Intra-species Diversity Analysis System. *Bioinformatics* 39:btac713.\n- Van Rossum T, Costea PI, Paoli L, et al. 2022. metaSNV v2: detection of SNVs and subspecies in prokaryotic metagenomes. *Bioinformatics* 38:1162-1164.\n- van Dijk LR, Walker BJ, Straub TJ, et al. 2022. StrainGE: a toolkit to track and characterize low-abundance strains in complex microbial communities. *Genome Biol* 23:74.\n- Vicedomini R, Quince C, Darling AE, Chikhi R. 2021. Strainberry: automated strain separation in low-complexity metagenomes using long reads. *Nat Commun* 12:4485.\n- Valles-Colomer M, Blanco-Miguez A, Manghi P, et al. 2023. The person-to-person transmission landscape of the gut and oral microbiomes. *Nature* 614:125-135.\n- Shaw J, Yu YW. 2023. Fast and robust metagenomic sequence comparison through sparse chaining with skani. *Nat Methods* 20:1661-1665.\n- Jain C, Rodriguez-R LM, Phillippy AM, Konstantinidis KT, Aluru S. 2018. High throughput ANI analysis of 90K prokaryotic genomes reveals clear species boundaries. *Nat Commun* 9:5114.\n\n## Related Skills\n\n- metaphlan-profiling - StrainPhlAn builds on MetaPhlAn markers; profile species first\n- kraken-classification - Species presence before strain resolution\n- genome-assembly\u002Fmetagenome-assembly - dRep MAGs to map against; long-read deconvolution\n- epidemiological-genomics\u002Famr-surveillance - Isolate outbreak SNP\u002FcgMLST trees from pure cultures\n- workflows\u002Fmetagenomics-pipeline - End-to-end shotgun analysis\n","## Version Compatibility\n\nReference examples tested with: inStrain 1.8+, StrainPhlAn\u002FMetaPhlAn 4.1+, dRep 3.4+, skani 0.2+, Bowtie2 2.5+, samtools 1.19+, pandas 2.2+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `inStrain profile -h`, `strainphlan -h`, `skani dist -h` to confirm flags and defaults\n- Python: `pip show \u003Cpackage>` then `help(module.function)` to check signatures\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\nThe mapping REFERENCE defines the answer. Map to genomes present in the sample set (dRep-dereplicated MAGs from this dataset), not generic database genomes - a distant reference inflates apparent SNVs and corrupts popANI. Record the reference set, the popANI\u002FnGD threshold, the minimum coverage and breadth, and the co-detection rate; the \"strain\" is defined by these, not by nature.\n\n# Strain Tracking\n\n**\"Is the same strain in samples A and B?\"** -> Compare per-position SNV populations (not consensus genomes) at adequate depth - because a strain is defined by the chosen threshold, and ANI cannot resolve the difference that matters.\n- CLI: `inStrain profile sample.bam reps.fasta -o sample.IS -s reps.stb -p 8` then `inStrain compare`\n\nScope: in-situ strain resolution, sharing, and deconvolution from a community. Pure-culture isolate outbreak SNP\u002FcgMLST trees -> epidemiological-genomics. MAG assembly\u002Fbinning -> genome-assembly\u002Fmetagenome-assembly. Species presence\u002Fabundance -> kraken-classification, metaphlan-profiling.\n\n## The Single Most Important Modern Insight -- A Strain Is a Threshold, Not a Thing\n\nThere is no universal definition of a metagenomic strain. A strain is an operational construct fixed by the reference mapped to, the genome fraction comparable at adequate depth, and the cutoff drawn. inStrain's popANI >= 99.999% over >= 50% of the genome IS the strain definition; Valles-Colomer's per-species nGD threshold IS the strain definition. Changing the cutoff changes how many strains exist. Two corollaries:\n\n1. **ANI answers \"same genome?\"; popANI\u002FnGD answer \"same population, in situ?\"** Genome-to-genome ANI (MASH\u002Fskani\u002FfastANI) saturates - two genuinely distinct, separately transmissible strains routinely share >99.9% ANI, and ANI's resolution floor sits above the difference that matters. Strain sharing cannot be done with an ANI number; it needs microdiversity-aware, position-level concordance.\n2. **Detecting a shared strain is a narrow statement:** across the genome fraction both samples covered at >= 5x, their SNV populations were >= 99.999% concordant. That is not proof an organism was transmitted between two people - the threshold certifies genomic identity within a coverage window, nothing more.\n\n## The Three Tasks (Do Not Conflate)\n\n| Task | Question | Tools |\n|------|----------|-------|\n| Identification | which known reference strain is present? | StrainGST, sourmash gather, MIDAS |\n| Tracking \u002F sharing | is the SAME strain in samples A and B? | inStrain compare, StrainPhlAn, MIDAS2, metaSNV, SameStr |\n| Deconvolution | how many strains coexist in ONE sample, what are their haplotypes? | DESMAN, Strainberry, strainFlye, Strainy |\n\nGenome-to-genome ANI (MASH\u002Fskani\u002FfastANI) is a fourth, orthogonal task - \"are these two assembled genomes the same?\" - isolate\u002FMAG comparison and dereplication, NOT in-situ strain resolution.\n\n## Tool Taxonomy\n\n| Tool | Citation | Mechanism \u002F role | When |\n|------|----------|------------------|------|\n| inStrain | Olm 2021 *Nat Biotechnol* 39:727 | popANI\u002FconANI microdiversity from reads mapped to MAGs | the reference standard for shared-strain detection |\n| StrainPhlAn | Truong 2017 *Genome Res* 27:626 | marker-SNV consensus -> phylogeny -> nGD | large cross-sample marker surveys, no assembly needed |\n| MIDAS2 | Zhao 2023 *Bioinformatics* 39:btac713 | UHGG pan-genome SNV + gene CNV | accessory-genome strain signal at scale |\n| StrainGE | van Dijk 2022 *Genome Biol* 23:74 | k-mer search + low-coverage variant calling | low-abundance strains down to 0.5x coverage |\n| metaSNV v2 | Van Rossum 2022 *Bioinformatics* 38:1162 | SNV distances + subspecies clustering | subspecies structure across samples |\n| skani | Shaw 2023 *Nat Methods* 20:1661 | sparse-chaining ANI | genome-vs-genome ANI; robust on fragmented MAGs (prefer over fastANI) |\n| Strainberry \u002F strainFlye | Vicedomini 2021 *Nat Commun* 12:4485; Fedarko 2022 *Genome Res* 32:2119 | long-read haplotype separation | deconvolute co-occurring strains (-> genome-assembly) |\n\n## Decision Tree by Scenario\n\n| Scenario | Recommended | Why |\n|----------|-------------|-----|\n| Is a strain shared between two metagenomes? | inStrain compare (popANI) | microdiversity-aware; the field standard |\n| Cross-sample transmission survey, many samples | StrainPhlAn (per-species nGD) | marker-based, scalable, no assembly |\n| Low-abundance pathogen (\u003C 1% \u002F \u003C 5x) | StrainGE | detects\u002Fcompares down to 0.5x |\n| Accessory-genome \u002F pan-genome strain signal | MIDAS2 | adds gene-content axis SNV tools miss |\n| Separate co-occurring strains into haplotypes | DESMAN (many samples) or long-read Strainberry\u002FstrainFlye | SNV tools do not partition a mixture |\n| Compare two assembled genomes \u002F dereplicate | skani (or fastANI) | genome-vs-genome ANI, not in-situ strains |\n| Pure-culture isolate outbreak tree | -> epidemiological-genomics | cgMLST\u002FSNP-distance on one genome per sample |\n\n## inStrain: popANI vs conANI\n\n**Goal:** Decide whether two metagenomes share a strain without being fooled by which allele happens to be the majority.\n\n**Approach:** dRep the dataset's MAGs into representative genomes, map reads to the concatenated references, profile each sample, then compare on popANI (microdiversity-aware) over the co-covered genome fraction.\n\n```bash\n# 1. dRep -> representative genomes (97-99% ANI); concatenate; build scaffold-to-bin (.stb).\n# 2. Map reads to the concatenated reps - your OWN MAGs, not database genomes.\nbowtie2 -x reps -1 r1.fq.gz -2 r2.fq.gz | samtools sort -o sampleA.bam\ninStrain profile sampleA.bam reps.fasta -o sampleA.IS -s reps.stb -g genes.fna -p 8\ninStrain profile sampleB.bam reps.fasta -o sampleB.IS -s reps.stb -g genes.fna -p 8\ninStrain compare -i sampleA.IS sampleB.IS -o compare.out -s reps.stb -p 8\n```\n\nconANI calls a difference whenever the consensus base differs - confounded by within-sample microdiversity (a minor-allele flip fakes a difference). popANI calls a difference only if the two samples share NO alleles at all, including minor ones, so popANI >= conANI always and is what detects shared strains consensus tools miss. Read genome-level calls from `genomeWide_compare.tsv` (breadth column `percent_compared`); the per-scaffold `comparisonsTable.tsv` uses `percent_genome_compared`.\n\n## StrainPhlAn: Marker SNVs and nGD\n\n```bash\nmetaphlan sample.fq.gz --input_type fastq -s sample.sam.bz2 --bowtie2out sample.bz2 -o profile.tsv  # need the SAM (-s)\nsample2markers.py -i sams\u002F*.sam.bz2 -o consensus_markers -n 8\nextract_markers.py -c t__SGB1877 -o clade_markers\u002F\nstrainphlan -s consensus_markers\u002F*.json -m clade_markers\u002Ft__SGB1877.fna \\\n    -r reference_genomes\u002F*.fna.bz2 -o output -c t__SGB1877 \\\n    --marker_in_n_samples_perc 80 --sample_with_n_markers 20 --nproc 8  # 4.0 named this --marker_in_n_samples\n```\n\nThe output tree gives a pairwise nGD (normalized genetic distance). There is no universal nGD strain cutoff - derive a per-species threshold from the data (same-individual-different-timepoint pairs fall below it, unrelated pairs above), as in Valles-Colomer 2023. Low coverage means too few markers pass the filters and the sample is dropped from the species tree silently - so a missing shared-strain call is not evidence of no shared strain.\n\n## Genome-vs-Genome ANI (Isolate\u002FMAG Comparison, NOT In-Situ Strains)\n\n```bash\nskani dist genomeA.fasta genomeB.fasta   # prefer skani over fastANI: robust on fragmented MAGs\n```\n\n~95% ANI is the species boundary (Jain 2018 *Nat Commun* 9:5114). ANI saturates above that and cannot resolve same-vs-different strain - use it to compare isolates\u002FMAGs and to dereplicate, never to call transmission.\n\n## Per-Method Failure Modes\n\n### ANI distance reported as strain resolution\n**Trigger:** \"MASH distance \u003C 0.001 = same strain\" or \"fastANI > 99% = same strain.\" **Mechanism:** ANI operates on consensus genomes, saturates above 99.9%, and ignores microdiversity. **Symptom:** distinct transmissible strains called identical; transmission inferred from an ANI number. **Fix:** use ANI for isolate\u002FMAG comparison; use inStrain popANI \u002F StrainPhlAn nGD for strain sharing.\n\n### Coverage detection limit (absence is not absence)\n**Trigger:** concluding \"no transmission\" or \"strain turnover.\" **Mechanism:** a shared strain can only be called for a species detected at adequate depth in BOTH samples (inStrain >= 5x and >= 50% breadth; StrainPhlAn enough markers). **Symptom:** a coverage dropout misread as biological absence; sharing rates biased to abundant taxa. **Fix:** report co-detection rates alongside sharing rates; use StrainGE for low-abundance targets.\n\n### Sharing read as transmission direction\n**Trigger:** narrating \"A infected B.\" **Mechanism:** a shared strain is an undirected edge. **Symptom:** directionality claimed from one cross-sectional comparison. **Fix:** direction comes from timepoints, contact metadata, or a known index case - the published landscapes infer it from study design, not the genomic comparison.\n\n### Wrong reference genome\n**Trigger:** mapping to a generic database genome. **Mechanism:** a distant reference inflates apparent SNVs. **Symptom:** corrupted popANI; spurious differences. **Fix:** map to dRep-dereplicated MAGs from the sample set.\n\n### Asking a SNV tool to deconvolute a mixture\n**Trigger:** \"what are the two strains here?\" from inStrain. **Mechanism:** SNV\u002Fmarker tools characterize population diversity; they do not partition it into haplotypes. **Symptom:** a category error. **Fix:** use DESMAN (many samples) or long-read Strainberry\u002FstrainFlye\u002FStrainy for haplotype separation.\n\n## Quantitative Thresholds\n\n| Threshold | Source | Rationale |\n|-----------|--------|-----------|\n| popANI >= 99.999% same strain | Olm 2021 *Nat Biotechnol* 39:727 | empirical shared-strain cutoff; IS the operational definition |\n| percent_compared >= 50% (genome-level breadth) | Olm 2021 *Nat Biotechnol* 39:727 | a genome below 50% breadth is not confidently present |\n| min_cov 5x | Olm 2021 *Nat Biotechnol* 39:727 | lowest coverage at which sub-50% minor alleles are reliable |\n| StrainGE detection ~0.5x | van Dijk 2022 *Genome Biol* 23:74 | tracks low-abundance strains below the inStrain floor |\n| Per-species nGD threshold (derive it) | Valles-Colomer 2023 *Nature* 614:125 | no universal cutoff; separate within-host timepoints from unrelated |\n| ~95% ANI species boundary | Jain 2018 *Nat Commun* 9:5114 | ANI saturates above this; cannot resolve strains |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Everything looks like one strain | ANI\u002FMASH used for strain calls | switch to inStrain popANI \u002F StrainPhlAn nGD |\n| Sample missing from the StrainPhlAn tree | too few markers passed filters at low coverage | report co-detection; do not read absence as no-sharing |\n| popANI implausibly low across the board | mapped to a distant database reference | map to dRep MAGs from the dataset |\n| inStrain compare gives no genomes | \u003C 50% breadth or \u003C 5x in one sample | deepen sequencing or use StrainGE for that taxon |\n| \"Who infected whom\" asked of one timepoint | sharing is undirected | need longitudinal\u002Fepi design for direction |\n\n## References\n\n- Olm MR, Crits-Christoph A, Bouma-Gregson K, et al. 2021. inStrain profiles population microdiversity from metagenomic data and sensitively detects shared microbial strains. *Nat Biotechnol* 39:727-736.\n- Truong DT, Tett A, Pasolli E, Huttenhower C, Segata N. 2017. Microbial strain-level population structure and genetic diversity from metagenomes. *Genome Res* 27:626-638.\n- Zhao C, Dimitrov B, Goldman M, Nayfach S, Pollard KS. 2023. MIDAS2: Metagenomic Intra-species Diversity Analysis System. *Bioinformatics* 39:btac713.\n- Van Rossum T, Costea PI, Paoli L, et al. 2022. metaSNV v2: detection of SNVs and subspecies in prokaryotic metagenomes. *Bioinformatics* 38:1162-1164.\n- van Dijk LR, Walker BJ, Straub TJ, et al. 2022. StrainGE: a toolkit to track and characterize low-abundance strains in complex microbial communities. *Genome Biol* 23:74.\n- Vicedomini R, Quince C, Darling AE, Chikhi R. 2021. Strainberry: automated strain separation in low-complexity metagenomes using long reads. *Nat Commun* 12:4485.\n- Valles-Colomer M, Blanco-Miguez A, Manghi P, et al. 2023. The person-to-person transmission landscape of the gut and oral microbiomes. *Nature* 614:125-135.\n- Shaw J, Yu YW. 2023. Fast and robust metagenomic sequence comparison through sparse chaining with skani. *Nat Methods* 20:1661-1665.\n- Jain C, Rodriguez-R LM, Phillippy AM, Konstantinidis KT, Aluru S. 2018. High throughput ANI analysis of 90K prokaryotic genomes reveals clear species boundaries. *Nat Commun* 9:5114.\n\n## Related Skills\n\n- metaphlan-profiling - StrainPhlAn builds on MetaPhlAn markers; profile species first\n- kraken-classification - Species presence before strain resolution\n- genome-assembly\u002Fmetagenome-assembly - dRep MAGs to map against; long-read deconvolution\n- epidemiological-genomics\u002Famr-surveillance - Isolate outbreak SNP\u002FcgMLST trees from pure cultures\n- workflows\u002Fmetagenomics-pipeline - End-to-end shotgun analysis\n",{"name":5,"source":24,"license":15,"tool_type":25,"description":7,"imported_at":26,"source_path":27,"primary_tool":28,"source_repository":29},"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills","mixed","2026-09-20","metagenomics\u002Fstrain-tracking\u002FSKILL.md","inStrain","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fbiology\u002Fbio-metagenomics-strain-tracking","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-metagenomics-strain-tracking",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-metagenomics-strain-tracking",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-metagenomics-strain-tracking","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-metagenomics-strain-tracking\u002FSKILL.md",true,[50,56,60,64],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Finstrain_workflow.sh","SCRIPT","脚本",1914,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-metagenomics-strain-tracking\u002Fexamples\u002Finstrain_workflow.sh",{"path":57,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":58,"sourceHtmlUrl":59},"examples\u002Fmash_comparison.sh",1565,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-metagenomics-strain-tracking\u002Fexamples\u002Fmash_comparison.sh",{"path":61,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":62,"sourceHtmlUrl":63},"examples\u002Fparse_instrain_compare.py",2172,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-metagenomics-strain-tracking\u002Fexamples\u002Fparse_instrain_compare.py",{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"usage-guide.md","REFERENCE","参考文档",4581,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-metagenomics-strain-tracking\u002Fusage-guide.md",[71,79,86,93,100,107],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":78},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":78},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":78},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":78},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":78},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":78},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]