Commit e5b7192d authored by rhpvorderman's avatar rhpvorderman

Defutured covstats.ssp

parent e2e3d2a5
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#import(scala.concurrent.Await) #import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration) #import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport) #import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema)
#import(java.io.File) #import(java.io.File)
<%@ var summary: SummaryDb %> <%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] %> <%@ var sampleId: Option[Int] %>
...@@ -16,17 +17,15 @@ ...@@ -16,17 +17,15 @@
<%@ var target: Option[String] %> <%@ var target: Option[String] %>
<%@ var runId: Int %> <%@ var runId: Int %>
<%@ var fields: List[String] = List("mean", "median", "max", "horizontal", "frac_min_10x", "frac_min_20x", "frac_min_30x", "frac_min_40x", "frac_min_50x") %> <%@ var fields: List[String] = List("mean", "median", "max", "horizontal", "frac_min_10x", "frac_min_20x", "frac_min_30x", "frac_min_40x", "frac_min_50x") %>
<%@ var plotFile: Option[Schema.File] %>
<%@ var values: Map[String, Option[Any]] %>
#{ #{
val moduleName = target.get + "_cov_stats" val moduleName = target.get + "_cov_stats"
val statsPaths = fields.map(x => x -> List("coverage", "_all", x)).toMap
val plotFile = Await.result(summary.getFile(runId, PipelineName(metricsTag), ModuleName(moduleName), sampleId.map(SampleId).get, libId.map(LibraryId).getOrElse(NoLibrary), "plot"), Duration.Inf)
val originalPlot = new File(plotFile.get.path) val originalPlot = new File(plotFile.get.path)
val plot = new File(outputDir, target.get + "_cov_stats.png") val plot = new File(outputDir, target.get + "_cov_stats.png")
val values = summary.getStatKeys(runId, PipelineName(metricsTag), ModuleName(moduleName), sampleId.map(SampleId).get, libId.map(LibraryId).getOrElse(NoLibrary), statsPaths) if (originalPlot.exists()) IoUtils.copyFile(originalPlot, plot)
if (originalPlot.exists()) IoUtils.copyFile(originalPlot, plot)
}# }#
<img src="${plot.getName}"> <img src="${plot.getName}">
......
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
#for (field <- fields) #for (field <- fields)
<td>${results(field)}</td> <td>${results(field)}</td>
#end #end
#end
</tr> </tr>
#end #end
#end #end
......
...@@ -23,13 +23,11 @@ import nl.lumc.sasc.biopet.core.report.{ ...@@ -23,13 +23,11 @@ import nl.lumc.sasc.biopet.core.report.{
ReportPage, ReportPage,
ReportSection 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
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
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.Schema._
import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.ArrayBuffer
import scala.concurrent.{Await, Future} import scala.concurrent.{Await, Future}
...@@ -71,11 +69,20 @@ object BammetricsReport extends ReportBuilder { ...@@ -71,11 +69,20 @@ object BammetricsReport extends ReportBuilder {
) )
} }
/** Generates values for bamMetricsPage */
def bamMetricsPageValues(summary: SummaryDb,
sampleId: Option[Int],
libId: Option[Int],
metricsTag: String = "bammetrics"): Map[String, Any] = {
Map("" -> "")
}
/** Generates a page with alignment stats */ /** Generates a page with alignment stats */
def bamMetricsPage(summary: SummaryDb, def bamMetricsPage(summary: SummaryDb,
sampleId: Option[Int], sampleId: Option[Int],
libId: Option[Int], libId: Option[Int],
metricsTag: String = "bammetrics"): Future[ReportPage] = Future { metricsTag: String = "bammetrics"): Future[ReportPage] = {
val wgsExecuted = summary.getStatsSize(runId, val wgsExecuted = summary.getStatsSize(runId,
metricsTag, metricsTag,
"wgs", "wgs",
...@@ -115,45 +122,55 @@ object BammetricsReport extends ReportBuilder { ...@@ -115,45 +122,55 @@ object BammetricsReport extends ReportBuilder {
case _ => Nil case _ => Nil
} }
ReportPage( val covstatsPlotValuesArray = ArrayBuffer[(String, Map[String,Any])]()
if (targets.isEmpty) List() for (t <- targets) {
else covstatsPlotValuesArray += Tuple2(t,BammetricsReportPage.covstatsPlotValues(summary, runId, sampleId, libId, Some(t)))
}
val covstatsPlotValuesList = covstatsPlotValuesArray.toList
Future {
ReportPage(
if (targets.isEmpty) List()
else
List(
"Targets" -> Future.successful(
ReportPage(
List(),
covstatsPlotValuesList.map(covstats =>
covstats._1 -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/covstatsPlot.ssp",
covstats._2)),
Map()))),
List( List(
"Targets" -> Future.successful( "Summary" -> ReportSection(
ReportPage( "/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"),
List(), "Mapping Quality" -> ReportSection(
targets.map(t => "/nl/lumc/sasc/biopet/pipelines/bammetrics/mappingQuality.ssp",
t -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/covstatsPlot.ssp", Map("showPlot" -> true)),
Map("target" -> Some(t)))), "Clipping" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/clipping.ssp",
Map()))), Map("showPlot" -> true))
List( ) ++
"Summary" -> ReportSection( (if (insertsizeMetrics)
"/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"), List(
"Mapping Quality" -> ReportSection( "Insert Size" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/mappingQuality.ssp", "/nl/lumc/sasc/biopet/pipelines/bammetrics/insertSize.ssp",
Map("showPlot" -> true)), Map("showPlot" -> true)))
"Clipping" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/clipping.ssp", else Nil) ++ (if (wgsExecuted)
Map("showPlot" -> true)) List(
) ++ "Whole genome coverage" -> ReportSection(
(if (insertsizeMetrics) "/nl/lumc/sasc/biopet/pipelines/bammetrics/wgsHistogram.ssp",
List( Map("showPlot" -> true)))
"Insert Size" -> ReportSection( else Nil) ++
"/nl/lumc/sasc/biopet/pipelines/bammetrics/insertSize.ssp", (if (rnaExecuted)
Map("showPlot" -> true))) List(
else Nil) ++ (if (wgsExecuted) "Rna coverage" -> ReportSection(
List( "/nl/lumc/sasc/biopet/pipelines/bammetrics/rnaHistogram.ssp",
"Whole genome coverage" -> ReportSection( Map("showPlot" -> true)))
"/nl/lumc/sasc/biopet/pipelines/bammetrics/wgsHistogram.ssp", else Nil),
Map("showPlot" -> true))) Map("metricsTag" -> metricsTag)
else Nil) ++ )
(if (rnaExecuted) }
List(
"Rna coverage" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/rnaHistogram.ssp",
Map("showPlot" -> true)))
else Nil),
Map("metricsTag" -> metricsTag)
)
} }
/** /**
...@@ -541,4 +558,4 @@ object BammetricsReport extends ReportBuilder { ...@@ -541,4 +558,4 @@ object BammetricsReport extends ReportBuilder {
} }
writer.close() writer.close()
} }
} }
\ No newline at end of file
...@@ -2,10 +2,14 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics ...@@ -2,10 +2,14 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport.mappingQualityPlotTables 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.Schema.{Library, Sample}
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb import nl.lumc.sasc.biopet.utils.summary.db.{Schema, SummaryDb}
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._ import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import java.io.File
object BammetricsReportPage { object BammetricsReportPage {
def alignmentSummaryValues(summary: SummaryDb, def alignmentSummaryValues(summary: SummaryDb,
runId: Int, runId: Int,
...@@ -99,7 +103,8 @@ object BammetricsReportPage { ...@@ -99,7 +103,8 @@ object BammetricsReportPage {
else None else None
val statsPaths = fields.map(x => x -> List("clipping", "general", x)).toMap val statsPaths = fields.map(x => x -> List("clipping", "general", x)).toMap
val clippingTableResults = summary.getStatsForLibraries(runId, "bammetrics", "bamstats", sampleId, statsPaths) val clippingTableResults =
summary.getStatsForLibraries(runId, "bammetrics", "bamstats", sampleId, statsPaths)
Map( Map(
"clippingPlotTables" -> clippingPlotTables, "clippingPlotTables" -> clippingPlotTables,
"clippingTableResults" -> clippingTableResults, "clippingTableResults" -> clippingTableResults,
...@@ -117,7 +122,8 @@ object BammetricsReportPage { ...@@ -117,7 +122,8 @@ object BammetricsReportPage {
allLibraries: Seq[Library], allLibraries: Seq[Library],
sampleId: Option[Int], sampleId: Option[Int],
libId: Option[Int], libId: Option[Int],
fields: List[String] = List("mean_insert_size", "standard_deviation", "median_insert_size"), fields: List[String] =
List("mean_insert_size", "standard_deviation", "median_insert_size"),
sampleLevel: Boolean = false, sampleLevel: Boolean = false,
showPlot: Boolean = false, showPlot: Boolean = false,
showIntro: Boolean = true, showIntro: Boolean = true,
...@@ -133,7 +139,11 @@ object BammetricsReportPage { ...@@ -133,7 +139,11 @@ object BammetricsReportPage {
else None else None
val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap
val insertSizeTableResults = summary.getStatsForLibraries(runId, "bammetrics", "CollectInsertSizeMetrics", sampleId, statsPaths) val insertSizeTableResults = summary.getStatsForLibraries(runId,
"bammetrics",
"CollectInsertSizeMetrics",
sampleId,
statsPaths)
Map( Map(
"insertSizePlotTables" -> insertSizePlotTables, "insertSizePlotTables" -> insertSizePlotTables,
"insertSizeTableResults" -> insertSizeTableResults, "insertSizeTableResults" -> insertSizeTableResults,
...@@ -145,16 +155,19 @@ object BammetricsReportPage { ...@@ -145,16 +155,19 @@ object BammetricsReportPage {
) )
} }
def rnaHistogramValues(summary: SummaryDb, def rnaHistogramValues(summary: SummaryDb,
runId: Int, runId: Int,
allSamples: Seq[Sample], allSamples: Seq[Sample],
allLibraries: Seq[Library], allLibraries: Seq[Library],
sampleId: Option[Int], sampleId: Option[Int],
libId: Option[Int], libId: Option[Int],
fields: List[String] = List("PF_ALIGNED_BASES", "MEDIAN_5PRIME_BIAS", "MEDIAN_3PRIME_BIAS", "MEDIAN_5PRIME_TO_3PRIME_BIAS"), fields: List[String] = List("PF_ALIGNED_BASES",
sampleLevel: Boolean = false, "MEDIAN_5PRIME_BIAS",
showPlot: Boolean = false, "MEDIAN_3PRIME_BIAS",
showIntro: Boolean = true, "MEDIAN_5PRIME_TO_3PRIME_BIAS"),
showTable: Boolean = true): Map[String, Any] = { sampleLevel: Boolean = false,
showPlot: Boolean = false,
showIntro: Boolean = true,
showTable: Boolean = true): Map[String, 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
...@@ -166,7 +179,8 @@ object BammetricsReportPage { ...@@ -166,7 +179,8 @@ object BammetricsReportPage {
else None else None
val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap
val rnaHistogramTableResults = summary.getStatsForLibraries(runId, "bammetrics", "rna", sampleId, statsPaths) val rnaHistogramTableResults =
summary.getStatsForLibraries(runId, "bammetrics", "rna", sampleId, statsPaths)
Map( Map(
"rnaHistogramPlotTables" -> rnaHistogramPlotTables, "rnaHistogramPlotTables" -> rnaHistogramPlotTables,
"rnaHistogramTableResults" -> rnaHistogramTableResults, "rnaHistogramTableResults" -> rnaHistogramTableResults,
...@@ -183,7 +197,20 @@ object BammetricsReportPage { ...@@ -183,7 +197,20 @@ object BammetricsReportPage {
allLibraries: Seq[Library], allLibraries: Seq[Library],
sampleId: Option[Int], sampleId: Option[Int],
libId: Option[Int], libId: Option[Int],
fields: List[String] = List("mean_coverage", "pct_5x", "pct_10x", "pct_15x", "pct_20x", "pct_25x", "pct_30x", "pct_40x", "pct_50x", "pct_60x", "pct_70x", "pct_80x", "pct_90x", "pct_100x"), fields: List[String] = List("mean_coverage",
"pct_5x",
"pct_10x",
"pct_15x",
"pct_20x",
"pct_25x",
"pct_30x",
"pct_40x",
"pct_50x",
"pct_60x",
"pct_70x",
"pct_80x",
"pct_90x",
"pct_100x"),
sampleLevel: Boolean = false, sampleLevel: Boolean = false,
showPlot: Boolean = false, showPlot: Boolean = false,
showIntro: Boolean = true, showIntro: Boolean = true,
...@@ -199,7 +226,8 @@ object BammetricsReportPage { ...@@ -199,7 +226,8 @@ object BammetricsReportPage {
else None else None
val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap
val wgsHistogramTableResults = summary.getStatsForLibraries(runId, "bammetrics", "wgs", sampleId, statsPaths) val wgsHistogramTableResults =
summary.getStatsForLibraries(runId, "bammetrics", "wgs", sampleId, statsPaths)
Map( Map(
"wgsHistogramPlotTables" -> wgsHistogramPlotTables, "wgsHistogramPlotTables" -> wgsHistogramPlotTables,
"wgsHistogramTableResults" -> wgsHistogramTableResults, "wgsHistogramTableResults" -> wgsHistogramTableResults,
...@@ -210,5 +238,41 @@ object BammetricsReportPage { ...@@ -210,5 +238,41 @@ object BammetricsReportPage {
"libId" -> libId "libId" -> libId
) )
} }
def covstatsPlotValues(summary: SummaryDb,
runId: Int,
sampleId: Option[Int],
libId: Option[Int],
target: Option[String],
metricsTag: String = "bammetrics",
fields: List[String] = List("mean",
"median",
"max",
"horizontal",
"frac_min_10x",
"frac_min_20x",
"frac_min_30x",
"frac_min_40x",
"frac_min_50x")): Map[String, Any] = {
val moduleName = target.get + "_cov_stats"
val plotFile: Option[Schema.File] = Await.result(
summary.getFile(runId,
PipelineName(metricsTag),
ModuleName(moduleName),
sampleId.map(SampleId).get,
libId.map(LibraryId).getOrElse(NoLibrary),
"plot"),
Duration.Inf
)
val statsPaths = fields.map(x => x -> List("coverage", "_all", x)).toMap
val values: Map[String, Option[Any]] = summary.getStatKeys(
runId,
PipelineName(metricsTag),
ModuleName(moduleName),
sampleId.map(SampleId).get,
libId.map(LibraryId).getOrElse(NoLibrary),
statsPaths)
Map("plotFile" -> plotFile, "values" -> values,
"target" -> target,
"metricsTag" -> metricsTag)
}
} }
...@@ -53,36 +53,36 @@ object FlexiprepReport extends ReportBuilder { ...@@ -53,36 +53,36 @@ object FlexiprepReport extends ReportBuilder {
/** Index page for a flexiprep report */ /** Index page for a flexiprep report */
def indexPage: Future[ReportPage] = { def indexPage: Future[ReportPage] = {
val flexiprepPageSummaries = this.flexiprepPageSummaries(summary, sampleId.get, libId.get) val flexiprepPageSummaries = this.flexiprepPageSummaries(summary, sampleId.get, libId.get)
this.flexiprepPage(flexiprepPageSummaries).map { this.flexiprepPage(flexiprepPageSummaries).map { page =>
page => ReportPage(
ReportPage( Nil,
Nil, List(
List( "Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepFront.ssp")
"Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepFront.ssp") ) ::: page.sections,
) ::: page.sections, Map())
Map()) }
}} }
/** Generate a QC report page for 1 single library, sampleId and libId must be defined in the arguments */ /** Generate a QC report page for 1 single library, sampleId and libId must be defined in the arguments */
def flexiprepPageSummaries(summary: SummaryDb, def flexiprepPageSummaries(summary: SummaryDb,
sampleId: Int, sampleId: Int,
libId: Int): Map[String, Map[String, Any]] = { libId: Int): Map[String, Map[String, Any]] = {
val flexiprepReadSummary: Map[String, Any] = FlexiprepReadSummary.values(summary, val flexiprepReadSummary: Map[String, Any] = FlexiprepReadSummary.values(summary,
runId, runId,
samples, samples,
libraries, libraries,
sampleId, sampleId,
libId, libId,
multisample = false) multisample = false)
val flexiprepBaseSummary: Map[String,Any] = FlexiprepBaseSummary.values(summary, val flexiprepBaseSummary: Map[String, Any] = FlexiprepBaseSummary.values(summary,
runId, runId,
samples, samples,
libraries, libraries,
sampleId, sampleId,
libId, libId,
multisample = false) multisample = false)
Map("flexiprepReadSummary" -> flexiprepReadSummary, Map("flexiprepReadSummary" -> flexiprepReadSummary,
"flexiprepBaseSummary" -> flexiprepBaseSummary "flexiprepBaseSummary" -> flexiprepBaseSummary)
)
} }
def flexiprepPage(summaries: Map[String, Map[String, Any]]): Future[ReportPage] = { def flexiprepPage(summaries: Map[String, Map[String, Any]]): Future[ReportPage] = {
......
...@@ -345,10 +345,10 @@ object GearsReport extends MultisampleReportBuilder { ...@@ -345,10 +345,10 @@ object GearsReport extends MultisampleReportBuilder {
val flexiprepReportPage = val flexiprepReportPage =
if (flexiprepExecuted) { if (flexiprepExecuted) {
val flexiprepPageSummaries = FlexiprepReport.flexiprepPageSummaries(summary,sampleId,libId) val flexiprepPageSummaries =
FlexiprepReport.flexiprepPageSummaries(summary, sampleId, libId)
Some("QC" -> FlexiprepReport.flexiprepPage(flexiprepPageSummaries)) Some("QC" -> FlexiprepReport.flexiprepPage(flexiprepPageSummaries))
} } else None
else None
val centrifugePageAllMappingsKronaPlot = GearsKronaPlot.values(summary, val centrifugePageAllMappingsKronaPlot = GearsKronaPlot.values(summary,
runId, runId,
......
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