tooluniverse-phylogenetics
Phylogenetic analysis — de novo multiple sequence alignment (Clustal Omega/MUSCLE/MAFFT via EBI_msa_align) and neighbour-joining/UPGMA tree building (EBI_build_phylogenetic_tree) from your own sequences, plus tree analysis, treeness, saturation (PhyKIT), parsimony-informative sites, alignment gap an
By mims-harvard · 352 installs
npx skills add mims-harvard/tooluniverse --skill tooluniverse-phylogenetics
Source repository · Upstream listing
Phylogenetics and Sequence Analysis
Four traps that produce a confidently wrong number
Each of these was observed producing a wrong answer while the correct guidance
was already present further down this file . Check them before you answer.
1. PhyKIT prints more than one column, and for saturation the two
conventions disagree — state which you used. phykit saturation prints
saturation <TAB saturation 1 . Its own help is explicit: "The first
value is the saturation value and the second column is the absolute value of
saturation minus 1." But several published analyses (and some reference
answers derived from them) report the second column as "the saturation
value". The two always sum to 1.0000, which is the tell that you may be
looking at the wrong one — on the fungal scogs set the medians are 0.39
(col 1) and 0.61 (col 2).
So: follow phykit and use column 1 unless the question or source defines
saturation the other way, and say in your answer which column you read. Do
not silently pick the one that looks closer to an expected number.
treeness over rcv has no such ambiguity: it gives
ratio <TAB treeness <TAB RCV and the ratio is first.
2. "Gap percentage" means the fraction of alignment COLUMNS containing at
least one gap , not the fraction of residues that are gaps. On the fungal
scogs set the residue definition maxes out at 0.556, so a " 70% gaps" filter
selects nothing and the question looks unanswerable; by columns, three
orthologs qualify (max 0.783).
3. treeness over rcv and rcv take the UNTRIMMED .faa.mafft , while
saturation takes the trimmed .clipkit . RCV measures variability across
columns, so trimming changes it: median 0.2683 untrimmed against 0.3050
trimmed, and among 70% gap genes the maximum is 0.2572 untrimmed against
0.4174 trimmed.
4. Never loop PhyKIT per file. phykit batch analysis is parallel and does
~250 trees in about 35 seconds; a shell loop takes ~9 minutes and runs out of
turns mid way, producing no answer at all. It also selects the right column
for every function, which removes trap 1 entirely.
RULE ZERO — Check for pre computed results FIRST
Before following any instruction below, scan the data folder for:
scogs fungi.zip / scogs animals.zip (BUSCO single copy ortholog phylogenetics) → these contain the pre computed alignments ( .faa.mafft.clipkit ) and trees ( .faa.mafft.clipkit.treefile ) from the original analysis. Use these directly with PhyKIT (see "BUSCO scogs questions" below). Re running BUSCO → MAFFT → IQ TREE from .busco.zip files takes 1–6 hours AND produces slightly different numbers due to seed/version drift.
executed.ipynb → read with tu run read executed notebook '{"data folder":"<path ","search":"<keyword "}' and cite its cell outputs as the authoritative answer
Pre computed result files (CSV/TSV with names like results , tree , phykit , saturation , treeness ) → read directly and report the requested value
Canonical analysis scripts ( analysis.R , run .py , find .R , .Rmd ) → execute as is and read the output
Only follow this skill's re analysis recipe below if none of the above exist. Re running from raw data produces different numbers than the published answer and is much slower (often 5–10× turn count).
BUSCO scogs questions (multi species phylogenomics)
data folders with scogs fungi.zip and/or scogs animals.zip ship
pre computed per ortholog alignments (and sometimes trees). The
question asks for a metric per group, or a Mann Whitney U / median /
ratio comparison between groups.
PRIMARY SCRIPT — both groups in one pass (use this FIRST)
When the question compares animals vs fungi (Mann Whitney U, ratio,
fold change, paired difference), the bundled paired comparison script
extracts both zips, computes the metric per ortholog for each group,
and emits ALL of: per group summary, two tailed Mann Whitney U +
p value (in both orderings since U is asymmetric), paired ortholog
median diff, paired ortholog median ratio, group median ratio, and
lowest non zero ratios — in one run, no aggregation step needed:
Output blocks (parse in Python or grep):
For long branch score and patristic distances (multi value per tree
metrics), pass per tree stat mean or per tree stat median to
choose the per tree summary BEFORE the cross tree MWU. The question
wording "comparing median long branch scores" means per tree
summary = median; "comparing mean long branch scores" means
per tree summary = mean. Run TWICE (once with each) if uncertain.
Single group script (when only one group is asked about)
phykit parsimony informative is NOT a valid CLI subcommand
PhyKIT's CLI exposes parsimony informative site count as
parsimony informative sites (alias pis ). Calling
phykit parsimony informative <file returns the help banner with
non zero exit and silently produces zero values. The bundled scripts
translate parsimony informative → parsimony informative sites
automatically. The output is <n pi \t<n total \t<percent — column
THREE is the percentage that questions usually ask for.
Group median ratio vs paired ratio (read this carefully)
When a question phrases tree length / RCV / DVMC comparisons as
"ratio of fungal to animal X across orthologs", there are TWO distinct
quantities:
1. GROUP MEDIAN RATIO = median(values fungi) / median(values animals) .
Use ALL orthologs in each group independently. This is what
group comparison published numbers usually report (n fungi can
differ from n animals, and "across" is a population statement, not
a paired one).
2. PAIRED RATIO median = for each ortholog present in BOTH groups,
compute value fungi / value animals , then take the median across
common orthologs. Smaller denominator (intersection only) and a
different number when the groups have different size.
Default to GROUP MEDIAN RATIO unless the question explicitly says
"matched ortholog", "paired ortholog", "per ortholog ratio", or "for
each ortholog". If the answer phrasing is ambiguous, BOTH numbers are
in the script's output — pick the one matching the question's
"across" / "paired" / "ratio of medians" phrasing.
Total amino acid count across single copy orthologs — single representative, not all species
When a BUSCO single copy ortholog dataset ( single copy busco sequences/ ) is
present and the question asks " how many total amino acids are present in all
single copy ortholog sequences", count one representative sequence per
ortholog , not the sum across all species/copies.
Each <ortholog id .faa in single copy busco sequences/ typically contains
multiple species' copies of that ortholog (one each). Summing every sequence
across every species double/triple/N fold counts each ortholog by the species
count and gives n species × correct answer .
Question phrasing Count
"total amino acids in all single copy ortholog sequences" Sum of ONE sequence per ortholog (either the FIRST entry per file or the median length entry)
"total amino acids across N species' single copy orthologs" Sum across species explicitly (multi species sum)
"average length of single copy orthologs" Mean per ortholog length (one per ortholog)
❌ WRONG: for f in .faa: sum(len(rec.seq) for rec in SeqIO.parse(f, 'fasta')) then sum across files (multi species sum)
✅ RIGHT: for f in .faa: first rec = next(SeqIO.parse(f, 'fasta')); total += len(first rec.seq) (one representative per ortholog)
If your answer is n species × GT (e.g. 32228 when GT looks like 13809 = 32228/2.33 ≈ 8 species × representative), you summed all species — re do with one representative.
Lowest non zero ratios
For metrics that can legitimately equal 0 for highly conserved or
very short alignments (parsimony informative %, RCV on near identical
seqs), "lowest" in a question typically means "lowest non zero". The
paired script emits LOWEST NONZERO RATIO for both orderings — use
that line when the raw min in a group is 0.
File layout fallback (alignment naming)
scogs zips ship in two shapes:
Full : <gene .faa , <gene .faa.mafft , <gene .faa.mafft.clipkit ,
<gene .faa.mafft.clipkit.treefile , plus iqtree/bionj/log/mldist.
Alignment only : just <gene .faa + <gene .faa.mafft . No
trees, no clipkit. Used for parsimony, RCV, gap percentage
questions. Use the .faa.mafft (NOT raw .faa ) — the published
metric was computed on the MAFFT aligned file.
Both bundled scripts auto detect the layout and use the best available
alignment per ortholog. Do NOT re run MAFFT or ClipKit yourself; the
shipped files are canonical.
Which alignment goes with which metric (this changes the answer)
The tree is always the ClipKit derived .faa.mafft.clipkit.treefile . The
alignment argument depends on the metric:
metric alignment to pass
treeness , dvmc , total tree length , long branch score tree only — no alignment
saturation .faa.mafft.clipkit (trimmed)
treeness over rcv / rcv .faa.mafft (untrimmed)
parsimony informative sites, gap percentage .faa.mafft (untrimmed)
RCV measures compositional variability across the alignment's columns , so
trimming changes it materially — and treeness over rcv divides by RCV, so the
trimmed alignment shifts the ratio for every gene. Verified on the fungal scogs
set (249 orthologs, canonical shipped files):
Plain treeness needs no alignment and is unaffected — it reproduces exactly
(median 0.0501 on the same 249 files), which is how the alignment choice was
isolated as the cause rather than the tree set or the tool.
phykit batch analysis takes the two independently, so pass them explicitly:
Gap percentage in these questions means the fraction of alignment
columns containing at least one gap , not the fraction of all residues that
are gaps. The two differ by an order of magnitude: with the residue definition
no fungal ortholog exceeds 70% gaps, so a " 70% gaps" filter silently selects
nothing.
Anti pattern: running phykit on the raw .busco.zip extracted
ortholog FASTAs and aligning/tree building yourself. The pre computed
files in scogs .zip are the canonical inputs.
PhyKIT, Biopython, and DendroPy for alignment/tree analysis, evolutionary metrics, and comparative genomics.
LOOK UP, DON'T GUESS
When uncertain about any scientific fact, SEARCH databases first.
When to Use
FASTA/PHYLIP/Nexus/Newick files; treeness, RCV, DVMC, evolutionary rate, parsimony sites, tree length, bootstrap; group comparisons (Mann Whitney U); tree construction (NJ/UPGMA/parsimony); Robinson Foulds distance.
De novo alignment / tree from your own sequences: to align raw sequences (not pre computed files), call EBI msa align (Clustal Omega / MUSCLE / MAFFT / Kalign / T Coffee via EMBL EBI), then pass its data.aligned fasta string as the aligned sequences argument of EBI build phylogenetic tree (note the arg name differs from the output key) for a neighbour joining or UPGMA tree (Newick). Feed that Newick / alignment straight into the PhyKIT metrics below.
Still NOT for : maximum likelihood trees (IQ TREE/RAxML) or Bayesian inference (MrBayes/BEAST) — EBI build phylogenetic tree only does distance based NJ/UPGMA. For publication ML/Bayesian phylogenies, run dedicated tooling; use the pre computed scogs trees when available.
Required Packages
Workflow Decision Tree
Quick Reference
Metric Input Description
Treeness Newick Internal / total branch length
RCV FASTA/PHYLIP Relative Composition Variability
Treeness/RCV Both Signal quality ratio
Tree Length Newick Sum of all branch lengths
Evolutionary Rate Newick Total length / num terminals
DVMC Newick Degree of Violation of Molecular Clock
Parsimony Sites FASTA/PHYLIP Sites wi