| name | scikit-bio |
| description | A Python bioinformatics toolkit for sequence, phylogeny, and microbiome/community-ecology analysis; use it when you need to compute diversity/ordination/statistics from biological data and standard formats (FASTA/FASTQ/Newick/BIOM). |
| license | MIT |
| author | AIPOCH |
Source: https://github.com/aipoch/medical-research-skills
When to Use
- You need to parse, validate, and manipulate biological sequences (DNA/RNA/protein) and their metadata.
- You are running microbiome/community-ecology workflows (alpha/beta diversity, UniFrac, ordination, PERMANOVA).
- You need to build, transform, or compare phylogenetic trees (Newick I/O, pruning/rerooting, patristic distances).
- You want to compute and work with distance matrices and downstream multivariate analyses (PCoA, Mantel, ANOSIM).
- You need to read/write common bioinformatics formats (FASTA/FASTQ, Newick, BIOM) and convert between them.
Key Features
- Sequence objects:
DNA, RNA, Protein, and generic Sequence with validation, slicing, motif search, reverse complement, transcription/translation, and metadata handling.
- Alignment utilities: pairwise local alignment (SSW-based) and multiple sequence alignment containers (
TabularMSA) with consensus support.
- Phylogenetics:
TreeNode manipulation, tree construction from distance matrices (e.g., Neighbor Joining), and tree distance/metrics.
- Diversity: alpha diversity (e.g., Shannon, Faith’s PD) and beta diversity (e.g., Bray-Curtis, UniFrac) returning
Series/DistanceMatrix.
- Ordination & stats: PCoA and ecological hypothesis tests (PERMANOVA, ANOSIM, Mantel) operating on distance matrices.
- I/O ecosystem: FASTA/FASTQ and Newick reading/writing; BIOM table support via
Table.
Dependencies
scikit-bio>=0.6.0
numpy>=1.23
pandas>=1.5
Example Usage
import numpy as np
import pandas as pd
import skbio
from skbio import DNA, TreeNode
from skbio.diversity import alpha_diversity, beta_diversity
from skbio.stats.ordination import pcoa
from skbio.stats.distance import permanova
seq = DNA("ACGTACGTNN--ACGT", metadata={"id": "seq1"})
seq_clean = seq.degap()
rc = seq_clean.reverse_complement()
motif_hits = seq_clean.find_with_regex("ACG[TA]")
print("Original:", str(seq))
print("Degapped:", str(seq_clean))
print("Reverse complement:", str(rc))
print("Motif hits:", list(motif_hits))
counts = np.array([
[10, 0, 3, 1],
[ 0, 8, 2, 0],
[ 5, 1, 0, ],
], dtype=)
sample_ids = [, , ]
feature_ids = [, , , ]
shannon = alpha_diversity(, counts, ids=sample_ids)
()
(shannon)
dm = beta_diversity(, counts, ids=sample_ids)
()
(dm)
ord_res = pcoa(dm)
()
(ord_res.samples[[, ]])
grouping = pd.Series([, , ], index=sample_ids)
perma = permanova(dm, grouping=grouping, permutations=)
()
(perma)
newick =
tree = TreeNode.read([newick])
subtree = tree.shear([, , ])
()
(subtree.ascii_art())
Implementation Details