scikit-bio – Data & Science skill for AI agents
Biological data toolkit. Sequence analysis, alignments, phylogenetic trees, diversity metrics (alpha/beta, UniFrac), ordination (PCoA), PERMANOVA, FASTA/Newick I/O, for microbiome analysis.
Install the scikit-bio skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/scikit-bio-3cfe0.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /scikit-bio – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/scikit-bio-3cfe0.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $scikit-bio – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/scikit-bio-3cfe0.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /scikit-bio – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/scikit-bio-3cfe0.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /scikit-bio – then describe the task you want done.
SKILL.md content
scikit-bio
Overview
Targets scikit-bio 0.7.4. Use it for sequence manipulation, alignment, phylogenetics, microbial ecology, and multivariate statistics. Native tests exercise small synthetic fixtures; examples with filenames or undefined inputs are workflow templates. See [review evidence and boundaries](references/review.md).
When to Use This Skill
This skill should be used when the user:
- Works with biological sequences (DNA, RNA, protein)
- Needs to read/write biological file formats (FASTA, FASTQ, GenBank, Newick, BIOM, etc.)
- Performs sequence alignments or searches for motifs
- Constructs or analyzes phylogenetic trees
- Calculates diversity metrics (alpha/beta diversity, UniFrac distances)
- Performs ordination analysis (PCoA, CCA, RDA)
- Runs statistical tests on biological/ecological data (PERMANOVA, ANOSIM, Mantel)
- Analyzes microbiome or community ecology data
- Works with protein embeddings from language models
- Needs to manipulate biological data tables
Core Capabilities
1. Sequence Manipulation
Work with biological sequences using specialized classes for DNA, RNA, and protein data.
Key operations:
- Read/write sequences from FASTA, FASTQ, GenBank, EMBL formats
- Sequence slicing, concatenation, and searching
- Reverse complement, transcription (DNA→RNA), and translation (RNA→protein)
- Find motifs and patterns using regex
- Calculate distances (Hamming, k-mer based)
- Handle sequence quality scores and metadata
Common patterns:
import skbio
# Read sequences from file
seq = skbio.DNA.read('input.fasta')
# Sequence operations
rc = seq.reverse_complement()
rna = seq.transcribe()
protein = rna.translate()
# Find motifs
motif_positions = seq.find_with_regex('(ATG[ACGT]{3})') # capture group required
# Check for properties
has_degens = seq.has_degenerates()
seq_no_gaps = seq.degap()Important notes:
- Use
DNA,RNA,Proteinclasses for grammared sequences with validation - Use
Sequenceclass for generic sequences without alphabet restrictions - FASTQ quality scores load into positional metadata; specify the known
phred_offset=33orvariant(do not infer encoding from the filename). Translation needs an explicit genetic code/frame and a decision about incomplete codons. - Metadata types: sequence-level (ID, description), positional (per-base), interval (regions/features)
2. Sequence Alignment
Perform pairwise and multiple sequence alignments using the pair_align engine (introduced in scikit-bio 0.7.0), a versatile and efficient dynamic-programming aligner.
Key capabilities:
- Global, local, and semi-global alignment (free ends configurable) in one function
- Convenience wrappers
pair_align_nucl(BLASTN-like) andpair_align_prot(BLASTP-like) - Configurable scoring: match/mismatch tuple or named substitution matrix; linear or affine gap penalties
PairAlignPathresults carry CIGAR strings and convert to aligned sequences- Multiple sequence alignment with
multi_align_nucl/multi_align_prot(0.7.4); storage and manipulation withTabularMSA
Common patterns:
from skbio import DNA, Protein
from skbio.alignment import pair_align_nucl, pair_align_prot, pair_align, TabularMSA
# Nucleotide alignment with BLASTN-like defaults
seq1, seq2 = DNA('ACTACCAGATTACTTACGGATCAGG'), DNA('CGAAACTACTAGATTACGGATCTTA')
aln = pair_align_nucl(seq1, seq2)
aln.score # alignment score (float)
path = aln.paths[0] # PairAlignPath (repr shows CIGAR)
aligned_seqs = path.to_aligned((seq1, seq2)) # list of gapped strings
# Build a TabularMSA from the alignment path + original sequences
msa = TabularMSA.from_path_seqs(path, (seq1, seq2))
# Customize the algorithm via pair_align (default mode='global')
aln = pair_align(seq1, seq2, mode='local') # Smith-Waterman
aln = pair_align(seq1, seq2, sub_score=(2, -3), gap_cost=(5, 2), free_ends=False)
aln = pair_align(seq1, seq2, sub_score='NUC.4.4', gap_cost=3) # substitution matrix, linear gap
# Protein alignment (BLASTP-like, BLOSUM62)
aln = pair_align_prot(Protein('HEAGAWGHEE'), Protein('PAWHEAE'))
# Read a multiple alignment from file and summarize
msa = TabularMSA.read('alignment.fasta', constructor=DNA)
consensus = msa.consensus()Important notes:
pair_alignreplaces the removed SSW wrapper (local_pairwise_align_ssw,StripedSmithWaterman) and the deprecated pure-Python aligners (global_pairwise_align,local_pairwise_align_nucleotide, etc.)- The result is a
PairAlignResultthat also unpacks asscore, paths, matrices(usekeep_matrices=Trueto retain the DP matrix) sub_scoreaccepts a(match, mismatch)tuple or a matrix name (e.g.,'NUC.4.4','BLOSUM62');gap_costaccepts a single number (linear) or(open, extend)tuple (affine)mode="global"defaults to free terminal gaps (overlap); usefree_ends=Falsefor fully penalized global alignment. Affine gap cost is open + length × extend. Wrapper scoring resembles BLAST, but is not a BLAST search or E-value.- Parse external CIGAR strings with
PairAlignPath.from_cigar('1I8M2D5M2I'); score an existing alignment withalign_score(...)and build a distance matrix from an MSA withalign_dists(...)
3. Phylogenetic Trees
Construct, manipulate, and analyze phylogenetic trees representing evolutionary relationships.
Key capabilities:
- Tree construction from distance matrices (UPGMA/WPGMA, Neighbor Joining, GME, BME)
- Tree rearrangement with nearest neighbor interchange (
nni) - Tree manipulation (pruning, rerooting, traversal)
- Distance calculations (patristic via
cophenet, Robinson-Foulds viacompare_rfd) - ASCII visualization
- Newick format I/O
Common patterns:
from skbio import TreeNode
from skbio.tree import nj, upgma, gme, bme, rf_dists
# Read tree from file
tree = TreeNode.read('tree.nwk')
# Construct tree from distance matrix
tree = nj(distance_matrix)
# Tree operations
subtree = tree.shear(['taxon1', 'taxon2', 'taxon3'])
tips = [node for node in tree.tips()]
lca = tree.lca(['taxon1', 'taxon2'])
# Calculate distances
patristic_dist = tree.find('taxon1').distance(tree.find('taxon2'))
cophenetic_dm = tree.cophenet() # patristic distance matrix among tips
# Compare two trees (Robinson-Foulds)
rf_distance = tree.compare_rfd(other_tree)
# Pairwise RF distances among many trees -> DistanceMatrix
rf_dm = rf_dists([tree, other_tree, third_tree])Important notes:
- Use
nj()for neighbor joining (classic phylogenetic method) - Use
upgma()for UPGMA/WPGMA (assumes molecular clock) - GME and BME are highly scalable for large trees; refine topology with
nni() cophenet()(formerlytip_tip_distances) returns the patristic distance matrix;compare_rfd()is the Robinson-Foulds method (compare_wrfd/compare_cophenetfor weighted/cophenetic variants)lca()is the lowest common ancestor;lowest_common_ancestorremains as an alias- NJ/GME/BME produce unrooted trees and clamp negative branches by default; record this choice. Rooting and sequence-distance models need scientific justification. RF comparisons must use a declared shared taxon set and rooting convention.
4. Diversity Analysis
Calculate alpha and beta diversity metrics for microbial ecology and community analysis.
Key capabilities:
- Alpha diversity: richness (
sobs,observed_features,chao1,ace), Shannon, Simpson, Hill numbers (hill), Faith's PD (faith_pd), generalized PD (phydiv), Pielou's evenness - Beta diversity: Bray-Curtis, Jaccard, weighted/unweighted UniFrac, Euclidean distances
- Phylogenetic diversity metrics (require tree input)
- Rarefaction and subsampling
- Integration with ordination and statistical tests
Common patterns:
from skbio.diversity import alpha_diversity, beta_diversity
# Alpha diversity (phylogenetic metrics take taxa= for tip-name mapping)
alpha = alpha_diversity('shannon', counts_matrix, ids=sample_ids)
faith_pd = alpha_diversity('faith_pd', counts_matrix, ids=sample_ids,
tree=tree, taxa=feature_ids)
# Beta diversity
bc_dm = beta_diversity('braycurtis', counts_matrix, ids=sample_ids)
unifrac_dm = beta_diversity('unweighted_unifrac', counts_matrix,
ids=sample_ids, tree=tree, taxa=feature_ids)
# Get available metrics
from skbio.diversity import get_alpha_diversity_metrics
print(get_alpha_diversity_metrics())Important notes:
- Keep finite, nonnegative raw counts for count-based estimators and rarefaction; never manufacture counts by scaling proportions. Shannon/Bray-Curtis can accept nonnegative abundances, but normalization changes the scientific question. Reject empty samples explicitly.
- The phylogenetic-metric argument is
taxa=(renamed fromotu_idsin 0.6.0; the old name is a deprecated alias);observed_otusis nowobserved_features(orsobs) - `counts_
… (full content is in the download package)
Related skills
- spark-environment-setup – Set up a working ML training/inference environment on NVIDIA DGX Spark (GB10, aarch64…
- scikit-learn – Supports machine learning in Python with scikit-learn. Applies when working with…
- deep-research – Run autonomous research tasks that plan, search, read, and synthesize information into…
- deep-research-framework – Framework for deep research reports: define the question and tier sources first…
- dependency-analysis – Analyze internal and package dependencies using Ontoly graph traversal. Use when asked…
- spark-optimization – Optimize Apache Spark jobs with partitioning, caching, shuffle optimization, and memory…
- scvelo – Performs RNA velocity analysis with scVelo from spliced and unspliced single-cell RNA…
- dependency-upgrade – Master major dependency version upgrades, compatibility analysis, staged upgrade…