Home

Awesome

Build Status

MiGMAP: mapper for full-length T- and B-cell repertoire sequencing

In a nutshell, this software is a smart wrapper for IgBlast V-(D)-J mapping tool designed to facilitate analysis immune receptor libraries profiled using high-throughput sequencing. This package includes additional experimental modules for contig assembly, error correction and immunoglobulin lineage tree construction.

The software is distributed as an executable JAR file and a data bundle.

NOTE Last IgBlastWrp version is available here (source and readme are available here), this is a completely re-written version of original software.

Motivation

IgBlast is an excellent of V-(D)-J mapping tool able to correctly map even severely hypermutated antibody variants. While being a gold standard, the following limitations of IgBlast v1.4.0 have driven MIGMAP development:

Features

Present wrapper adds the following capabilities to IgBlast:

Pre-requisites

Java v1.8 or higher is required to run MIGMAP. Users should then install IgBlast v1.4.0 binaries that are appropriate for their system and make sure that igblastn and makeblastdb are added to $PATH or the directory that contains binaries is specified using --blast-dir /path/to/bin/ argument during MiGMAP execution. IgBlast v1.4.0 binaries can also be downloaded from here.

Note that MIGMAP also works with IgBlast v1.6.1, although this was not tested extensively

A data folder named data/ containing binary databases required for IgBlast to work is provided in the release bundle. It can also explicitly specify its path with --blast-dir /path/to/bin/ for troubleshooting purposes.

Installation

See latest release section for MiGMAP package. For Windows you need to both install IgBlast and download the latest release. For MacOS and Linux, MIGMAP can be easily installed using Homebrew/Linuxbrew or bioconda (no need to download anything/manually install IgBlast):

brew tap mikessh/repseq
brew install migmap-macos # or migmap-linux

Another option is to intall MIGMAP using BIOCONDA, see corresponding recipe.

MiGMAP can be compiled from sources using Gradle with gradle build. Note that in order for tests to pass IgBlast binaries should be in $PATH variable, you may need to modify following part of build.gradle

test {
    environment "PATH", "$System.env.PATH:/usr/local/bin/:/usr/local/ncbi/igblast/bin/"
}

Execution

General

To see the full list of MiGMAP options run

java -jar migmap.jar -h ...

The memory limit can be extended by using -Xmx argument (-Xmx8G will be sufficient in most cases). In case installed using Homebrew the command to execute MIGMAP is simply migmap ....

The following command will process sample.fastq.gz file containing human Immunoglobulin Heavy Chain reads, assemble clonotypes and store them in out.txt:

java -jar migmap.jar -R IGH -S human sample.fastq.gz out.txt

MIGMAP accepts both FASTQ and FASTA input files, raw and GZIP-compressed. MiGMAP can be also run in per-read mode and allows piping results, e.g.:

java -jar migmap.jar --by-read -R IGH -S human sample.fastq.gz - | grep "IGHV1-8" > out.txt

Several receptor chains can be specified, e.g. -R IGH,IGK,IGL. It is always recommended to map to complete set of TCR or IG genes and filter contaminations (e.g. TRA<>TRB) later.

The list of possible options is the following:

OptionDefinition
--blast-dirPath to folder that contains igblastn and makeblastdb binaries, by default assume they are added to $PATH and execute them directly.
--data-dirPath to folder that contains the data bundle (internal_data/ and optional_file/ directories). By default it the package is provided with MIGMAP binaries, that is install_dir/data/.
--custom-databasePath to a custom segments database. By default will use built-in database. See segments.txt and Using your own references for details.
-nNumber of reads to analyze before stopping. Will analyze all reads by default
-pNumber of threads to use. By default will use all available threads.
--reportPath to the file that is going to store MIGMAP report (extraction and filtering efficiency for current input, etc). Will append report line if file exists.
-RREQUIRED Receptor gene and chain. Several chains can be specified, separated with commas. Allowed values are: IGH,IGL,IGK,TRA,TRB,TRG,TRD.
-SREQUIRED Species, allowed values: human,mouse,rat,rabbit,rhesus_monkey
--all-allelesWill use all alleles provided in the antigen receptor segment database. By default uses only major allele (*01 according to IMGT).
--use-kabatWill use KABAT nomenclature for FR/CDR region markup. Uses IMGT nomenclature by default.
--allow-incompleteReport clonotypes with partial CDR3 mapping (lacking J germline part, etc). By default those are no included into the output.
--allow-no-cdr3Report clonotypes with no CDR3 mapping. By default those are no included into the output.
--allow-noncodingReport clonotypes that have either stop codon or frameshift in their receptor sequence. By default those are no included into the output.
--allow-noncanonicalReport clonotypes that have non-canonical CDR3 (do not start with C or end with F/W residues). By default those are no included into the output.
-qQuality threshold, 2-40 defaults to 25. Filter out reads that have at least one error or N-nucleotide with a quality value below the corresponding threshold.
--detailsSpecifies the nucleotide and amino acid sequences for certain FR/CDR regions that will be added to the output. Allowed values: fr1X,cdr1X,fr2X,cdr2X,fr3X,cdr3X,fr4X,contigX where X stands for nt or aa. By default all those fileds are included
--by-readWill output mapping results for each read (see Output format below, excluding frequency and count fields) and read headers.
--unmappedSpecifies a file to store unmapped reads.

Additional routines

There are several built-in routines implementing common result processing and analysis tasks. Note that one should use -cp instead of -jar when executing the module and specify full package name, as shown below. When using -cp (classpath) for execution always make sure that the path to executable JAR file is set correctly, otherwise JVM will throw some uninformative error message.

Merging contigs

MergeContigs routine of MIGMAP merges clonotypes that are represented by embedded contigs. MIGMAP uses CDR3 nucleotide sequence, V and J segment names and mutation list to define a unique clonotype signature. Therefore in case of variable IG/TCR sequence coverage (can be a result of intrinsic library properties and/or read trimming) there is a chance of ambigous clonotypes: e.g. in case two reads coming from a clonotype with a mutation in FR1 region and one of the reads doesn't cover the FR1 two clonotypes will be reported by MIGMAP. To resolve these ambiguities run MergeContigs utility as follows:

java -cp migmap.jar com.antigenomics.migmap.MergeContigs out.txt out_merged.txt

This routine will generate a list of clonotypes represented by the set of longest completely overlapping contigs. Note: make sure that you haven't manually excluded contignt feature from output as in such case the routine will fail.

Error correction

PCR and sequencing errors, as well as hot-spot PCR errors in case of UMI correct data can generate a great deal of artificial (erroneous) clonotypes, especially in case of full-length IG sequence analysis. To filter erroneous sub-variants and append their read count to corresponding parent clonotypes, execute

java -cp migmap.jar com.antigenomics.migmap.Correct out.txt corrected.txt

There are three error correction options that can be set by user:

The algorithm can deal with errors in CDR3 region as well as correctly resolve networks of erroneous sub-variants.

Note that error correction only works for clonotype tables, not by-read output. This step should be ideally executed after MergeContigs routine.

Post-analysis

IMPORTANT It is highly recommended that you merge contigs and perform error correction prior to proceeding to post-analysis.

To summarize somatic hypermutations and generate clonotype trees run

java -cp migmap.jar com.antigenomics.migmap.Analyze -S species -R gene out.txt out

Species and receptor parameters are required and should be the same as the ones used in initial MIGMAP analysis. This module will generate several text files with out prefix:

For more details and an example analysis of hypermutating Raji cell repertoire go to post/ folder in this repository (or click here).

Using your own references

It is possible to use your own references with MiGMAP, given they are in the same format as internal reference file. Note that you do not need to set the reference points, just put -1 in corresponding column and run

java -cp migmap.jar com.antigenomics.migmap.AnnotateSegments -S mouse -R TRB my_segments.txt my_segments_with_refs.txt

Here you are required to set the receptor(s) (-R) and species (-S), run the command with -h to see the list of available options. Choose the closest receptor(s) and species, however don't worry as the Variable segment amino acid sequences are quite homologous between species and the markup should run fine in most cases. Next, run MiGMAP with --custom-database my_segments_with_refs.txt selecting same receptor(s) and species as before.

To convert references in IMGT format into MIGEC/MiGMAP reference format use imgtparser.

Output format

The output is provided in a tab-delimited format. Note that no header column is present in piped output. Mutations are grouped by their FW/CDR region in several columns, mutations in the same region are separated with commas. Mutation entries are stored as follows,

$type$position:$reference>$query

where $type is S for substitution, D for deletion or I for indel. Position field $position marks either the substituted base, the first deleted base or the first base after insertion. Mutation positions are provided in Variable segment coordinates with the first Variable segment germline nucleotide having position of 0 (in contrast to BLAST output which is 1-based). Reference and query bases are provided for substitution, deleted and inserted bases are provided for deletions and insertions (omitting >).

Amino-acid level mutations are provided as translations of codons adjacent to the mutated position. Thus, cumulative effect of mutations on the amino acid sequence is shown for mutation sets. The effect is however reported so that there is a one-to-one correspondence between nucleotide and amino acid mutation entries. For example, if S90:T>C and S91:C>A together lead to S30:S>H, the S30:S>H,S30:S>H is reported, not S30:S>P,S30:S>Y.

Output format for assembled clonotypes is the following:

ColumnDefinition
freqclonotype frequency in (0,1]
countnumber of reads
vVariable segment (top hit only)
dDiversity segment (top hit only)
jJoining segment (top hit only)
cdr3ntCDR3 nucleotide sequence
cdr3aaCDR3 amino acid sequence
mutations.nt.FR1Mutations in FR1 region, nucleotide level
mutations.nt.CDR1Mutations in CDR1 region, nucleotide level
mutations.nt.FR2Mutations in FR2 region, nucleotide level
mutations.nt.CDR2Mutations in CDR2 region, nucleotide level
mutations.nt.FR3Mutations in FR3 region, nucleotide level
mutations.nt.CDR3Mutations in V/D/J germline sequence in CDR3 region, nucleotide level
mutations.nt.FR4Mutations in FR4 region, nucleotide level
mutations.aa.FR1Mutations in FR1 region, amino-acid level
mutations.aa.CDR1Mutations in CDR1 region, amino-acid level
mutations.aa.FR2Mutations in FR2 region, amino-acid level
mutations.aa.CDR2Mutations in CDR2 region, amino-acid level
mutations.aa.FR3Mutations in FR3 region, amino-acid level
mutations.aa.CDR3Mutations in V/D/J germline sequence in CDR3 region, amino-acid level
mutations.aa.FR4Mutations in FR4 region, amino-acid level
cdr.insert.qualquality string N-nucleotides in CDR3 region
mutations.qualmutation quality string
v.end.in.cdr3V segment end (exclusive) in CDR3 region
d.start.in.cdr3D segment start in CDR3 region or -1 if D segment is not defined
d.end.in.cdr3D segment end (exclusive) in CDR3 region or -1 if D segment is not defined
j.start.in.cdr3J segment start in CDR3 region or -1 if J segment is not defined
v.delNumber of nucleotides deleted from V segment 3' end
d.del.5Number of nucleotides deleted from D segment 5' end or -1 if D segment is not defined
d.del.3Number of nucleotides deleted from D segment 3' end or -1 if D segment is not defined
j.delNumber of nucleotides deleted from J segment 5' end or -1 if J segment is not defined
pol.vPosition of last nucleotide of V segment's P segment or -1 if P segment was not found
pol.d.5Position of first nucleotide of D segment's 5' P segment or -1 if P segment was not found
pol.d.3Position of last nucleotide of D segment's 3' P segment or -1 if P segment was not found
pol.jPosition of first nucleotide of J segment's P segment or -1 if P segment was not found
has.cdr3true if CDR3 region is present (both V segment conserved residue is present)
in.frametrue if receptor has no frameshifts
no.stoptrue if receptor contains no stop codons
completetrue if CDR3 region is fully defined (both V and J conserved residues are present)
canonicaltrue if CDR3 region starts with C residue and ends with F/W residue

Note that all coordinates are 0-based.

In case the --details ... option is specified, corresponding columns will be added to output. E.g. --details cdr1nt,contigaa will add CDR1 nucleotide sequence and translated complete receptor sequence to the table. By default, all nucleotide and amino acid sequences for FR/CDR regions and entire contigs are added.