Search in sources :

Example 1 with CaseToPoNTargetMapper

use of org.broadinstitute.hellbender.tools.pon.coverage.CaseToPoNTargetMapper in project gatk by broadinstitute.

the class PCATangentNormalizationUtils method mapTargetsToPoNAndFactorNormalize.

/**
     * Returns a target-factor-normalized {@link ReadCountCollection} given a {@link PCACoveragePoN}..
     */
private static ReadCountCollection mapTargetsToPoNAndFactorNormalize(final ReadCountCollection input, final PCACoveragePoN pon) {
    final CaseToPoNTargetMapper targetMapper = new CaseToPoNTargetMapper(input.targets(), pon.getTargetNames());
    final RealMatrix inputCounts = targetMapper.fromCaseToPoNCounts(input.counts());
    //factor normalize in-place
    factorNormalize(inputCounts, pon.getTargetFactors());
    return targetMapper.fromPoNtoCaseCountCollection(inputCounts, input.columnNames());
}
Also used : RealMatrix(org.apache.commons.math3.linear.RealMatrix) CaseToPoNTargetMapper(org.broadinstitute.hellbender.tools.pon.coverage.CaseToPoNTargetMapper)

Example 2 with CaseToPoNTargetMapper

use of org.broadinstitute.hellbender.tools.pon.coverage.CaseToPoNTargetMapper in project gatk-protected by broadinstitute.

the class PCATangentNormalizationUtils method tangentNormalize.

/**
     * Tangent normalize given the raw PoN data.  Non-Spark or Spark implementation automatically chosen.
     */
private static PCATangentNormalizationResult tangentNormalize(final ReadCountCollection targetFactorNormalizedCounts, final List<String> panelTargetNames, final RealMatrix reducedPanelCounts, final RealMatrix reducedPanelPInvCounts, final JavaSparkContext ctx) {
    final CaseToPoNTargetMapper targetMapper = new CaseToPoNTargetMapper(targetFactorNormalizedCounts.targets(), panelTargetNames);
    // The input counts with rows (targets) sorted so that they match the PoN's order.
    final RealMatrix tangentNormalizationRawInputCounts = targetMapper.fromCaseToPoNCounts(targetFactorNormalizedCounts.counts());
    // We prepare the counts for tangent normalization.
    final RealMatrix tangentNormalizationInputCounts = composeTangentNormalizationInputMatrix(tangentNormalizationRawInputCounts);
    if (ctx == null) {
        return tangentNormalizeNonSpark(targetFactorNormalizedCounts, reducedPanelCounts, reducedPanelPInvCounts, targetMapper, tangentNormalizationInputCounts);
    } else {
        return tangentNormalizeSpark(targetFactorNormalizedCounts, reducedPanelCounts, reducedPanelPInvCounts, targetMapper, tangentNormalizationInputCounts, ctx);
    }
}
Also used : RealMatrix(org.apache.commons.math3.linear.RealMatrix) CaseToPoNTargetMapper(org.broadinstitute.hellbender.tools.pon.coverage.CaseToPoNTargetMapper)

Example 3 with CaseToPoNTargetMapper

use of org.broadinstitute.hellbender.tools.pon.coverage.CaseToPoNTargetMapper in project gatk-protected by broadinstitute.

the class PCATangentNormalizationUtils method mapTargetsToPoNAndFactorNormalize.

/**
     * Returns a target-factor-normalized {@link ReadCountCollection} given a {@link PCACoveragePoN}..
     */
private static ReadCountCollection mapTargetsToPoNAndFactorNormalize(final ReadCountCollection input, final PCACoveragePoN pon) {
    final CaseToPoNTargetMapper targetMapper = new CaseToPoNTargetMapper(input.targets(), pon.getTargetNames());
    final RealMatrix inputCounts = targetMapper.fromCaseToPoNCounts(input.counts());
    //factor normalize in-place
    factorNormalize(inputCounts, pon.getTargetFactors());
    return targetMapper.fromPoNtoCaseCountCollection(inputCounts, input.columnNames());
}
Also used : RealMatrix(org.apache.commons.math3.linear.RealMatrix) CaseToPoNTargetMapper(org.broadinstitute.hellbender.tools.pon.coverage.CaseToPoNTargetMapper)

Example 4 with CaseToPoNTargetMapper

use of org.broadinstitute.hellbender.tools.pon.coverage.CaseToPoNTargetMapper in project gatk by broadinstitute.

the class PCATangentNormalizationUtils method tangentNormalize.

/**
     * Tangent normalize given the raw PoN data.  Non-Spark or Spark implementation automatically chosen.
     */
private static PCATangentNormalizationResult tangentNormalize(final ReadCountCollection targetFactorNormalizedCounts, final List<String> panelTargetNames, final RealMatrix reducedPanelCounts, final RealMatrix reducedPanelPInvCounts, final JavaSparkContext ctx) {
    final CaseToPoNTargetMapper targetMapper = new CaseToPoNTargetMapper(targetFactorNormalizedCounts.targets(), panelTargetNames);
    // The input counts with rows (targets) sorted so that they match the PoN's order.
    final RealMatrix tangentNormalizationRawInputCounts = targetMapper.fromCaseToPoNCounts(targetFactorNormalizedCounts.counts());
    // We prepare the counts for tangent normalization.
    final RealMatrix tangentNormalizationInputCounts = composeTangentNormalizationInputMatrix(tangentNormalizationRawInputCounts);
    if (ctx == null) {
        return tangentNormalizeNonSpark(targetFactorNormalizedCounts, reducedPanelCounts, reducedPanelPInvCounts, targetMapper, tangentNormalizationInputCounts);
    } else {
        return tangentNormalizeSpark(targetFactorNormalizedCounts, reducedPanelCounts, reducedPanelPInvCounts, targetMapper, tangentNormalizationInputCounts, ctx);
    }
}
Also used : RealMatrix(org.apache.commons.math3.linear.RealMatrix) CaseToPoNTargetMapper(org.broadinstitute.hellbender.tools.pon.coverage.CaseToPoNTargetMapper)

Aggregations

RealMatrix (org.apache.commons.math3.linear.RealMatrix)4 CaseToPoNTargetMapper (org.broadinstitute.hellbender.tools.pon.coverage.CaseToPoNTargetMapper)4