Skip to content

Commit

Permalink
Merge branch 'hotfix/v2.1.2' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
  • Loading branch information
dbolotin committed Apr 20, 2017
2 parents 86df8be + fff2916 commit 4fb3809
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 21 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

MiXCR 2.1.2 (20 Apr 2017)
========================

-- Fixed rear IllegalArgumentException in `extendAlignments` action
-- Fixed rear NPE in `align` action


MiXCR 2.1.1 ( 3 Mar 2017)
========================

Expand Down
4 changes: 1 addition & 3 deletions doc/assemble.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ can set ``maxBadPointsPercent`` to zero:
Separation of clones with same CDR3 (clonal sequence) but different V/J/C genes
-------------------------------------------------------------------------------

Since v1.8 MiXCR by default separates clones with equal clonal sequence and different V and J genes
and optionally can separate clones with different C genes (e.g. do distinguish clones with different
IG isotype).
Since v1.8 MiXCR can separates clones with equal clonal sequence and different V, J and C (e.g. do distinguish clones with different IG isotype) genes.

To make analysis more robust to sequencing errors there is an additional clustering step to shrink
artificial diversity generated by this separation mechanism.
Expand Down
12 changes: 6 additions & 6 deletions doc/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ For the full length cDNA-based immunoglobulin repertoire analysis we generally r

::
> mixcr align -p kaligner2 s hsa -r alignmentReport.txt -OreadsLayout=Collinear \
> mixcr align -p kaligner2 -s hsa -r alignmentReport.txt -OreadsLayout=Collinear \
-OvParameters.geneFeatureToAlign=VTranscript read_R1.fastq.gz read_R2.fastq.gz \
alignments.vdjca
Option ``-s`` allows to specify species (e.g. homo sapiens - ``hsa``, mus musculus - ``mmu``). Parameter ``OreadsLayout`` allow us to set paired-end reads orientation (``Collinear``, ``Opposite``, ``Unknown``). Note, that after MiGEC analysis paired-end read pairs are in ``Collinear`` orientation.
Option ``-s`` allows to specify species (e.g. homo sapiens - ``hsa``, mus musculus - ``mmu``). Parameter ``-OreadsLayout`` allow us to set paired-end reads orientation (``Collinear``, ``Opposite``, ``Unknown``). Note, that after MiGEC analysis paired-end read pairs are in ``Collinear`` orientation.

Instead of KAligner2, default MiXCR aligner can be used as well, but it may miss immunoglobulin subvariants that contain several nucleotide-lengths indels within the V gene segment.

Expand All @@ -187,13 +187,13 @@ For the full length cDNA-based immunoglobulin repertoire analysis we generally r
::
> mixcr assemble -p default_affine -r assembleReport.txt -OassemblingFeatures=VDJRegion \
OseparateByC=true -OqualityAggregationType=Average \
-OseparateByC=true -OqualityAggregationType=Average \
-OclusteringFilter.specificMutationProbability=1E-5 -OmaxBadPointsPercent=0 \
alignments.vdjca clones.clns

``default_affine`` parameter is specifically required for the data aligned using KAligner2 (use this option only if ``-p kaligner2`` was used on the alignemnt step)

``OseparateByC=true`` separates clones with different antibody isotype.
``-OseparateByC=true`` separates clones with different antibody isotype.

Set ``-OcloneClusteringParameters=null`` parameter to switch off the frequency-based correction of PCR errors.

Expand All @@ -205,9 +205,9 @@ For the full length cDNA-based immunoglobulin repertoire analysis we generally r

::

> mixcr exportClones c IGH -o -t clones.clns clones.txt
> mixcr exportClones -c IGH -o -t clones.clns clones.txt

where options ``-o`` and ``-t`` filter off the out-of-frame and stop codon containing clonotypes, respectively, and ``c`` indicates which chain will be extracted (e.g. ``IGH``, ``IGL``).
where options ``-o`` and ``-t`` filter off the out-of-frame and stop codon containing clonotypes, respectively, and ``-c`` indicates which chain will be extracted (e.g. ``IGH``, ``IGL``).


.. _ref-exampleRnaSeq:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<groupId>com.milaboratory</groupId>
<artifactId>mixcr</artifactId>
<version>2.1.2-SNAPSHOT</version>
<version>2.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MiXCR</name>

Expand Down
2 changes: 1 addition & 1 deletion repseqio
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,42 @@ public HitMappingRecord(VDJCGene gene, Alignment<NucleotideSequence>[] alignment
}
}

static boolean hasAlignments(AlignedTarget target, GeneType geneType) {
for (VDJCHit l : target.getAlignments().getHits(geneType))
if (l.getAlignment(target.getTargetId()) != null)
return true;
return false;
}

@SuppressWarnings("unchecked")
static List<HitMappingRecord> extractSortedHits(AlignedTarget targetLeft, AlignedTarget targetRight, GeneType geneType) {
// Fast calculation for targets from the same PE-read (or multi-read)
if (targetLeft.getAlignments() == targetRight.getAlignments()) {
VDJCHit[] hits = targetLeft.getAlignments().getHits(geneType);
List<HitMappingRecord> mRecords = new ArrayList<>(hits.length);
for (VDJCHit hit : hits)
mRecords.add(new HitMappingRecord(hit.getGene(), new Alignment[]{
hit.getAlignment(targetLeft.getTargetId()), hit.getAlignment(targetRight.getTargetId())}));

// Don't resort mRecords because "hits" were already sorted. Sorting may be different from
// Collections.sort(mRecords, ...), if initial Alignments object contain more than two targets,
// however soring in "hits" is considered here to be more accurate because it was supported by
// other parts of the multi-read object
return mRecords;
}

// Full recalculation for targets form two different Alignments objects
Map<VDJCGeneId, HitMappingRecord> map = extractHitsMapping(targetLeft, targetRight, geneType);
List<HitMappingRecord> mRecords = new ArrayList<>(map.values());
Collections.sort(mRecords, new Comparator<HitMappingRecord>() {
@Override
public int compare(HitMappingRecord o1, HitMappingRecord o2) {
return Integer.compare(sumScore(o2.alignments), sumScore(o1.alignments));
}
});
return mRecords;
}

@SuppressWarnings("unchecked")
static Map<VDJCGeneId, HitMappingRecord> extractHitsMapping(AlignedTarget targetLeft, AlignedTarget targetRight, GeneType geneType) {
Map<VDJCGeneId, HitMappingRecord> map = new HashMap<>();
Expand Down Expand Up @@ -237,18 +273,10 @@ public TargetMergingResult merge(long readId, AlignedTarget targetLeft, AlignedT
public TargetMergingResult merge(long readId, AlignedTarget targetLeft, AlignedTarget targetRight,
boolean trySequenceMerge) {
for (GeneType geneType : GeneType.VJC_REFERENCE) {

Map<VDJCGeneId, HitMappingRecord> map = extractHitsMapping(targetLeft, targetRight, geneType);
if (map.isEmpty())
if (!hasAlignments(targetLeft, geneType) || !hasAlignments(targetRight, geneType))
continue;
List<HitMappingRecord> als = new ArrayList<>(map.values());

Collections.sort(als, new Comparator<HitMappingRecord>() {
@Override
public int compare(HitMappingRecord o1, HitMappingRecord o2) {
return Integer.compare(sumScore(o2.alignments), sumScore(o1.alignments));
}
});
List<HitMappingRecord> als = extractSortedHits(targetLeft, targetRight, geneType);

Alignment<NucleotideSequence>[] topHits = als.get(0).alignments;

Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/milaboratory/mixcr/util/AlignmentExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ public VDJCAlignments process(VDJCAlignments input) {
< vAnchorPositionInRef)
break OUTER;

//checking one more time, whether extension is required
//this termination point will be triggered if aligned V hits do not agree on
//the position of vLeftExtensionRefPoint
if (vAnchorPositionInRef >= vHit.getAlignment(cdr3target).getSequence1Range().getFrom()) {
//dropping any previous extension intents
vExtension = null;
//breaking only current loop
break;
}

//extend V
int vLeftTargetId = -1;
int vLeftEndCoord = -1;
Expand Down Expand Up @@ -229,6 +239,16 @@ else if (!vExtension.equals(r))
>= jAnchorPositionInRef)
break OUTER;

//checking one more time, whether extension is required
//this termination point will be triggered if aligned J hits do not agree on
//the position of jRightExtensionRefPoint
if (jAnchorPositionInRef <= jHit.getAlignment(cdr3target).getSequence1Range().getTo()) {
//dropping any previous extension intents
jExtension = null;
//breaking only current loop
break;
}

//extend J
int jRightTargetId = -1;
int jRightEndCoord = Integer.MAX_VALUE;
Expand Down

0 comments on commit 4fb3809

Please sign in to comment.