Commit c7b0392c authored by Peter van 't Hof's avatar Peter van 't Hof

Fix plots for library level

parent 2d950663
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#end #end
#if (showPlot) #if (showPlot)
#{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId) }# #{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId, libId = libId) }#
<div class="panel-body"> <div class="panel-body">
<img src="insertsize.png" class="img-responsive" /> <img src="insertsize.png" class="img-responsive" />
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#end #end
#if (showPlot) #if (showPlot)
#{ BammetricsReport.wgsHistogramPlot(outputDir, "wgs", summary, !sampleLevel, sampleId = sampleId) }# #{ BammetricsReport.wgsHistogramPlot(outputDir, "wgs", summary, !sampleLevel, sampleId = sampleId, libId = libId) }#
<div class="panel-body"> <div class="panel-body">
<img src="wgs.png" class="img-responsive" /> <img src="wgs.png" class="img-responsive" />
......
...@@ -156,14 +156,15 @@ object BammetricsReport extends ReportBuilder { ...@@ -156,14 +156,15 @@ object BammetricsReport extends ReportBuilder {
prefix: String, prefix: String,
summary: Summary, summary: Summary,
libraryLevel: Boolean = false, 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 tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png") val pngFile = new File(outputDir, prefix + ".png")
val tsvWriter = new PrintWriter(tsvFile) val tsvWriter = new PrintWriter(tsvFile)
if (libraryLevel) { if (libraryLevel) {
tsvWriter.println((for ( tsvWriter.println((for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample; 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") ) yield s"$sample-$lib")
.mkString("library\t", "\t", "")) .mkString("library\t", "\t", ""))
} else { } else {
...@@ -198,7 +199,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -198,7 +199,7 @@ object BammetricsReport extends ReportBuilder {
if (libraryLevel) { if (libraryLevel) {
for ( for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample; 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)) ) fill(sample, Some(lib))
} else if (sampleId.isDefined) fill(sampleId.get, None) } else if (sampleId.isDefined) fill(sampleId.get, None)
else summary.samples.foreach(fill(_, None)) else summary.samples.foreach(fill(_, None))
...@@ -208,7 +209,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -208,7 +209,7 @@ object BammetricsReport extends ReportBuilder {
if (libraryLevel) { if (libraryLevel) {
for ( for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample; 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")) ) tsvWriter.print("\t" + counts.getOrElse(s"$sample-$lib", "0"))
} else { } else {
for (sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample) { for (sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample) {
...@@ -243,14 +244,15 @@ object BammetricsReport extends ReportBuilder { ...@@ -243,14 +244,15 @@ object BammetricsReport extends ReportBuilder {
prefix: String, prefix: String,
summary: Summary, summary: Summary,
libraryLevel: Boolean = false, 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 tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png") val pngFile = new File(outputDir, prefix + ".png")
val tsvWriter = new PrintWriter(tsvFile) val tsvWriter = new PrintWriter(tsvFile)
if (libraryLevel) { if (libraryLevel) {
tsvWriter.println((for ( tsvWriter.println((for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample; 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") ) yield s"$sample-$lib")
.mkString("library\t", "\t", "")) .mkString("library\t", "\t", ""))
} else { } else {
...@@ -285,7 +287,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -285,7 +287,7 @@ object BammetricsReport extends ReportBuilder {
if (libraryLevel) { if (libraryLevel) {
for ( for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample; 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)) ) fill(sample, Some(lib))
} else if (sampleId.isDefined) fill(sampleId.get, None) } else if (sampleId.isDefined) fill(sampleId.get, None)
else summary.samples.foreach(fill(_, None)) else summary.samples.foreach(fill(_, None))
...@@ -295,8 +297,10 @@ object BammetricsReport extends ReportBuilder { ...@@ -295,8 +297,10 @@ object BammetricsReport extends ReportBuilder {
if (libraryLevel) { if (libraryLevel) {
for ( for (
sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample; 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")) ) {
tsvWriter.print("\t" + counts.getOrElse(s"$sample-$lib", "0"))
}
} else { } else {
for (sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample) { for (sample <- summary.samples if sampleId.isEmpty || sampleId.get == sample) {
tsvWriter.print("\t" + counts.getOrElse(sample, "0")) tsvWriter.print("\t" + counts.getOrElse(sample, "0"))
......
Markdown is supported
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