agentsclimarketplace

Bio tcr bcr analysis mixcr analysis skills mixcr analysis

Skill bg-szy/TOP-SKILLS/skills/awesome-skills/bio-tcr-bcr-analysis-mixcr-analysis__skills-mixcr-analysis

Align V(D)J reads and assemble TCR/BCR clonotypes with MiXCR, driven by a chemistry-matched preset. Use when choosing/auditing the preset for a library (5'RACE/template-switch vs multiplex-primer amplicon -> rigid vs floating boundaries; RNA vs gDNA -> --rna/--dna; bulk vs 10x single-cell; UMI vs no-UMI -> tag pattern and barcode collapse; kit presets Takara/NEBNext/QIAseq/BD/MiLaboratory); assembling clonotypes by CDR3 vs VDJRegion; setting the reads-vs-UMI-vs-cell quantitation denominator; exporting native MiXCR fields vs AIRR rearrangement TSV for downstream Immcantation/scirpy/VDJtools; and running alignment/chain-usage QC. Keywords: MiXCR, analyze, align, refineTagsAndSort, assemblePartial, assemble, assembleCells, exportClones, exportAirr, exportQc, CDR3, V(D)J, clonotype, UMI, cell barcode, 10x VDJ, license.From its SKILL.md

Install
npx -y skills add bg-szy/TOP-SKILLS --skill bio-tcr-bcr-analysis-mixcr-analysis__skills-mixcr-analysis

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

16.0 KB, ~4.2k tokens by cl100k_base, as published. Nobody here has run it

Version Compatibility

Reference examples tested with: MiXCR 4.7+ (Java 17)

Before using code patterns, verify installed versions match. If versions differ:

  • CLI: mixcr --version (also prints the JVM) then mixcr <command> --help to confirm flags

If a command errors with an unknown-flag, unknown-preset, or missing-license message, run mixcr <command> --help and mixcr exportPreset --preset-name <name> and adapt rather than retrying.

Note: MiXCR 4.x is a rearchitecture of 3.x. The hand-built mixcr analyze amplicon/analyze shotgun pipelines are GONE, replaced by mixcr analyze <preset>; correctAndSortTags became refineTagsAndSort; AIRR export moved to a dedicated mixcr exportAirr. Current 4.x needs Java 17 and an activated license (see the licensing gate below). Any 3.x tutorial is stale.

MiXCR Analysis

"Extract TCR/BCR clonotypes from my sequencing data" -> align raw reads to V/D/J/C germline, collapse molecules/cells by barcode, and assemble reads into clonotypes keyed on CDR3 + V + J.

  • CLI: mixcr analyze <preset> runs the whole ordered pipeline; the underlying stages (align -> refineTagsAndSort -> assemblePartial/extend -> assemble -> assembleCells -> exportClones/exportAirr -> qc) can be run by hand for control.

The governing principle: the preset IS the analysis, and the wrong one fails silently

In MiXCR 4.x there is no default-correct pipeline. Correctness is ~90% preset choice plus library-chemistry match. mixcr analyze <preset> expands the preset into an ordered stage list encoding material (RNA vs DNA), 5'/3' alignment-boundary behavior (rigid vs floating), the barcode tag pattern, the assembling feature, and species defaults. The wrong preset does NOT raise an error -- it emits plausible-but-wrong clonotypes: a mismatched RNA/DNA model or boundary model mis-places V/J boundaries and truncates CDR3; a UMI kit run without a tag pattern skips barcode collapse and inflates diversity with PCR/sequencing artifacts. Because the failure is silent, the load-bearing skill is choosing and AUDITING the preset. Dump exactly what a preset does with mixcr exportPreset --preset-name <name> (full resolved parameter YAML), and confirm chemistry with mixcr exportQc align/chainUsage after the run. A clonotype is an analyst choice, not a fact: it is CDR3 (+ V + J) at a chosen boundary (assembling feature), counted in a chosen denominator (reads vs UMIs vs cells) -- every downstream number depends on these.

Licensing gate (do this first, or every run fails)

MiXCR 4.x refuses to run any analysis command until a license is activated -- the single most common reason a copied 3.x recipe fails today. Academic/non-profit use is free (obtain a key at platforma.bio/getlicense); for-profit use needs a business license. Activate by any one of:

  • mixcr activate-license then paste the key (interactive).
  • Place mi.license (or ~/.mi.license) in ~/, next to mixcr.jar, or next to the executable.
  • Set MI_LICENSE=<key content> or MI_LICENSE_FILE=/path/mi.license (best for HPC/Docker/CI).

MiXCR also validates the key over the internet periodically. On air-gapped or firewalled compute nodes, whitelist IPv4 75.2.96.100 and 99.83.215.63 (and the corresponding IPv6) or arrange an offline license, or a job silently stalls waiting on egress.

Preset selection by library type

The preset must match the exact wet-lab chemistry. Inspect the built-in list with mixcr exportPreset and the docs; verify current names against mixcr analyze --help since MiLaboratories occasionally renames presets between minor releases.

Library / chemistryPreset (verified 4.7)Material5' boundaryUMI/barcodeBiology consequence if mismatched
5'RACE / template-switch bulk (e.g. SMARTer)kit preset, or generic-amplicon/-with-umi with --rigid-left-alignment-boundary--rnaRIGID (5' set by template-switch oligo)kit UMI or --tag-patternFloating-left on RACE trims real 5' V sequence; missing tag pattern skips UMI collapse
Multiplex-primer amplicon (V/J or V/C primers)kit preset, or generic-amplicon with --floating-left-alignment-boundary--rna or --dnaFLOATING on the primer sideas designedRigid boundary counts primer bases as germline mismatch -> wrong V call, truncated CDR3
gDNA multiplex (genomic template)--dna variant preset--dna (include introns)floating on primer sideusually none--rna on gDNA drops intron-containing alignments; gDNA count approximates cell count
Bulk RNA-seq mining (non-targeted)rna-seq--rnan/a (fragmented)noneNeeds assemblePartial x2 + extend; judged by absolute yield, not % aligned
10x single-cell V(D)J (TCR+BCR)10x-sc-xcr-vdjpreset-setpreset-setCELL+UMI (preset)Missing cell/UMI pattern -> no pairing, fake diversity; count CELLS not reads
10x 5' GEX repertoire mining10x-sc-5gexpreset-setpreset-setCELL+UMIShallow repertoire mined from GEX; not a substitute for enriched VDJ
Takara SMARTer human TCR/BCRtakara-human-rna-tcr-umi-smarter-v2, takara-human-rna-bcr-umi-smarter, ...-smartseq--rnaRIGID (template-switch)12nt UMI (preset)Uses the correct RACE boundary + UMI pattern automatically
NEBNext immune-seqneb-human-rna-xcr-umi-nebnext (neb-mouse-...)--rnapreset-setUMI (preset)xcr = both TCR and BCR in one preset
QIAseq immuneqiagen-human-rna-tcr-umi-qiaseq (...-mouse-...)--rnapreset-setUMI (preset)--
BD Rhapsody single-cellbd-human-sc-xcr-rhapsody-cdr3, bd-sc-xcr-rhapsody-full-lengthpreset-setpreset-setCELL+UMIfull-length variant enables SHM/contig work
MiLaboratories kitsmilab-human-rna-tcr-umi-race, milab-human-rna-tcr-umi-multiplex, milab-human-dna-tcr-multiplex, ...per nameper nameper namename decodes <vendor>-<species>-<rna/dna>-<chain>-[umi]-<protocol>

For generic-* presets --species <hsa|mmu|...> is REQUIRED (forgetting it fails or misaligns). xcr presets cover TCR and BCR together; single-chain presets (trb, ig) cover one locus. For gamma-delta (TRG/TRD), use the same generic/kit presets and restrict chains at export with -c TRG / -c TRD (or a gd-specific kit preset if the wet-lab kit targets gd); note that a gd repertoire is invisible if the library only primed alpha-beta.

Pipeline stages and where each one fails

mixcr analyze <preset> R1.fastq.gz R2.fastq.gz out_prefix runs the ordered stages below; the preset is embedded in the binary .vdjca/.clns files so hand-run commands only name the preset on align.

StageCommandPurposeCommon failure
Alignmixcr align -p <preset> --species hsa ...Reads -> V/D/J/C germline; extract barcodes if tag pattern setLow alignment rate: wrong species/material/boundaries, untrimmed primers, reads too short to span CDR3
Refine tagsmixcr refineTagsAndSortUMI + cell-barcode error correction and sortSkipped on a UMI library -> barcode errors become fake clonotypes; memory-heavy (~32 GB on large single-cell)
Assemble partialmixcr assemblePartial (run x2)Overlap fragmented mates that each cover part of CDR3 (RNA-seq/10x)Needs align --keep-non-CDR3-alignments first; on amplicon reads that already span CDR3 it is wasted
Extendmixcr extendImpute unambiguous missing V/J germline endsSafe for TCR; on BCR can fabricate germline over SHM-mutated ends
Assemblemixcr assembleCollapse alignments into clonotypes by the assembling feature; PCR/error correction, UMI consensusWrong assembling feature merges/splits clones; low-quality CDR3 filtered
Assemble cellsmixcr assembleCellsSingle-cell: group per-chain clones by CELL barcode into paired cellsNeeds cell tags; barcode contamination -> mispaired cells
Exportmixcr exportClones / mixcr exportAirrWrite clonotype TSV (native or AIRR)Native field-name mistakes; forgetting -c/--chains; not filtering non-productive
QCmixcr qc, mixcr exportQc align/chainUsageAlignment rate, chain composition, tag coverageNot run -> silent quality problems pass downstream

From MiXCR 4.7, presets that do not intrinsically define an assembling feature REQUIRE --assemble-clonotypes-by <feature> (e.g. CDR3, VDJRegion); older tutorials that omit it now error. CDR3 is the robust default on short reads; VDJRegion needs reads/contigs spanning V-through-J and keeps SHM variants separate (useful for BCR full-length).

The quantitation denominator: reads vs UMIs vs cells

Clonotype abundance is only meaningful relative to the chemistry. Report the right unit or reintroduce the bias the chemistry was meant to remove:

  • Non-UMI bulk: abundance = readCount (cloneCount is an alias). PCR-amplification biased -- not a molecule count.
  • UMI bulk: after refineTagsAndSort, report uniqueMoleculeCount (generic form uniqueTagCount Molecule), NOT reads. Reporting reads on a UMI library re-adds the amplification bias the UMIs removed.
  • Single-cell: the unit is the CELL (uniqueTagCount Cell / cellGroup), not reads or UMIs.

Export: native MiXCR fields vs AIRR

MiXCR's native export headers are NOT AIRR or VDJtools names. Downstream renaming to a chosen schema is a user-side step; the field names to select from MiXCR are its own.

mixcr exportClones -c TRB \
    -cloneId -readCount -readFraction -uniqueMoleculeCount \
    -nSeqCDR3 -aaSeqCDR3 -bestVGene -bestJGene -allVHitsWithScore -isProductive VRegion \
    clones.clns clones_TRB.tsv

Key native fields: cloneId, readCount/readFraction (aliases cloneCount/cloneFraction), uniqueMoleculeCount, nSeqCDR3/aaSeqCDR3 (CDR3 nt/aa -- the headline fields), bestVGene/bestJGene/bestCGene (gene-level), bestVHit (allele-level best), allVHitsWithScore (full hit list), isProductive <feature>. Filter flags: -c/--chains TRB, -o (drop out-of-frame), -t (drop stops), --export-productive-clones-only.

For AIRR-schema interchange (Immcantation, scirpy, any AIRR tool) use the dedicated command, which emits sequence_id, v_call, d_call, j_call, junction, junction_aa, productive, duplicate_count, cell_id:

mixcr exportAirr clones.clns clones.airr.tsv

Field-name traps (do NOT use as MiXCR selectors): count/frequency/cdr3_aa/vGene are VDJtools/AIRR conventions, not MiXCR headers. A downstream tool expecting AIRR names should be fed exportAirr output, not renamed native output.

The D-gene caveat: never key or trust the D call in TRB/IGH

Dbeta and Dh segments are short (~12-16 nt) and heavily trimmed at both ends with N-additions between; the surviving germline-matchable D stretch is often 0-5 nt, statistically indistinguishable from random junctional nucleotides. A substantial fraction of TRB rearrangements have no detectable D at all (de Greef & de Boer 2021 PNAS 118:e2104367118), and any "longest germline D match" over-calls D by chance. Treat bestDGene/allDHitsWithScore as unreliable: never use the D call as a clonotype key, never stratify biology by D usage without heavy skepticism, and expect large tool-to-tool D disagreement. Clonotypes are keyed on CDR3 + V + J -- not D. This caveat is TRB- and IGH-specific: the TRD (delta) chain can incorporate one to two D segments in tandem, giving more germline D content than TRB's single heavily-trimmed D, so the D call is more informative for gamma-delta work (the junction is still highly diverse from N-additions).

QC: match preset to chemistry, catch cross-contamination

mixcr qc clones.clns
mixcr exportQc align results/*.clns qc_align.pdf
mixcr exportQc chainUsage results/*.clns qc_chainUsage.pdf

Read exportQc align: targeted amplicon should align high (often >80-90%); a low rate signals wrong species/library/boundaries or untrimmed primers, and "absent CDR3" means reads too short or wrong boundaries. RNA-seq mining legitimately aligns a tiny fraction (only receptor-overlapping reads) -- judge it by absolute clonotype yield, not %. Read chainUsage: a TRB library showing appreciable IGH signals cross-contamination or index hopping on patterned flowcells. A huge reads-to-clonotypes drop (millions -> thousands, worse after UMI collapse) is normal; a tiny clone count with high alignment suggests over-aggressive filtering or a wrong assembling feature.

Common Errors

SymptomCauseFix
Every processing command (align/analyze/assemble) refuses to runNo activated license (4.x mandatory for the pipeline; mixcr --version/exportPreset still work)mixcr activate-license or set MI_LICENSE_FILE; whitelist phone-home IPs on firewalled nodes
mixcr analyze amplicon ... unknown3.x command removed in 4.xUse mixcr analyze <preset>; pick a chemistry-matched preset
Runs cleanly but clonotypes look wrong (truncated CDR3, odd V calls)Wrong preset / boundary / material -- silent, no errorMatch preset to chemistry; audit with mixcr exportPreset; check exportQc align
Diversity far too high, many near-identical clonesUMI kit run without tag pattern -> no barcode collapseUse the UMI preset or add --tag-pattern; ensure refineTagsAndSort ran; report uniqueMoleculeCount
RNA-seq run yields almost no clonotypesNo assemblePartial/extend; partials filtered at alignalign --keep-non-CDR3-alignments, assemblePartial twice, then extend (or use rna-seq preset)
assemble errors asking for an assembling featurePreset lacks intrinsic feature (4.7+)Add --assemble-clonotypes-by CDR3 (or VDJRegion)
Downstream AIRR tool rejects the tableFed native MiXCR headers, not AIRRExport with mixcr exportAirr, not renamed exportClones
D-gene usage plot looks meaningless / irreproducibleTrusting the near-unassignable D call in TRB/IGHDrop D from keys and usage; report V/J only
--species missing on a generic presetGeneric presets require speciesAdd --species hsa (or mmu, taxon id)
refineTagsAndSort out-of-memory on single-cellBarcode-heavy step needs large heapmixcr -Xmx32g refineTagsAndSort ...

Related Skills

  • vdjtools-analysis - Downstream diversity and overlap on bulk clonotypes
  • immcantation-analysis - BCR clonal clustering, SHM and lineage from AIRR output
  • scirpy-analysis - Single-cell VDJ integration with gene expression
  • repertoire-visualization - Plot V/J usage and clonal structure
  • specificity-annotation - Antigen-specificity clustering and database lookup
  • read-qc/adapter-trimming - Upstream read QC and adapter handling
  • workflows/tcr-pipeline - End-to-end orchestration

References

  • Bolotin DA, et al. MiXCR: software for comprehensive adaptive immunity profiling. Nat Methods 12:380-381 (2015).
  • Bolotin DA, et al. Antigen receptor repertoire profiling from RNA-seq data. Nat Biotechnol 35:908-911 (2017).
  • de Greef PC, de Boer RJ. TCRbeta rearrangements without a D segment are common, abundant, and public. PNAS 118:e2104367118 (2021).
  • Vander Heiden JA, et al. AIRR Community standardized representations for annotated immune repertoires. Front Immunol 9:2206 (2018).
  • MiXCR documentation. https://mixcr.com/mixcr/ (presets, mixins, exportClones/exportAirr, licensing, QC).

What ships with it: 1 file

4.8 KB alongside SKILL.md

Keep looking

Skills are one crate of 326,834. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.