Repository navigation
Get HaplotypeCallerSpark strict mode running on an exome - #5475
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5475 +/- ##
============================================
+ Coverage 87.01% 87.08% +0.07%
- Complexity 31251 31533 +282
============================================
Files 1919 1930 +11
Lines 144355 145262 +907
Branches 15961 16095 +134
============================================
+ Hits 125607 126505 +898
+ Misses 12969 12903 -66
- Partials 5779 5854 +75
Continue to review full report at Codecov.
|
ef381af to
80c4629
Compare
FindAssemblyRegionsSpark can repartition them, rather than collect them to the driver. Also ensure repartition results in sorted intervals. Successfully ran on an exome (24 mins, vs 12 for fast mode)
80c4629 to
f011abc
Compare
|
@jamesemery I've rebased this and added some more javadoc so it's ready for review now. |
jamesemery
left a comment
There was a problem hiding this comment.
Mostly some questions but no real issue from me. Generally speaking it sounds like this works because you flipped the partitioning from collecting the very large number of intervals for the assembly regions to instead collecting the intervals for the reads rdd which is a much more controlled number. I think this raises the question again of whether we should reduce the num-partitions for reads to make that number smaller yet.
| * @param maxLocatableLength the maximum length of a {@link Locatable}, if any is larger than this size then an exception will be thrown | ||
| * @param <L> the {@link Locatable} type | ||
| * @param <SB> the {@link ShardBoundary} type | ||
| * @return an RDD of {@link Shard} of overlapping {@link Locatable} objects (including overlapping only padding) |
There was a problem hiding this comment.
In the interest of excessive nit-picking, the maxLocatableLenght and useShuffle doesn't seem to be in the java docs for any of these overrides...
There was a problem hiding this comment.
I couldn't see what was missing here. Both maxLocatableLength and useShuffle have @param descriptions in all the public methods.
|
|
||
| JavaRDD<ShardBoundary> paddedIntervals = intervals.map(ShardBoundary::paddedShardBoundary); | ||
| if (useShuffle) { | ||
| throw new UnsupportedOperationException(); |
There was a problem hiding this comment.
This exception should have a description
| int lastPartitionStartIndex = 0; | ||
| for (I interval : intervals) { | ||
| int[] partitionIndexes = overlapDetector.getOverlaps(interval).stream() | ||
| Broadcast<OverlapDetector<PartitionLocatable<SimpleInterval>>> overlapDetectorBroadcast = ctx.broadcast(overlapDetector); |
There was a problem hiding this comment.
Considering that we are now broadcasting this value on a per-partition basis perhaps it would be a good idea to reevaluate the default partition size we use for reads in the gatk, as that might cut down on some of the time spent in these sorts of operations.
| int maxLocatableLength, FlatMapFunction2<Iterator<L>, Iterator<I>, T> f) { | ||
|
|
||
| List<PartitionLocatable<SimpleInterval>> partitionReadExtents = computePartitionReadExtents(locatables, sequenceDictionary, maxLocatableLength); | ||
| List<SimpleInterval> firstLocatables = partitionReadExtents.stream().map(PartitionLocatable::getLocatable).collect(Collectors.toList()); |
There was a problem hiding this comment.
Why is this not broadcasted here? it looks like it is used inside of the RDD operations so it would effectively be passed in for every interval in intervals which doesn't sound desirable. (though I suspect it is smarter than that)
There was a problem hiding this comment.
Yes, it's probably better to broadcast here. I've updated the code to do this.
| } | ||
| Arrays.sort(partitionIndexes); | ||
| int startIndex = partitionIndexes[0]; | ||
| int endIndex = partitionIndexes[partitionIndexes.length - 1]; |
There was a problem hiding this comment.
Do we always expect it to hold that a partitioning of the reads will necessarily be in order based on the start? One could imagine pathological cases where a very tall pileup at a given start position (perhaps with some very long reads as part of it) would cause us to split the partition so there may be another partition that starts after the start of this partition but ends before the end of this partition.
There was a problem hiding this comment.
Unless this is by the start position... in which case we should better document that in computePartitionReadExetents()...
There was a problem hiding this comment.
Yes, it's by start position. Added a comment.
| .repartitionAndSortWithinPartitions(new PartitionLocatablePartitioner(locatables.getNumPartitions()), new PartitionLocatableComparator<I>(sequenceDictionary)) | ||
| .keys(); | ||
|
|
||
| indexedIntervalsRepartitioned.cache(); // cache since we need to do two calculations on the intervals |
There was a problem hiding this comment.
Are you sure that ends up being faster? When we were doing mark duplicates work we found that caching ended up costing significantly more than just doing the entire tools work twice (regardless of which cache we used). This is probably a reasonable use of it however...
There was a problem hiding this comment.
It was faster when I was doing some test runs on exome data.
|
|
||
| indexedIntervalsRepartitioned.cache(); // cache since we need to do two calculations on the intervals | ||
|
|
||
| Map<Integer, Integer> maxEndPartitionIndexesMap = indexedIntervalsRepartitioned.mapToPair((PairFunction<PartitionLocatable<I>, Integer, Integer>) partitionLocatable -> |
There was a problem hiding this comment.
I think this method generally should have some line comments in it to help readability
|
Thanks for the review @jamesemery. Reducing the number of partitions means that each task has to process more data, which has caused out of memory issues in the past. Might be worth revisiting though since the HaplotypeCaller now uses a lot less memory. |
jonn-smith
left a comment
There was a problem hiding this comment.
I had one question and a very minor comment.
Maybe revisiting the default partition size is a good idea... I wonder if anything will similarly need to be strengthened / improved for running on whole genome data...
| if (i >= 0) { | ||
| throw new IllegalStateException(); // TODO: no overlaps, yet start of interval matches a partition read extent start | ||
| } | ||
| int insertionPoint = -i - 1; |
There was a problem hiding this comment.
Since Collections.binarySearch returns (-<insertion point>)-1 do you really need to subtract one here again?
There was a problem hiding this comment.
I think this is correct. If the return value is i, then -i - 1 gives the insertion point, since
-i - 1 = -((-<insertion point>)-1) - 1
= <insertion point>
E.g. if i is -5 then the insertion point is 4. If it's -1 then the insertion point is 0.
There was a problem hiding this comment.
Ah. That makes sense. Just wanted to double-check.
|
|
||
| /** | ||
| * Compares {@link PartitionLocatable} objects using a {@link htsjdk.samtools.SAMSequenceDictionary} sequence ordering. | ||
| * @param <L> he interval type |
jonn-smith
left a comment
There was a problem hiding this comment.
This now looks good to merge to me.
|
Thanks @jonn-smith |
This is based on #5416