SKILL.md
Version Compatibility
Reference examples tested with: MiXCR 4.6+, ggplot2 3.5+
Before using code patterns, verify installed versions match. If versions differ:
- R:
packageVersion('<pkg>')then?function_nameto verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Immcantation Analysis
"Analyze B cell repertoire evolution and clonal lineages" → Study somatic hypermutation, build B cell phylogenies, and track affinity maturation using the Immcantation framework for BCR repertoire analysis.
- R:
alakazam::plotMutability(),dowser::buildPhylipLineage(),scoper::spectralClones()
Requires Immcantation suite: alakazam 1.3+, shazam 1.2+, scoper 1.3+, dowser 2.0+, tigger 1.1+.
Load and Format Data
Goal: Import AIRR-formatted repertoire data into the Immcantation framework for downstream analysis.
Approach: Read Change-O/AIRR tab-delimited files into R data frames with required V(D)J annotation columns.
library(alakazam)
library(shazam)
library(dplyr)
# Load AIRR-formatted data (from MiXCR, IMGT/HighV-QUEST, etc.)
db <- readChangeoDb('clones_airr.tsv')
# Required columns:
# sequence_id, sequence, v_call, d_call, j_call, junction, junction_aa
Clonal Clustering
Goal: Group B cell sequences into clonal lineages based on junction sequence similarity.
Approach: Apply hierarchical clustering on nucleotide distance of junction regions with a threshold-based cutoff.
library(scoper)
# Assign clones based on junction similarity
# Threshold typically 0.15-0.2 (15-20% nucleotide distance)
db <- hierarchicalClones(
db,
threshold = 0.15,
method = 'nt',
linkage = 'single'
)
# Count clones
clone_sizes <- countClones(db, groups = 'sample_id')
