Commit 0008b0d3 authored by rhpvorderman's avatar rhpvorderman

Completely defutured clipping.ssp

parent 67b9334f
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema._)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Sample)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Library)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
......@@ -18,6 +19,8 @@
<%@ var fields: List[String] = List("min", "max", "mean", "median", "modal")%>
<%@ var allSamples: Seq[Sample] %>
<%@ var allLibraries: Seq[Library] %>
<%@ var clippingPlotTables: Array[Map[String, Array[Any]]] %>
<%@ var clippingTableResults: Map[(Int, Int), Map[String, Option[Any]]] %>
#{
val samples = sampleId match {
case Some(id) => allSamples.filter(_.id == id).toList
......@@ -43,7 +46,7 @@
#end
#if (showPlot)
#{ BammetricsReport.clippingPlot(outputDir, "clipping", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
#{ BammetricsReport.clippingPlot(outputDir, "clipping", clippingPlotTables) }#
<div class="panel-body">
<img src="clipping.png" class="img-responsive" />
......@@ -86,8 +89,7 @@
#if (libs.head != libId) <tr> #end
#if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
#{
val statsPaths = fields.map(x => x -> List("clipping", "general", x)).toMap
val results = summary.getStatKeys(runId, "bammetrics", "bamstats", sample = sample.id, library = libId.map(LibraryId).getOrElse(NoLibrary), keyValues = statsPaths)
val results: Map[String, Option[Any]] = clippingTableResults(sample.id, libId)
}#
#for (field <- fields)
<td>${results(field)}</td>
......
......@@ -17,7 +17,13 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
import java.io.{File, PrintWriter}
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.core.report.{ReportBuilder, ReportBuilderExtension, ReportPage, ReportSection}
import nl.lumc.sasc.biopet.core.report.{
ReportBuilder,
ReportBuilderExtension,
ReportPage,
ReportSection
}
import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport.mappingQualityPlotTables
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.rscript.{LinePlot, StackedBarPlot}
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
......@@ -479,10 +485,17 @@ object BammetricsReport extends ReportBuilder {
"position" -> List("histogram", "normalized_position"),
"count" -> List("histogram", "All_Reads.normalized_coverage")
)
summaryForPlot(summary,statsPaths, "position" :: Nil,
"count" :: Nil, "bammetrics",
"rna",libraryLevel,sampleId,libraryId)
summaryForPlot(summary,
statsPaths,
"position" :: Nil,
"count" :: Nil,
"bammetrics",
"rna",
libraryLevel,
sampleId,
libraryId)
}
/**
* Generate a line plot for rna coverage
*
......@@ -503,8 +516,7 @@ object BammetricsReport extends ReportBuilder {
"count" :: Nil,
"Relative position",
"Coverage",
"RNA coverage"
)
"RNA coverage")
}
def mergeTables(tables: Array[Map[String, Array[Any]]],
......@@ -529,67 +541,4 @@ object BammetricsReport extends ReportBuilder {
}
writer.close()
}
def alignmentReportValues(summary: SummaryDb,
runId: Int,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int] = None,
libId: Option[Int] = None,
sampleLevel: Boolean = false,
showPlot: Boolean = false,
showIntro: Boolean = true,
showTable: Boolean = true): Map[String, Any] = {
val statsPaths = Map(
"All" -> List("flagstats", "All"),
"Mapped" -> List("flagstats", "Mapped"),
"Duplicates" -> List("flagstats", "Duplicates"),
"NotPrimaryAlignment" -> List("flagstats", "NotPrimaryAlignment")
)
val alignmentSummaryResults =
summary.getStatsForLibraries(runId, "bammetrics", "bamstats", sampleId, statsPaths)
val alignmentSummaryPlotLines: Option[Seq[String]] =
if (showPlot)
Some(BammetricsReport.alignmentSummaryPlotLines(summary, sampleId, !sampleLevel))
else None
Map(
"alignmentSummaryResults" -> alignmentSummaryResults,
"alignmentSummaryPlotLines" -> alignmentSummaryPlotLines,
"sampleLevel" -> sampleLevel,
"showPlot" -> showPlot,
"showIntro" -> showIntro,
"showTable" -> showTable,
"sampleId" -> sampleId,
"libId" -> libId
)
}
def mappingQualityValues(summary: SummaryDb,
runId: Int,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int],
libId: Option[Int],
fields: List[String] = List("min", "max", "mean", "median", "modal"),
sampleLevel: Boolean = false,
showPlot: Boolean = false,
showIntro: Boolean = true,
showTable: Boolean = true)
: Map[String, Any] = {
val samples = sampleId match {
case Some(id) => allSamples.filter(_.id == id).toList
case _ => allSamples.toList
}
val mapQualityPlotTables = mappingQualityPlotTables(summary,!sampleLevel,sampleId,libId)
val statsPaths = fields.map(x => x -> List("mapping_quality", "general", x)).toMap
val mappingQualityTableResults: Map[(Int, Int), Map[String, Option[Any]]]: = summary.getStatsForLibraries(runId, "bammetrics", "bamstats", sampleId, statsPaths)
Map("mappingQualityPlotTables" -> mapQualityPlotTables,
"mappingQualityTableResults" -> mappingQualityTableResults,
"showIntro" -> showIntro,
"showTable" -> showTable,
"showPlot" -> showPlot,
"sampleId" -> sampleId,
"libId" -> libId)
}
}
\ No newline at end of file
package nl.lumc.sasc.biopet.pipelines.bammetrics
import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport.mappingQualityPlotTables
import nl.lumc.sasc.biopet.utils.summary.db.Schema.{Library, Sample}
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._
object BammetricsReportPage {
def alignmentSummaryValues(summary: SummaryDb,
runId: Int,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int] = None,
libId: Option[Int] = None,
sampleLevel: Boolean = false,
showPlot: Boolean = false,
showIntro: Boolean = true,
showTable: Boolean = true): Map[String, Any] = {
val statsPaths = Map(
"All" -> List("flagstats", "All"),
"Mapped" -> List("flagstats", "Mapped"),
"Duplicates" -> List("flagstats", "Duplicates"),
"NotPrimaryAlignment" -> List("flagstats", "NotPrimaryAlignment")
)
val alignmentSummaryResults =
summary.getStatsForLibraries(runId, "bammetrics", "bamstats", sampleId, statsPaths)
val alignmentSummaryPlotLines: Option[Seq[String]] =
if (showPlot)
Some(BammetricsReport.alignmentSummaryPlotLines(summary, sampleId, !sampleLevel))
else None
Map(
"alignmentSummaryResults" -> alignmentSummaryResults,
"alignmentSummaryPlotLines" -> alignmentSummaryPlotLines,
"sampleLevel" -> sampleLevel,
"showPlot" -> showPlot,
"showIntro" -> showIntro,
"showTable" -> showTable,
"sampleId" -> sampleId,
"libId" -> libId
)
}
def mappingQualityValues(summary: SummaryDb,
runId: Int,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int],
libId: Option[Int],
fields: List[String] = List("min", "max", "mean", "median", "modal"),
sampleLevel: Boolean = false,
showPlot: Boolean = false,
showIntro: Boolean = true,
showTable: Boolean = true): Map[String, Any] = {
val samples = sampleId match {
case Some(id) => allSamples.filter(_.id == id).toList
case _ => allSamples.toList
}
val mapQualityPlotTables = mappingQualityPlotTables(summary, !sampleLevel, sampleId, libId)
val statsPaths = fields.map(x => x -> List("mapping_quality", "general", x)).toMap
val mappingQualityTableResults: Map[(Int, Int), Map[String, Option[Any]]] =
summary.getStatsForLibraries(runId, "bammetrics", "bamstats", sampleId, statsPaths)
Map(
"mappingQualityPlotTables" -> mapQualityPlotTables,
"mappingQualityTableResults" -> mappingQualityTableResults,
"showIntro" -> showIntro,
"showTable" -> showTable,
"showPlot" -> showPlot,
"sampleId" -> sampleId,
"libId" -> libId
)
}
def clippingValues(summary: SummaryDb,
runId: Int,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int],
libId: Option[Int],
fields: List[String] = List("min", "max", "mean", "median", "modal"),
sampleLevel: Boolean = false,
showPlot: Boolean = false,
showIntro: Boolean = true,
showTable: Boolean = true): Map[String, Any] = {
val samples = sampleId match {
case Some(id) => allSamples.filter(_.id == id).toList
case _ => allSamples.toList
}
val clippingPlotTables = BammetricsReport.clippingPlotTables(summary,!sampleLevel, sampleId, libId)
val statsPaths = fields.map(x => x -> List("clipping", "general", x)).toMap
val clippingTableResults = summary.getStatsForLibraries(runId, "bammetrics", "bamstats",sampleId, statsPaths)
Map(
"clippingPlotTables" -> clippingPlotTables,
"clippingTableResults" -> clippingTableResults,
"showIntro" -> showIntro,
"showTable" -> showTable,
"showPlot" -> showPlot,
"sampleId" -> sampleId,
"libId" -> libId
)
}
}
......@@ -20,7 +20,7 @@ import nl.lumc.sasc.biopet.core.report.{
ReportPage,
ReportSection
}
import nl.lumc.sasc.biopet.pipelines.bammetrics.{BamMetricsAlignmentReport, BammetricsReport}
import nl.lumc.sasc.biopet.pipelines.bammetrics.{BammetricsReport, BammetricsReportPage}
import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import nl.lumc.sasc.biopet.pipelines.gears.GearsKronaPlot
import nl.lumc.sasc.biopet.utils.config.Configurable
......@@ -124,7 +124,16 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
libraries,
sampleId,
libId)
val alignmentSummary = BammetricsReport.alignmentReportValues(summary,
val alignmentReportValues = BammetricsReportPage.alignmentSummaryValues(summary,
runId,
samples,
libraries,
sampleId,
libId,
sampleLevel = true,
showPlot = true,
showTable = false)
val mappingQualityReportValues = BammetricsReportPage.mappingQualityValues(summary,
runId,
samples,
libraries,
......@@ -133,7 +142,6 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
sampleLevel = true,
showPlot = true,
showTable = false)
val mappingQualitySummary = BammetricsReport.mappingQualityPlotTables(summary)
Future {
ReportPage(
List("Samples" -> generateSamplesPage(pageArgs)) ++
......@@ -176,10 +184,10 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
List(
"Alignment" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp",
alignmentSummary),
alignmentReportValues),
"Mapping Quality" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/mappingQuality.ssp",
Map("sampleLevel" -> true, "showPlot" -> true, "showTable" -> false)),
mappingQualityReportValues),
"Clipping" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/clipping.ssp",
Map("sampleLevel" -> true,
"showPlot" -> true,
......
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