domains / science / scikit-bio-bioinformatics / scikit-bio

scikit-bio

Skill card

combined

The copies overlap heavily on the high-level capabilities (sequences, alignment, trees, diversity, ordination, PERMANOVA), but they disagree on the concrete API to use. K-Dense-AI targets scikit-bio 0.7.4 and documents the new pair_align / pair_align_nucl / pair_align_prot API, explicitly noting that the SSW wrappers were removed. Vibe-Skills and OpenClaw-Medical-Skills still instruct the agent to use local_pairwise_align_ssw and StripedSmithWaterman, which are deprecated/removed in the newer version. aipoch/medical-research-skills targets an older version (>=0.6.0) and provides a different, more end-to-end example workflow. Crowning one copy would hide the version-specific API differences and the alternative workflow style.

Repositories

RepositoryPath
K-Dense-AI/scientific-agent-skillsskills/scikit-bio/SKILL.md
foryourhealth111-pixel/Vibe-Skillsbundled/skills/scikit-bio/SKILL.md
aipoch/medical-research-skillsscientific-skills/Data Analysis/scikit-bio/SKILL.md
FreedomIntelligence/OpenClaw-Medical-Skillsskills/scikit-bio/SKILL.md

Other copies

RoleRepositoryPath
peerK-Dense-AI/scientific-agent-skillsskills/scikit-bio/SKILL.md
peerforyourhealth111-pixel/Vibe-Skillsbundled/skills/scikit-bio/SKILL.md
peeraipoch/medical-research-skillsscientific-skills/Data Analysis/scikit-bio/SKILL.md
peerFreedomIntelligence/OpenClaw-Medical-Skillsskills/scikit-bio/SKILL.md

Combined skill

# scikit-bio

## Overview

Use scikit-bio for sequence manipulation, alignment, phylogenetics, microbial ecology, and multivariate statistics. Check the installed scikit-bio version before choosing alignment APIs: 0.7.0+ uses pair_align; older versions use the SSW wrappers.

## When to Use

- Working with biological sequences (DNA, RNA, protein)
- Reading/writing FASTA, FASTQ, GenBank, Newick, BIOM formats
- Performing sequence alignments or motif searches
- Constructing or analyzing phylogenetic trees
- Calculating alpha/beta diversity, UniFrac distances
- Running ordination (PCoA, CCA, RDA) and statistical tests (PERMANOVA, ANOSIM, Mantel)
- Analyzing microbiome or community ecology data

## 1. Sequence Manipulation

Use DNA, RNA, Protein classes for alphabet-aware validation; use Sequence for generic sequences.

```python
import skbio
seq = skbio.DNA.read('input.fasta')
rc = seq.reverse_complement()
rna = seq.transcribe()
protein = rna.translate()
```

- FASTQ quality scores load into positional metadata. Specify phred_offset=33 or variant explicitly; do not infer from filename.
- find_with_regex requires a capture group in the pattern (e.g., '(ATG[ACGT]{3})').
- Translation requires an explicit genetic code/frame and a decision about incomplete codons.

## 2. Sequence Alignment

### scikit-bio 0.7.0+ (recommended)

Use pair_align, pair_align_nucl, or pair_align_prot. The old SSW wrappers (local_pairwise_align_ssw, StripedSmithWaterman) are removed.

```python
from skbio.alignment import pair_align_nucl, pair_align_prot, pair_align, TabularMSA
aln = pair_align_nucl(seq1, seq2)
path = aln.paths[0]
aln_seqs = path.to_aligned((seq1, seq2))
msa = TabularMSA.from_path_seqs(path, (seq1, seq2))
```

- sub_score accepts a (match, mismatch) tuple or a matrix name ('NUC.4.4', 'BLOSUM62').
- gap_cost accepts a single number (linear) or (open, extend) tuple (affine).
- mode='global' defaults to free terminal gaps; use free_ends=False for fully penalized global alignment.

### scikit-bio < 0.7.0

Use local_pairwise_align_ssw for local alignments and StripedSmithWaterman for protein alignments.

```python
from skbio.alignment import local_pairwise_align_ssw, TabularMSA
alignment = local_pairwise_align_ssw(seq1, seq2)
msa = alignment.aligned_sequences
```

## 3. Phylogenetic Trees

```python
from skbio import TreeNode
from skbio.tree import nj, upgma
tree = TreeNode.read('tree.nwk')
tree = nj(distance_matrix)
subtree = tree.shear(['taxon1', 'taxon2'])
patristic = tree.find('taxon1').distance(tree.find('taxon2'))
rf = tree.robinson_foulds(other_tree)
```

- Use nj() for neighbor joining; upgma() assumes a molecular clock.
- GME and BME are scalable for large trees.

## 4. Diversity Analysis

```python
from skbio.diversity import alpha_diversity, beta_diversity
alpha = alpha_diversity('shannon', counts, ids=sample_ids)
faith_pd = alpha_diversity('faith_pd', counts, ids=sample_ids, tree=tree, otu_ids=feature_ids)
bc_dm = beta_diversity('braycurtis', counts, ids=sample_ids)
unifrac_dm = beta_diversity('unweighted_unifrac', counts, ids=sample_ids, tree=tree, otu_ids=feature_ids)
```

- Counts must be non-negative integers (abundances, not relative frequencies).
- Phylogenetic metrics require a tree and OTU/feature ID mapping.

## 5. Ordination and Statistics

```python
from skbio.stats.ordination import pcoa
from skbio.stats.distance import permanova
ord_res = pcoa(dm)
perma = permanova(dm, grouping=grouping, permutations=999)
```

- DistanceMatrix enforces symmetry and zero diagonal.
- Increase permutations (999+) for stable p-values in real analyses.

## Dependencies

- scikit-bio 0.7.4 (or >=0.6.0 for older API)
- NumPy 2.0+ (0.7.4) or >=1.23 (older)
- pandas >=1.5
- Optional: matplotlib/seaborn/plotly for plotting; biom-format for BIOM tables