Search in sources :

Example 16 with Resource

use of org.broadinstitute.hellbender.utils.io.Resource in project gatk by broadinstitute.

the class PlotACNVResults method writeSegmentedAlleleFractionPlot.

/**
     * @param sampleName Sample name derived from input files
     * @param contigNames List containing contig names
     * @param contigLengths List containing contig lengths (same order as contigNames)
     */
private void writeSegmentedAlleleFractionPlot(final String sampleName, final List<String> contigNames, final List<Integer> contigLengths) {
    //names separated by delimiter
    final String contigNamesArg = contigNames.stream().collect(Collectors.joining(CONTIG_DELIMITER));
    //lengths separated by delimiter
    final String contigLengthsArg = contigLengths.stream().map(Object::toString).collect(Collectors.joining(CONTIG_DELIMITER));
    final String outputDirArg = addTrailingSlashIfNecessary(outputDir);
    final RScriptExecutor executor = new RScriptExecutor();
    //this runs the R statement "source("CNVPlottingLibrary.R")" before the main script runs
    executor.addScript(new Resource(CNV_PLOTTING_R_LIBRARY, PlotSegmentedCopyRatio.class));
    executor.addScript(new Resource(ACNV_PLOTTING_R_SCRIPT, PlotACNVResults.class));
    //--args is needed for Rscript to recognize other arguments properly
    executor.addArgs("--args", "--sample_name=" + sampleName, "--snp_counts_file=" + snpCountsFile, "--tangent_file=" + tangentFile, "--segments_file=" + segmentsFile, "--contig_names=" + contigNamesArg, "--contig_lengths=" + contigLengthsArg, "--output_dir=" + outputDirArg, "--output_prefix=" + outputPrefix);
    executor.exec();
}
Also used : Resource(org.broadinstitute.hellbender.utils.io.Resource) RScriptExecutor(org.broadinstitute.hellbender.utils.R.RScriptExecutor)

Aggregations

Resource (org.broadinstitute.hellbender.utils.io.Resource)16 RScriptExecutor (org.broadinstitute.hellbender.utils.R.RScriptExecutor)14 File (java.io.File)7 GATKException (org.broadinstitute.hellbender.exceptions.GATKException)3 UserException (org.broadinstitute.hellbender.exceptions.UserException)3 MetricsFile (htsjdk.samtools.metrics.MetricsFile)2 DoubleStream (java.util.stream.DoubleStream)2 ParamUtils (org.broadinstitute.hellbender.utils.param.ParamUtils)2 SAMRecord (htsjdk.samtools.SAMRecord)1 SamReader (htsjdk.samtools.SamReader)1 ReferenceSequence (htsjdk.samtools.reference.ReferenceSequence)1 ReferenceSequenceFileWalker (htsjdk.samtools.reference.ReferenceSequenceFileWalker)1 Histogram (htsjdk.samtools.util.Histogram)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintStream (java.io.PrintStream)1 NumberFormat (java.text.NumberFormat)1 ArrayList (java.util.ArrayList)1 CommandLineException (org.broadinstitute.barclay.argparser.CommandLineException)1 GATKReport (org.broadinstitute.hellbender.utils.report.GATKReport)1 ProcessController (org.broadinstitute.hellbender.utils.runtime.ProcessController)1