$npx -y skills add GPTomics/bioSkills --skill alignment-trimmingTrim multiple sequence alignments using ClipKIT, trimAl, BMGE, Divvier, or HMMcleaner with mode selection guidance per downstream goal. Use when removing unreliable columns or contaminating residues before phylogenetic inference, HMM building, or selection analysis.
| 1 | ## Version Compatibility |
| 2 | |
| 3 | Reference examples tested with: ClipKIT 2.1+, trimAl 1.4+, BMGE 1.12+, Divvier 1.01+, HMMcleaner (current CPAN release of `Bio::MUST::Apps::HmmCleaner`), BioPython 1.83+ |
| 4 | |
| 5 | Before using code patterns, verify installed versions match. If versions differ: |
| 6 | - CLI: `clipkit --version`, `trimal --version`, `BMGE --help`, `Divvier --help` |
| 7 | - Python: `pip show <package>` then `help(module.function)` to check signatures |
| 8 | |
| 9 | If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying. |
| 10 | |
| 11 | # Alignment Trimming |
| 12 | |
| 13 | **"Remove unreliable columns from this MSA"** -> Filter or split columns based on gap fraction, conservation, entropy, or per-residue quality. |
| 14 | - CLI: `clipkit`, `trimal`, `BMGE`, `Divvier`, `HMMcleaner` |
| 15 | - Python: post-process via Bio.AlignIO with custom column masks |
| 16 | |
| 17 | **"Make this alignment publication-grade for phylogenetics"** -> Apply ClipKIT's `kpic-smart-gap` mode, or trimAl `-automated1`, then verify via tree-stability comparison before vs after trimming. |
| 18 | |
| 19 | Tool choice and aggressiveness matter more than trimming vs not-trimming. Pick a mode by dataset character (table below), and always run a sensitivity check by building trees on trimmed and untrimmed alignments. |
| 20 | |
| 21 | ### Pick a Trimming Mode by Dataset Character |
| 22 | |
| 23 | | Dataset character | Trimming effect | Recommended approach | |
| 24 | |-------------------|-----------------|----------------------| |
| 25 | | Deep-divergence orthologs (>500 Ma), saturated 3rd codons | Aggressive trimming HURTS (Tan-style result) | No trim or `kpic-smart-gap` only; report sensitivity to trimming choice | |
| 26 | | Mid-depth eukaryotic (animal phyla, fungal classes) | ClipKIT `kpic-smart-gap` HELPS | Steenwyk-style result | |
| 27 | | Shallow (within-genus) | All trimmers ~equivalent | Choose for downstream-tool compatibility | |
| 28 | | Concatenated supermatrix with very long alignments (>10 kb) | Trimming reduces phylogenetic noise | `kpic-smart-gap` or BMGE `-h 0.5` | |
| 29 | | Single short genes (<200 bp aligned) | Trimming amplifies stochastic error | Skip column trimming; use sequence-level outlier filtering | |
| 30 | |
| 31 | **The 20%/40% rule.** Tan et al 2015 (Syst Biol) and Steenwyk et al 2020 (PLOS Bio) appear to disagree but their conclusions are reconciled by trimming aggressiveness: light trimming (<20% of columns removed) has minimal impact on tree accuracy regardless of method; heavy trimming (>40%) removes phylogenetic signal alongside noise and degrades tree accuracy on most empirical datasets. Steenwyk's ClipKIT `kpic-smart-gap` improves trees because it stays in the light-trim regime; the older Gblocks defaults fail because they over-trim. **Operational rule:** if the trimmer removes >40% of columns, the mode is too aggressive for the dataset; switch to a less aggressive mode or skip trimming. |
| 32 | |
| 33 | Always run a sensitivity analysis: build the tree on trimmed AND untrimmed alignments. If topology and support are stable across trimming choices, the conclusion is robust; if unstable, report this and pick the result better supported by independent evidence (gene-tree concordance, biological priors). |
| 34 | |
| 35 | ## Goal-Driven Tool Selection |
| 36 | |
| 37 | | Downstream goal | First-line tool | Rationale | |
| 38 | |----------------|-----------------|-----------| |
| 39 | | Phylogenetic-tree input (concatenated genes) | ClipKIT `kpic-smart-gap` (Steenwyk et al 2020 PLOS Bio) | Retains parsimony-informative + constant sites; consistently produces better trees | |
| 40 | | Phylogenetic-tree input (single gene) | ClipKIT `smart-gap` | Default mode; dynamic threshold determination | |
| 41 | | HMM profile building (HMMER, HHsuite) | trimAl `-gappyout` (Capella-Gutierrez et al 2009 Bioinf) | Aggressive gap removal acceptable; profile quality benefits | |
| 42 | | Selection / dN/dS analysis (PAML, HyPhy) | TCS column masking or GUIDANCE2 (NOT aggressive trimming) | Removing columns causes false-positive selection signals (Fletcher & Yang 2010 MBE) | |
| 43 | | Deep prokaryotic phylogenomics | BMGE (Criscuolo & Gribaldo 2010 BMC Evol Biol) | Entropy-based with BLOSUM62 context; standard in GToTree pipeline | |
| 44 | | Cross-contaminated sequences | HMMcleaner (Di Franco et al 2019 BMC Evol Biol) | Per-residue cleaning; targets contamination not column quality | |
| 45 | | Preserve phylogenetic signal in indels | Divvier (Ali, Bogusz & Whelan 2019 MBE) | Splits ambiguous columns rather than removing them | |
| 46 | | Column-mapping retention for site analysis | trimAl `-colnumbering` | Outputs original-column indices for downstream cross-reference | |
| 47 | | Codon-aware trimming | MACSE `trimAlignment` (Ranwez et al 2018 MBE) | Preserves codon boundaries; pairs with MACSE codon MSA | |
| 48 | |
| 49 | ## C |