Search in sources :

Example 1 with Chromosome

use of com.hartwig.hmftools.common.chromosome.Chromosome in project hmftools by hartwigmedical.

the class CobaltRatioFactory method merge.

@NotNull
public static Multimap<Chromosome, CobaltRatio> merge(@NotNull final Multimap<Chromosome, CobaltCount> counts, @NotNull final Multimap<String, ReadRatio> referenceGCRatio, @NotNull final Multimap<String, ReadRatio> tumorGCRatio, @NotNull final Multimap<String, ReadRatio> referenceGCDiploidRatio) {
    final Multimap<Chromosome, CobaltRatio> result = ArrayListMultimap.create();
    final GenomePositionSelector<ReadRatio> tumorGCRatioSelector = GenomePositionSelectorFactory.create(tumorGCRatio);
    final GenomePositionSelector<ReadRatio> referenceGCRatioSelector = GenomePositionSelectorFactory.create(referenceGCRatio);
    final GenomePositionSelector<ReadRatio> referenceGCDiploidRatioSelector = GenomePositionSelectorFactory.create(referenceGCDiploidRatio);
    for (Chromosome chromosome : counts.keySet()) {
        for (CobaltCount count : counts.get(chromosome)) {
            final CobaltRatio ratio = ImmutableCobaltRatio.builder().from(count).tumorGCRatio(tumorGCRatioSelector.select(count).map(ReadRatio::ratio).orElse(-1D)).referenceGCRatio(referenceGCRatioSelector.select(count).map(ReadRatio::ratio).orElse(-1D)).referenceGCDiploidRatio(referenceGCDiploidRatioSelector.select(count).map(ReadRatio::ratio).orElse(-1D)).build();
            result.put(chromosome, ratio);
        }
    }
    return result;
}
Also used : Chromosome(com.hartwig.hmftools.common.chromosome.Chromosome) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Chromosome

use of com.hartwig.hmftools.common.chromosome.Chromosome in project hmftools by hartwigmedical.

the class CobaltCountFactory method merge.

@NotNull
public static Multimap<Chromosome, CobaltCount> merge(@NotNull final Multimap<String, ReadCount> referenceCount, @NotNull final Multimap<String, ReadCount> tumorCount) {
    final Multimap<Chromosome, CobaltCount> result = ArrayListMultimap.create();
    final GenomePositionSelector<ReadCount> tumorCountSelector = GenomePositionSelectorFactory.create(tumorCount);
    for (String chromosomeName : referenceCount.keySet()) {
        if (HumanChromosome.contains(chromosomeName)) {
            Chromosome chromosome = HumanChromosome.fromString(chromosomeName);
            for (ReadCount referenceReadCount : referenceCount.get(chromosomeName)) {
                int tumorReadCount = tumorCountSelector.select(referenceReadCount).map(ReadCount::readCount).orElse(0);
                final CobaltCount position = create(referenceReadCount, tumorReadCount);
                result.put(chromosome, position);
            }
        } else {
            LOGGER.info("Excluding unsupported {} chromosome from read counts", chromosomeName);
        }
    }
    return result;
}
Also used : HumanChromosome(com.hartwig.hmftools.common.chromosome.HumanChromosome) Chromosome(com.hartwig.hmftools.common.chromosome.Chromosome) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with Chromosome

use of com.hartwig.hmftools.common.chromosome.Chromosome in project hmftools by hartwigmedical.

the class StructuralVariantImplied method svImpliedCopyNumber.

@NotNull
ListMultimap<String, CombinedRegion> svImpliedCopyNumber(final List<StructuralVariant> structuralVariants, @NotNull final ListMultimap<String, CombinedRegion> copyNumbers) {
    long previousMissingCopyNumbers = copyNumbers.size();
    long currentMissingCopyNumbers = missingCopyNumberCount(copyNumbers);
    while (currentMissingCopyNumbers < previousMissingCopyNumbers && currentMissingCopyNumbers > 0) {
        final GenomePositionSelector<StructuralVariantLegPloidy> selector = GenomePositionSelectorFactory.create(createPloidies(structuralVariants, copyNumbers));
        for (Chromosome chromosome : HumanChromosome.values()) {
            final String chromosomeName = chromosome.toString();
            final List<CombinedRegion> chromosomeCopyNumbers = copyNumbers.get(chromosomeName);
            boolean svInferred = false;
            for (final CombinedRegion copyNumber : chromosomeCopyNumbers) {
                if (implyCopyNumberFromSV(copyNumber)) {
                    final Optional<StructuralVariantLegPloidy> optionalStart = selector.select(GenomePositions.create(chromosomeName, copyNumber.start()));
                    final Optional<StructuralVariantLegPloidy> optionalEnd = selector.select(GenomePositions.create(chromosomeName, copyNumber.end() + 1));
                    if (optionalStart.isPresent() || optionalEnd.isPresent()) {
                        svInferred = true;
                        inferCopyNumberFromStructuralVariants(copyNumber, optionalStart, optionalEnd);
                    }
                }
            }
            // JOBA: Extend structural variant segments
            if (svInferred) {
                ExtendStructuralVariant.extendStructuralVariants(chromosomeCopyNumbers);
            }
        }
        previousMissingCopyNumbers = currentMissingCopyNumbers;
        currentMissingCopyNumbers = missingCopyNumberCount(copyNumbers);
    }
    return copyNumbers;
}
Also used : StructuralVariantLegPloidy(com.hartwig.hmftools.common.purple.copynumber.sv.StructuralVariantLegPloidy) Chromosome(com.hartwig.hmftools.common.chromosome.Chromosome) HumanChromosome(com.hartwig.hmftools.common.chromosome.HumanChromosome) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with Chromosome

use of com.hartwig.hmftools.common.chromosome.Chromosome in project hmftools by hartwigmedical.

the class FittedPurityFactory method fitPurity.

private void fitPurity(@NotNull final Collection<ObservedRegion> observedRegions) throws ExecutionException, InterruptedException {
    int totalBAFCount = 0;
    final List<ObservedRegion> filteredRegions = Lists.newArrayList();
    for (final ObservedRegion region : observedRegions) {
        final Chromosome chromosome = HumanChromosome.valueOf(region);
        if (region.bafCount() > 0 && positiveOrZero(region.observedTumorRatio()) && chromosome.isAutosome() && region.status() == GermlineStatus.DIPLOID && Doubles.lessOrEqual(region.observedTumorRatio(), MAX_TUMOR_RATIO_TO_FIT)) {
            totalBAFCount += region.bafCount();
            filteredRegions.add(region);
        }
    }
    List<Future<List<FittedPurity>>> futures = Lists.newArrayList();
    for (double purity = minPurity; lessOrEqual(purity, maxPurity); purity += purityIncrements) {
        futures.add(executorService.submit(callableFitPurity(purity, totalBAFCount, filteredRegions)));
    }
    for (Future<List<FittedPurity>> future : futures) {
        List<FittedPurity> fittedPurities = future.get();
        if (!fittedPurities.isEmpty()) {
            bestScoringPerPurity.add(fittedPurities.get(0));
        }
    }
    Collections.sort(bestScoringPerPurity);
}
Also used : Chromosome(com.hartwig.hmftools.common.chromosome.Chromosome) HumanChromosome(com.hartwig.hmftools.common.chromosome.HumanChromosome) Future(java.util.concurrent.Future) List(java.util.List) ObservedRegion(com.hartwig.hmftools.common.purple.region.ObservedRegion)

Example 5 with Chromosome

use of com.hartwig.hmftools.common.chromosome.Chromosome in project hmftools by hartwigmedical.

the class PurityAdjuster method purityAdjustedCopyNumber.

public double purityAdjustedCopyNumber(final String chromosomeName, final double ratio) {
    final Chromosome chromosome = HumanChromosome.fromString(chromosomeName);
    final double typicalRatio = chromosome.isHomologous(gender) ? 1 : 0.5;
    return purityAdjustedCopyNumber(ratio, typicalRatio);
}
Also used : HumanChromosome(com.hartwig.hmftools.common.chromosome.HumanChromosome) Chromosome(com.hartwig.hmftools.common.chromosome.Chromosome)

Aggregations

Chromosome (com.hartwig.hmftools.common.chromosome.Chromosome)5 HumanChromosome (com.hartwig.hmftools.common.chromosome.HumanChromosome)4 NotNull (org.jetbrains.annotations.NotNull)3 StructuralVariantLegPloidy (com.hartwig.hmftools.common.purple.copynumber.sv.StructuralVariantLegPloidy)1 ObservedRegion (com.hartwig.hmftools.common.purple.region.ObservedRegion)1 List (java.util.List)1 Future (java.util.concurrent.Future)1