/scientific-agent-skills:scikit-biofrom scientific-agent-skills
Provides data structures and algorithms for bioinformatics and community ecology: sequences, alignments, phylogenetics, diversity analysis, ordination (PCoA), PERMANOVA, and distance matrices.
Ships in scientific-agent-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
scikit-bio provides the data structures and statistical methods needed for rigorous biological analysis. It excels in calculating alpha/beta diversity, performing ordination (PCoA), and handling complex phylogenetic trees.
Official docs: http://scikit-bio.org/
Tutorials: http://scikit-bio.org/docs/latest/
Search patterns: skbio.sequence, skbio.stats.distance, skbio.diversity, skbio.stats.ordination
Instead of using raw strings, scikit-bio uses typed objects (DNA, RNA, Protein). These objects know their alphabet, can handle quality scores (Phred), and support biological operations (transcription, translation).
Microbiome research often boils down to comparing samples. The DistanceMatrix object is central, allowing for easy indexing, sub-setting, and statistical testing (e.g., PERMANOVA).
Provides a standardized implementation of hundreds of diversity metrics used in ecology, ensuring reproducibility across studies.
pip install scikit-bio
import skbio
import numpy as np
import pandas as pd
from skbio import DNA, RNA, Protein, Sequence
from skbio.stats.distance import DistanceMatrix
from skbio.diversity import alpha, beta
from skbio.stats.ordination import pcoa
from skbio import DNA
# 1. Create a sequence with metadata
seq = DNA("ACC--GTT", metadata={'id': 'sample1', 'desc': 'gene A'})
# 2. Biological operations
rc = seq.reverse_complement()
degapped = seq.degap()
# 3. Validation
print(f"Is valid? {seq.is_valid()}") # Checks against DNA alphabet
.is_valid() when importing data from untrusted sources to catch non-IUPAC characters.pcoa() to visualize high-dimensional community data.skbio.tree.TreeNode for tree manipulations as it provides robust traversal methods.skbio.diversity.beta to access UniFrac or Bray-Curtis.from skbio import DNA
# ❌ BAD: Manual reverse complement with string logic
rc_str = seq_str[::-1].replace('A', 't').replace('T', 'a')... # Fragile
# ✅ GOOD: Built-in validated method
rc_seq = DNA(seq_str).reverse_complement()
# ❌ BAD: Using raw lists for community analysis
# data = [[1, 0, 5], [2, 1, 0]]
# dist = manual_bray_curtis(data)
# ✅ GOOD: Using DistanceMatrix
from skbio.stats.distance import DistanceMatrix
dm = DistanceMatrix(matrix_data, ids=['S1', 'S2', 'S3'])
# ❌ BAD: Stripping metadata to run scikit-learn
# vals = seq.values # Metadata lost!
# ✅ GOOD: Process within skbio or use standard IO
seq.write('output.fasta')
from skbio import DNA, Protein
# Sequence with quality scores
seq = DNA("ACGT", positional_metadata={'quality': [30, 35, 40, 20]})
# Slicing preserves metadata
sub = seq[1:3]
print(sub.positional_metadata) # {'quality': [35, 40]}
# K-mer frequencies
freqs = seq.kmer_frequencies(k=2)
# Translation (DNA -> Protein)
protein = DNA("ATGCGA").translate()
from skbio.diversity import alpha
counts = [10, 0, 5, 2, 20] # Species abundances
otus = ['OTU1', 'OTU2', 'OTU3', 'OTU4', 'OTU5']
shannon = alpha.shannon(counts)
simpson = alpha.simpson(counts)
observed_otus = alpha.observed_otus(counts)
print(f"Shannon Index: {shannon:.3f}")
from skbio.diversity import beta
import numpy as np
# Abundance table (samples x taxa)
data = np.array([[10, 20, 0],
[5, 15, 2],
[0, 1, 30]])
ids = ['Sample1', 'Sample2', 'Sample3']
# Bray-Curtis distance
bc_dm = beta.pw_distances(data, ids=ids, metric='braycurtis')
# Weighted UniFrac (Requires a tree)
# unifrac_dm = beta.weighted_unifrac(data, otu_ids, tree)
from skbio import TreeNode
from io import StringIO
# Load Newick tree
tree_str = "((A:0.1, B:0.2)C:0.3, D:0.4)E;"
tree = TreeNode.read(StringIO(tree_str))
# Traverse
for node in tree.tips():
print(f"Leaf: {node.name}, dist: {node.length}")
# Find Lowest Common Ancestor
lca = tree.find_lca(['A', 'B'])
print(f"LCA of A and B is {lca.name}")
# Rooting
tree.root_at('D')
from skbio.stats.ordination import pcoa
from skbio.stats.distance import DistanceMatrix
# Create DM
dm = DistanceMatrix([[0, 0.5, 0.8], [0.5, 0, 0.2], [0.8, 0.2, 0]],
ids=['A', 'B', 'C'])
# Perform PCoA
results = pcoa(dm)
# View proportion of variance explained
print(results.proportion_explained)
# Access coordinates for plotting
coords = results.samples
from skbio.stats.distance import permanova
# metadata linking IDs to groups
metadata = pd.DataFrame({
'BodySite': ['Gut', 'Gut', 'Skin', 'Skin']},
index=['S1', 'S2', 'S3', 'S4'])
# Assuming dm is a DistanceMatrix of S1..S4
# results = permanova(dm, metadata, column='BodySite', permutations=999)
# print(results['p-value'])
def plot_microbiome_pcoa(abundance_df, metadata_df, group_col):
"""Full workflow: Abundance -> Distance -> PCoA -> Table."""
from skbio.diversity import beta
from skbio.stats.ordination import pcoa
# 1. Calculate Bray-Curtis distance
dm = beta.pw_distances(abundance_df.values, ids=abundance_df.index, metric='braycurtis')
# 2. PCoA
pc = pcoa(dm)
# 3. Merge with metadata for plotting
plot_data = pc.samples[['PC1', 'PC2']].join(metadata_df)
return plot_data # Ready for Seaborn/Plotly
def filter_low_quality_sequences(sequences, min_avg_qual=30):
"""Filters DNA sequences based on Phred scores."""
valid_seqs = []
for s in sequences:
# Assuming quality is in positional_metadata
avg_q = np.mean(s.positional_metadata['quality'])
if avg_q >= min_avg_qual:
valid_seqs.append(s)
return valid_seqs
def get_tip_distances(tree):
"""Returns a distance matrix of all tips in a tree."""
dm = tree.tip_tip_distances()
return dm
When calculating diversity for many samples, pass the entire 2D array to beta.pw_distances instead of looping through pairs.
Use tree.preorder() or tree.postorder() instead of manual recursion for much better performance on large (10,000+ tip) trees.
PERMANOVA and PCoA will fail if your metadata index and DistanceMatrix IDs don't match.
# ✅ Solution: Ensure alignment
common_ids = set(dm.ids).intersection(metadata.index)
dm_sub = dm.filter(common_ids)
metadata_sub = metadata.loc[list(common_ids)]
UniFrac calculation can be memory-intensive. For massive datasets, consider using the skbio.diversity.beta.unweighted_unifrac optimized versions or external tools like Unifrac-Binaries.
Standard DNA objects don't allow arbitrary characters.
# ❌ Problem: DNA("ACGN") raises error if 'N' isn't handled
# ✅ Solution: scikit-bio DNA supports IUPAC (N, R, Y, etc.) by default.
# But if you have non-standard characters:
from skbio import Sequence
custom = Sequence("ACG-X") # Generic sequence permits anything
scikit-bio is the mathematical heart of modern microbiome and evolutionary research. By enforcing strict biological typing and providing validated ecological metrics, it ensures that your biological insights are grounded in statistical rigor.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub tondevrel/scientific-agent-skills --plugin scientific-agent-skills70 skills in this plugin
/aseAtomic Simulation Environment - a set of tools for setting up, manipulating, running, visualizing, and analyzing atomistic simulations. Acts as a universal interface between Python and numerous quantum chemical and molecular dynamics codes. Use for building atomic structures, geometry optimization, molecular dynamics simulations, transition state searches (NEB), file format conversion (CIF, XYZ, POSCAR, PDB), electronic property calculations (DOS, band structures), and automating simulation workflows with DFT/MD codes like VASP, GPAW, Quantum ESPRESSO, LAMMPS./astropyThe core library for Astronomy and Astrophysics in Python. Provides data structures for coordinates, time, units, FITS files, and cosmological models. Essential for observational data reduction and theoretical astrophysics. Use when working with astronomical coordinates (RA/Dec), physical units, FITS files, time scales, WCS, cosmology, or astronomical tables./biopythonComprehensive guide for Biopython - the premier Python library for computational biology and bioinformatics. Use for DNA/RNA/protein sequence analysis, file I/O (FASTA, FASTQ, GenBank, PDB), sequence alignment, BLAST searches, phylogenetic analysis, structure analysis, and NCBI database access./chempyA Python package useful for chemistry (mainly physical/analytical/inorganic chemistry). Features include balancing chemical reactions, chemical kinetics (ODE integration), chemical equilibria, ionic strength calculations, and unit handling. Use when working with chemical equations, reaction balancing, kinetic modeling, equilibrium calculations, speciation, pH calculations, ionic strength, activity coefficients, or chemical formula parsing./cobrapyConstraints-Based Reconstruction and Analysis for Python. Used for modeling large-scale metabolic networks in microorganisms./daskA flexible library for parallel computing in Python. It scales Python libraries like NumPy, pandas, and scikit-learn to multi-core systems or distributed clusters. Features lazy evaluation and task scheduling for data that exceeds RAM capacity. Use for out-of-core computing, parallel processing, distributed computing, large-scale data analysis, dask.array, dask.dataframe, dask.delayed, dask.bag, task scheduling, lazy evaluation, and scaling beyond memory limits.Other plugins' skills for the same job