use of org.broadinstitute.hellbender.tools.exome.Target in project gatk by broadinstitute.
the class TargetCoverageSexGenotypeCalculator method getSampleReadDepthFromAutosomalTargets.
/**
* Estimates read depth per target per homolog for a given sample index in the collection.
*
* @param sampleIndex integer index of the sample in the read count collection
* @return read depth per target per homolog
*/
private double getSampleReadDepthFromAutosomalTargets(final int sampleIndex) {
final double[] readCounts = processedReadCounts.getColumnOnSpecifiedTargets(sampleIndex, autosomalTargetList, false);
final double[] readCountsNormalizedByPloidy = IntStream.range(0, readCounts.length).mapToDouble(i -> readCounts[i] / (double) autosomalTargetPloidies[i]).toArray();
return new Median().evaluate(readCountsNormalizedByPloidy);
}
use of org.broadinstitute.hellbender.tools.exome.Target in project gatk by broadinstitute.
the class TargetCoverageSexGenotypeCalculator method processReadCountsAndTargets.
/**
* Processes raw read counts and targets:
* <dl>
* <dt> If more than one sample is present in the collection, filters out fully uncovered targets
* from read counts and removes the uncovered targets from the target list</dt>
*
* <dt> Otherwise, does nothing and warns the user
* </dt>
* </dl>
*
* @param rawReadCounts raw read count collection
* @param targetList user provided target list
* @return pair of processed read counts and targets
*/
private ImmutablePair<ReadCountCollection, List<Target>> processReadCountsAndTargets(@Nonnull final ReadCountCollection rawReadCounts, @Nonnull final List<Target> targetList) {
final ReadCountCollection finalReadCounts;
final List<Target> finalTargetList;
/* remove totally uncovered targets */
if (rawReadCounts.columnNames().size() > 1) {
finalReadCounts = ReadCountCollectionUtils.removeTotallyUncoveredTargets(rawReadCounts, logger);
final Set<Target> targetSetFromProcessedReadCounts = new HashSet<>(finalReadCounts.targets());
finalTargetList = targetList.stream().filter(targetSetFromProcessedReadCounts::contains).collect(Collectors.toList());
} else {
final long numUncoveredTargets = rawReadCounts.records().stream().filter(rec -> (int) rec.getDouble(0) == 0).count();
final long numAllTargets = rawReadCounts.targets().size();
logger.info("Since only one sample is given for genotyping, the user is responsible for asserting" + " the aptitude of targets. Fully uncovered (irrelevant) targets can not be automatically" + " identified (total targets: " + numAllTargets + ", uncovered targets: " + numUncoveredTargets + ")");
finalReadCounts = rawReadCounts;
finalTargetList = targetList;
}
return ImmutablePair.of(finalReadCounts, finalTargetList);
}
use of org.broadinstitute.hellbender.tools.exome.Target in project gatk by broadinstitute.
the class GermlineCNVCallerIntegrationTest method runCaseSampleCallingTestOnLearnedModelParams.
private void runCaseSampleCallingTestOnLearnedModelParams(final String... extraArgs) {
runCommandLine(getCallingOnLearnedModelArgs(ArrayUtils.addAll(new String[] { "--" + GermlineCNVCaller.INPUT_MODEL_PATH_LONG_NAME, LEARNING_MODEL_OUTPUT_PATH.getAbsolutePath() }, extraArgs)));
final List<Target> callingTargets = TargetTableReader.readTargetFile(new File(CALLING_POSTERIORS_OUTPUT_PATH, CoverageModelGlobalConstants.TARGET_LIST_OUTPUT_FILE));
reportCopyNumberSummaryStatistics(CALLING_POSTERIORS_OUTPUT_PATH, TEST_CALLING_COMBINED_COPY_NUMBER_FILE, callingTargets, CALLING_SEX_GENOTYPES_DATA);
logger.info("Copy number concordance test passed for case sample calling");
}
use of org.broadinstitute.hellbender.tools.exome.Target in project gatk by broadinstitute.
the class PoNTestUtils method createDummyHDF5FilePoN.
/** Creates a HDF5 PoN (using {@link HDF5PCACoveragePoNCreationUtils} ). Parameters use the
* current {@link CreatePanelOfNormals} defaults.
* @param inputPCovFile regular readable file that could be used to create a PoN. Must be same format as output of
* {@link org.broadinstitute.hellbender.tools.exome.CombineReadCounts}
* @param numEigensamples number of desired eigensamples in the PoN reduction
* @return HDF5 File. Never {@code null}
*/
public static File createDummyHDF5FilePoN(final File inputPCovFile, final int numEigensamples) {
IOUtils.canReadFile(inputPCovFile);
ParamUtils.isPositive(numEigensamples, "Number of eigensamples must be greater than zero.");
final File outputFile = IOUtils.createTempFile("dummy-pon-", ".pon");
final TargetCollection<Target> targets = TargetArgumentCollection.readTargetCollection(inputPCovFile);
HDF5PCACoveragePoNCreationUtils.create(null, outputFile, HDF5File.OpenMode.CREATE, inputPCovFile, targets, new ArrayList<>(), CreatePanelOfNormals.DEFAULT_TARGET_FACTOR_THRESHOLD_PERCENTILE, CreatePanelOfNormals.DEFAULT_MAXIMUM_PERCENT_ZEROS_IN_COLUMN, CreatePanelOfNormals.DEFAULT_MAXIMUM_PERCENT_ZEROS_IN_TARGET, CreatePanelOfNormals.DEFAULT_COLUMN_OUTLIER_DROP_THRESHOLD_PERCENTILE, CreatePanelOfNormals.DEFAULT_OUTLIER_TRUNCATE_PERCENTILE_THRESHOLD, OptionalInt.of(numEigensamples), false);
return outputFile;
}
use of org.broadinstitute.hellbender.tools.exome.Target in project gatk-protected by broadinstitute.
the class HDF5PCACoveragePoNCreationUtilsUnitTest method readCountOnlyWithDiverseShapeData.
@DataProvider(name = "readCountOnlyWithDiverseShapeData")
public Object[][] readCountOnlyWithDiverseShapeData() {
final List<Object[]> result = new ArrayList<>(4);
final Random rdn = new Random(31);
final int[] columnCounts = new int[] { 10, 100, 100, 200 };
final int[] targetCounts = new int[] { 100, 100, 200, 200 };
for (int k = 0; k < columnCounts.length; k++) {
final List<String> columnNames = IntStream.range(0, columnCounts[k]).mapToObj(i -> "sample_" + (i + 1)).collect(Collectors.toList());
final List<Target> targets = IntStream.range(0, targetCounts[k]).mapToObj(i -> new Target("target_" + (i + 1))).collect(Collectors.toList());
final double[][] counts = new double[targetCounts[k]][columnCounts[k]];
for (int i = 0; i < counts.length; i++) {
for (int j = 0; j < counts[0].length; j++) {
counts[i][j] = rdn.nextDouble();
}
}
final ReadCountCollection readCounts = new ReadCountCollection(targets, columnNames, new Array2DRowRealMatrix(counts, false));
result.add(new Object[] { readCounts });
}
return result.toArray(new Object[result.size()][]);
}
Aggregations