Commit d5ae90cf authored by Sander Bollen's avatar Sander Bollen
Browse files

Merge branch 'fix-report' into 'develop'

Fix report

Fixes #202 

See merge request !236
parents f65704c6 884125eb
......@@ -8,7 +8,7 @@ package nl.lumc.sasc.biopet
import nl.lumc.sasc.biopet.utils.{ BiopetExecutable, MainCommand }
object BiopetExecutableProtected extends BiopetExecutable {
def pipelines: List[MainCommand] = BiopetExecutablePublic.pipelines ::: List(
def pipelines: List[MainCommand] = BiopetExecutablePublic.publicPipelines ::: List(
nl.lumc.sasc.biopet.pipelines.gatk.Shiva,
nl.lumc.sasc.biopet.pipelines.gatk.ShivaVariantcalling,
nl.lumc.sasc.biopet.pipelines.gatk.Basty)
......
......@@ -42,7 +42,7 @@
#end
#if (showPlot)
#{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId) }#
#{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId, libId = libId) }#
<div class="panel-body">
<img src="insertsize.png" class="img-responsive" />
......
......@@ -36,7 +36,7 @@
#end
#if (showPlot)
#{ BammetricsReport.wgsHistogramPlot(outputDir, "wgs", summary, !sampleLevel, sampleId = sampleId) }#
#{ BammetricsReport.wgsHistogramPlot(outputDir, "wgs", summary, !sampleLevel, sampleId = sampleId, libId = libId) }#
<div class="panel-body">
<img src="wgs.png" class="img-responsive" />
......
......@@ -186,8 +186,13 @@ class BamMetrics(val root: Configurable) extends QScript with SummaryQScript wit
object BamMetrics extends PipelineCommand {
/** Make default implementation of BamMetrics and runs script already */
def apply(root: Configurable, bamFile: File, outputDir: File): BamMetrics = {
def apply(root: Configurable,
bamFile: File, outputDir: File,
sampleId: Option[String] = None,
libId: Option[String] = None): BamMetrics = {
val bamMetrics = new BamMetrics(root)
bamMetrics.sampleId = sampleId
bamMetrics.libId = libId
bamMetrics.inputBam = bamFile
bamMetrics.outputDir = outputDir
......
......@@ -156,14 +156,15 @@ object BammetricsReport extends ReportBuilder {
prefix: String,
summary: Summary,
libraryLevel: Boolean = false,
sampleId: Option[String] = None): Unit = {
sampleId: Option[String] = None,
libId: Option[String] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png")
val tsvWriter = new PrintWriter(tsvFile)
if (libraryLevel) {
tsvWriter.println((for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample;
lib <- summary.libraries(sample)
lib <- summary.libraries(sample) if libId.isEmpty || libId.get == lib
) yield s"$sample-$lib")
.mkString("library\t", "\t", ""))
} else {
......@@ -198,7 +199,7 @@ object BammetricsReport extends ReportBuilder {
if (libraryLevel) {
for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample;
lib <- summary.libraries(sample)
lib <- summary.libraries(sample) if libId.isEmpty || libId.get == lib
) fill(sample, Some(lib))
} else if (sampleId.isDefined) fill(sampleId.get, None)
else summary.samples.foreach(fill(_, None))
......@@ -208,7 +209,7 @@ object BammetricsReport extends ReportBuilder {
if (libraryLevel) {
for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample;
lib <- summary.libraries(sample)
lib <- summary.libraries(sample) if libId.isEmpty || libId.get == lib
) tsvWriter.print("\t" + counts.getOrElse(s"$sample-$lib", "0"))
} else {
for (sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample) {
......@@ -243,14 +244,15 @@ object BammetricsReport extends ReportBuilder {
prefix: String,
summary: Summary,
libraryLevel: Boolean = false,
sampleId: Option[String] = None): Unit = {
sampleId: Option[String] = None,
libId: Option[String] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png")
val tsvWriter = new PrintWriter(tsvFile)
if (libraryLevel) {
tsvWriter.println((for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample;
lib <- summary.libraries(sample)
lib <- summary.libraries(sample) if libId.isEmpty || libId.get == lib
) yield s"$sample-$lib")
.mkString("library\t", "\t", ""))
} else {
......@@ -285,7 +287,7 @@ object BammetricsReport extends ReportBuilder {
if (libraryLevel) {
for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample;
lib <- summary.libraries(sample)
lib <- summary.libraries(sample) if libId.isEmpty || libId.get == lib
) fill(sample, Some(lib))
} else if (sampleId.isDefined) fill(sampleId.get, None)
else summary.samples.foreach(fill(_, None))
......@@ -295,8 +297,10 @@ object BammetricsReport extends ReportBuilder {
if (libraryLevel) {
for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample;
lib <- summary.libraries(sample)
) tsvWriter.print("\t" + counts.getOrElse(s"$sample-$lib", "0"))
lib <- summary.libraries(sample) if libId.isEmpty || libId.get == lib
) {
tsvWriter.print("\t" + counts.getOrElse(s"$sample-$lib", "0"))
}
} else {
for (sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample) {
tsvWriter.print("\t" + counts.getOrElse(sample, "0"))
......
......@@ -48,5 +48,5 @@ class LinePlot(val root: Configurable) extends Rscript {
ylabel.map(Seq("--ylabel", _)).getOrElse(Seq()) ++
llabel.map(Seq("--llabel", _)).getOrElse(Seq()) ++
title.map(Seq("--title", _)).getOrElse(Seq()) ++
(if (removeZero) Seq("--removeZero") else Seq())
(if (removeZero) Seq("--removeZero", "true") else Seq())
}
......@@ -107,7 +107,7 @@ class Carp(val root: Configurable) extends QScript with MultiSampleQScript with
add(merge)
}
val bamMetrics = BamMetrics(qscript, bamFile, new File(sampleDir, "metrics"))
val bamMetrics = BamMetrics(qscript, bamFile, new File(sampleDir, "metrics"), sampleId = Some(sampleId))
addAll(bamMetrics.functions)
addSummaryQScript(bamMetrics)
addAll(Bam2Wig(qscript, bamFile).functions)
......
......@@ -76,7 +76,7 @@ object CarpReport extends MultisampleReportBuilder {
), List(
"Alignment" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp",
if (summary.libraries(sampleId).size > 1) Map("showPlot" -> true) else Map()),
"Preprocessing" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp", Map("sampleLevel" -> true)),
"Merged" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp", Map("sampleLevel" -> true)),
"QC reads" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepReadSummary.ssp"),
"QC bases" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepBaseSummary.ssp")
), args)
......
......@@ -129,7 +129,7 @@
#if (read == "R2") </tr><tr> #end
#{
val beforeTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read, "bases", "num_total").getOrElse(0).toString.toLong
val afterTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read + "_after", "bases", "num_total").getOrElse(0).toString.toLong
val afterTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read + "_qc", "bases", "num_total").getOrElse(0).toString.toLong
}#
<td>${read}</td>
<td>${beforeTotal}</td>
......
......@@ -133,7 +133,7 @@
#if (read == "R2") </tr><tr> #end
#{
val beforeTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read, "reads", "num_total")
val afterTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read + "_after", "reads", "num_total")
val afterTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read + "_qc", "reads", "num_total")
val clippingDiscardedToShort = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "clipping_" + read, "num_reads_discarded_too_short").getOrElse(0).toString.toLong
val clippingDiscardedToLong = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "clipping_" + read, "num_reads_discarded_too_long").getOrElse(0).toString.toLong
val trimmingDiscarded = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "trimming", "num_reads_discarded_" + read).getOrElse(0).toString.toLong
......
......@@ -218,6 +218,7 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
fqSync.outputFastq1 = swapExt(outDir, R1, R1_ext, ".sync" + R1_ext)
fqSync.outputFastq2 = swapExt(outDir, R2.get, R2_ext, ".sync" + R2_ext)
fqSync.outputStats = swapExt(outDir, R1, R1_ext, ".sync.stats")
fqSync.isIntermediate = true
fqSync.deps :::= deps
add(fqSync)
addSummarizable(fqSync, "fastq_sync")
......
......@@ -95,7 +95,7 @@ object FlexiprepReport extends ReportBuilder {
def getLine(summary: Summary, sample: String, lib: String): String = {
val beforeTotal = new SummaryValue(List("flexiprep", "stats", "seqstat_" + read, "reads", "num_total"),
summary, Some(sample), Some(lib)).value.getOrElse(0).toString.toLong
val afterTotal = new SummaryValue(List("flexiprep", "stats", "seqstat_" + read + "_after", "reads", "num_total"),
val afterTotal = new SummaryValue(List("flexiprep", "stats", "seqstat_" + read + "_qc", "reads", "num_total"),
summary, Some(sample), Some(lib)).value.getOrElse(0).toString.toLong
val clippingDiscardedToShort = new SummaryValue(List("flexiprep", "stats", "clipping_" + read, "num_reads_discarded_too_short"),
summary, Some(sample), Some(lib)).value.getOrElse(0).toString.toLong
......@@ -152,7 +152,7 @@ object FlexiprepReport extends ReportBuilder {
def getLine(summary: Summary, sample: String, lib: String): String = {
val beforeTotal = new SummaryValue(List("flexiprep", "stats", "seqstat_" + read, "bases", "num_total"),
summary, Some(sample), Some(lib)).value.getOrElse(0).toString.toLong
val afterTotal = new SummaryValue(List("flexiprep", "stats", "seqstat_" + read + "_after", "bases", "num_total"),
val afterTotal = new SummaryValue(List("flexiprep", "stats", "seqstat_" + read + "_qc", "bases", "num_total"),
summary, Some(sample), Some(lib)).value.getOrElse(0).toString.toLong
val sb = new StringBuffer()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment