From sequencing-pipelines
Bulk TCR/BCR repertoire analysis using MiXCR for targeted amplicon sequencing on FGCZ infrastructure
How this skill is triggered — by the user, by Claude, or both
Slash command
/sequencing-pipelines:mixcr-analysisThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
MiXCR is a tool for analyzing T cell receptor (TCR) and B cell receptor (BCR) repertoires from bulk sequencing data. This skill covers the complete workflow from FASTQ files to interactive HTML reports with diversity metrics, V gene usage, and clonotype tables.
MiXCR is a tool for analyzing T cell receptor (TCR) and B cell receptor (BCR) repertoires from bulk sequencing data. This skill covers the complete workflow from FASTQ files to interactive HTML reports with diversity metrics, V gene usage, and clonotype tables.
Key capabilities:
| Data Type | Preset | Notes |
|---|---|---|
| Generic bulk amplicon | generic-amplicon | Default for demultiplexed FASTQs |
| QIAseq TCR with UMI | qiagen-human-rna-tcr-umi-qiaseq | Only if barcodes in R2 sequence |
| 10x VDJ | Use scRepertoire skill | Single-cell, not MiXCR |
| Takara SMARTer | takara-human-rna-bcr-umi-smartseq | Check kit version |
Important: If using a kit-specific preset and getting >90% barcode failures, switch to generic-amplicon. This happens when FASTQs are already demultiplexed (barcodes in header, not sequence).
mixcr analyze generic-amplicon \
--species hsa \
--threads 16 \
--force-overwrite \
--rna \
--assemble-clonotypes-by CDR3 \
--floating-left-alignment-boundary \
--floating-right-alignment-boundary J \
${R1_FASTQ} ${R2_FASTQ} \
${OUTPUT_PREFIX}
Parameter explanations:
--species hsa: Human (use mmu for mouse)--rna: Input is RNA-derived (affects alignment expectations)--assemble-clonotypes-by CDR3: Group by CDR3 only (standard for repertoire analysis)--floating-left-alignment-boundary: Flexible 5' alignment for variable primer positions--floating-right-alignment-boundary J: Flexible 3' alignment at J geneAfter processing, export chain-specific clonotype tables:
# Export TRB (beta chain - primary for αβ T cells)
mixcr exportClones \
--chains TRB \
-cloneId -count -fraction -sequence -quality \
-vGene -dGene -jGene -cGene \
-vHit -dHit -jHit -cHit \
-aaFeature CDR3 -nFeature CDR3 \
${SAMPLE}.clns ${SAMPLE}.TRB.tsv
# Export other chains as needed
# TRA (alpha), TRD (delta), TRG (gamma) for TCR
# IGH, IGK, IGL for BCR
Load clonotypes and analyze in R:
library(tidyverse)
library(ggplot2)
library(patchwork)
library(DT)
# Load clonotypes
files <- list.files("clonotypes/", pattern = "\\.TRB\\.tsv$", full.names = TRUE)
clonotypes <- map_dfr(files, ~read_tsv(.x) |> mutate(Sample = basename(.x)))
# Calculate diversity metrics
diversity <- clonotypes |>
group_by(Sample) |>
summarise(
n_clones = n(),
n_reads = sum(cloneCount),
shannon = -sum((cloneCount/sum(cloneCount)) * log(cloneCount/sum(cloneCount))),
clonality = 1 - (shannon / log(n_clones))
)
/srv/GT/analysis/pXXXXX/
├── mixcr_output/ # MiXCR binary outputs (.clns files)
├── clonotypes/ # Exported TSV files
├── logs/ # Processing logs
└── TCR_Analysis_Report.html
/srv/gstore/projects/pXXXXX/Analyses_Paul/
├── TCR_Analysis_Report.html # Final delivery
└── clonotypes/ # Clonotype tables
#!/bin/bash
#SBATCH --job-name=pXXXXX_mixcr
#SBATCH --output=/srv/GT/analysis/pXXXXX/logs/mixcr_%j.log
#SBATCH --error=/srv/GT/analysis/pXXXXX/logs/mixcr_%j.err
#SBATCH --time=12:00:00
#SBATCH --mem-per-cpu=8G
#SBATCH --cpus-per-task=16
#SBATCH --partition=employee
set -e
set -u
# Load environment with MiXCR
eval "$(/usr/local/ngseq/miniforge3/bin/conda shell.bash hook)"
conda activate ps_pgueguen # Or your environment with MiXCR
# Process samples...
# Copy report to gstore
g-req copynow /srv/GT/analysis/pXXXXX/TCR_Analysis_Report.html \
/srv/gstore/projects/pXXXXX/Analyses_Paul/
# Copy clonotype tables
g-req copynow /srv/GT/analysis/pXXXXX/clonotypes/ \
/srv/gstore/projects/pXXXXX/Analyses_Paul/
ggplot(diversity, aes(x = Group, y = clonality, fill = Group)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(width = 0.2, alpha = 0.7) +
labs(y = "Simpson Clonality", x = NULL) +
theme_minimal() +
theme(legend.position = "none")
v_usage <- clonotypes |>
group_by(Sample, allVHitsWithScore) |>
summarise(count = sum(cloneCount)) |>
mutate(proportion = count / sum(count))
ggplot(v_usage, aes(x = reorder(allVHitsWithScore, -proportion), y = proportion, fill = Group)) +
geom_bar(stat = "identity", position = "dodge") +
coord_flip() +
labs(x = "V Gene", y = "Proportion") +
theme_minimal()
# Top clones table
top_clones <- clonotypes |>
group_by(Sample) |>
slice_max(cloneCount, n = 10)
DT::datatable(top_clones,
filter = "top",
options = list(pageLength = 25, scrollX = TRUE)
)
--species hsa vs mmu)Switch from kit-specific preset to generic-amplicon. This happens when:
grep "Successfully aligned" *.align.report.txtIncrease --mem-per-cpu in SBATCH or reduce --threads
Skill Files:
External:
# 1. Set up directories
PROJECT="p35802"
ANALYSIS_DIR="/srv/GT/analysis/${PROJECT}"
mkdir -p ${ANALYSIS_DIR}/{mixcr_output,clonotypes,logs}
# 2. Process one sample
mixcr analyze generic-amplicon \
--species hsa --threads 16 --rna \
--assemble-clonotypes-by CDR3 \
--floating-left-alignment-boundary \
--floating-right-alignment-boundary J \
sample_R1.fastq.gz sample_R2.fastq.gz \
${ANALYSIS_DIR}/mixcr_output/sample
# 3. Export clonotypes
for chain in TRA TRB TRD TRG; do
mixcr exportClones --chains ${chain} \
-cloneId -count -fraction \
-vGene -jGene -aaFeature CDR3 \
${ANALYSIS_DIR}/mixcr_output/sample.clns \
${ANALYSIS_DIR}/clonotypes/sample.${chain}.tsv
done
# 4. Generate report (copy template, edit parameters, render)
cp ~/.claude/skills/mixcr-analysis/assets/tcr_analysis_template.Rmd \
${ANALYSIS_DIR}/TCR_Analysis_Report.Rmd
module load Dev/R/4.5.0
Rscript -e "rmarkdown::render('${ANALYSIS_DIR}/TCR_Analysis_Report.Rmd')"
# 5. Deliver to gstore
g-req copynow ${ANALYSIS_DIR}/TCR_Analysis_Report.html \
/srv/gstore/projects/${PROJECT}/Analyses_Paul/
npx claudepluginhub cpanse/skills --plugin sequencing-pipelinesProvides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Searches MemPalace before answering questions about past work, people, projects, or prior decisions. Returns verbatim stored content instead of guessing from model memory.