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