Commit e5b7192d authored by rhpvorderman's avatar rhpvorderman

Defutured covstats.ssp

parent e2e3d2a5
......@@ -7,6 +7,7 @@
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema)
#import(java.io.File)
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] %>
......@@ -16,17 +17,15 @@
<%@ var target: Option[String] %>
<%@ 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 plotFile: Option[Schema.File] %>
<%@ var values: Map[String, Option[Any]] %>
#{
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 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}">
......
......@@ -85,6 +85,7 @@
#for (field <- fields)
<td>${results(field)}</td>
#end
#end
</tr>
#end
#end
......
......@@ -23,13 +23,11 @@ import nl.lumc.sasc.biopet.core.report.{
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
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.Schema._
import scala.collection.mutable.ArrayBuffer
import scala.concurrent.{Await, Future}
......@@ -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 */
def bamMetricsPage(summary: SummaryDb,
sampleId: Option[Int],
libId: Option[Int],
metricsTag: String = "bammetrics"): Future[ReportPage] = Future {
metricsTag: String = "bammetrics"): Future[ReportPage] = {
val wgsExecuted = summary.getStatsSize(runId,
metricsTag,
"wgs",
......@@ -115,45 +122,55 @@ object BammetricsReport extends ReportBuilder {
case _ => Nil
}
ReportPage(
if (targets.isEmpty) List()
else
val covstatsPlotValuesArray = ArrayBuffer[(String, Map[String,Any])]()
for (t <- targets) {
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(
"Targets" -> Future.successful(
ReportPage(
List(),
targets.map(t =>
t -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/covstatsPlot.ssp",
Map("target" -> Some(t)))),
Map()))),
List(
"Summary" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"),
"Mapping Quality" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/mappingQuality.ssp",
Map("showPlot" -> true)),
"Clipping" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/clipping.ssp",
Map("showPlot" -> true))
) ++
(if (insertsizeMetrics)
List(
"Insert Size" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/insertSize.ssp",
Map("showPlot" -> true)))
else Nil) ++ (if (wgsExecuted)
List(
"Whole genome coverage" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/wgsHistogram.ssp",
Map("showPlot" -> true)))
else Nil) ++
(if (rnaExecuted)
List(
"Rna coverage" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/rnaHistogram.ssp",
Map("showPlot" -> true)))
else Nil),
Map("metricsTag" -> metricsTag)
)
"Summary" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"),
"Mapping Quality" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/mappingQuality.ssp",
Map("showPlot" -> true)),
"Clipping" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/clipping.ssp",
Map("showPlot" -> true))
) ++
(if (insertsizeMetrics)
List(
"Insert Size" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/insertSize.ssp",
Map("showPlot" -> true)))
else Nil) ++ (if (wgsExecuted)
List(
"Whole genome coverage" -> ReportSection(
"/nl/lumc/sasc/biopet/pipelines/bammetrics/wgsHistogram.ssp",
Map("showPlot" -> true)))
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 {
}
writer.close()
}
}
\ No newline at end of file
}
......@@ -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.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._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import java.io.File
object BammetricsReportPage {
def alignmentSummaryValues(summary: SummaryDb,
runId: Int,
......@@ -99,7 +103,8 @@ object BammetricsReportPage {
else None
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(
"clippingPlotTables" -> clippingPlotTables,
"clippingTableResults" -> clippingTableResults,
......@@ -117,7 +122,8 @@ object BammetricsReportPage {
allLibraries: Seq[Library],
sampleId: 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,
showPlot: Boolean = false,
showIntro: Boolean = true,
......@@ -133,7 +139,11 @@ object BammetricsReportPage {
else None
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(
"insertSizePlotTables" -> insertSizePlotTables,
"insertSizeTableResults" -> insertSizeTableResults,
......@@ -145,16 +155,19 @@ object BammetricsReportPage {
)
}
def rnaHistogramValues(summary: SummaryDb,
runId: Int,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int],
libId: Option[Int],
fields: List[String] = List("PF_ALIGNED_BASES", "MEDIAN_5PRIME_BIAS", "MEDIAN_3PRIME_BIAS", "MEDIAN_5PRIME_TO_3PRIME_BIAS"),
sampleLevel: Boolean = false,
showPlot: Boolean = false,
showIntro: Boolean = true,
showTable: Boolean = true): Map[String, Any] = {
runId: Int,
allSamples: Seq[Sample],
allLibraries: Seq[Library],
sampleId: Option[Int],
libId: Option[Int],
fields: List[String] = List("PF_ALIGNED_BASES",
"MEDIAN_5PRIME_BIAS",
"MEDIAN_3PRIME_BIAS",
"MEDIAN_5PRIME_TO_3PRIME_BIAS"),
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
......@@ -166,7 +179,8 @@ object BammetricsReportPage {
else None
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(
"rnaHistogramPlotTables" -> rnaHistogramPlotTables,
"rnaHistogramTableResults" -> rnaHistogramTableResults,
......@@ -183,7 +197,20 @@ object BammetricsReportPage {
allLibraries: Seq[Library],
sampleId: 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,
showPlot: Boolean = false,
showIntro: Boolean = true,
......@@ -199,7 +226,8 @@ object BammetricsReportPage {
else None
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(
"wgsHistogramPlotTables" -> wgsHistogramPlotTables,
"wgsHistogramTableResults" -> wgsHistogramTableResults,
......@@ -210,5 +238,41 @@ object BammetricsReportPage {
"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 {
/** Index page for a flexiprep report */
def indexPage: Future[ReportPage] = {
val flexiprepPageSummaries = this.flexiprepPageSummaries(summary, sampleId.get, libId.get)
this.flexiprepPage(flexiprepPageSummaries).map {
page =>
ReportPage(
Nil,
List(
"Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepFront.ssp")
) ::: page.sections,
Map())
}}
this.flexiprepPage(flexiprepPageSummaries).map { page =>
ReportPage(
Nil,
List(
"Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepFront.ssp")
) ::: page.sections,
Map())
}
}
/** Generate a QC report page for 1 single library, sampleId and libId must be defined in the arguments */
def flexiprepPageSummaries(summary: SummaryDb,
sampleId: Int,
libId: Int): Map[String, Map[String, Any]] = {
sampleId: Int,
libId: Int): Map[String, Map[String, Any]] = {
val flexiprepReadSummary: Map[String, Any] = FlexiprepReadSummary.values(summary,
runId,
samples,
libraries,
sampleId,
libId,
multisample = false)
val flexiprepBaseSummary: Map[String,Any] = FlexiprepBaseSummary.values(summary,
runId,
samples,
libraries,
sampleId,
libId,
multisample = false)
runId,
samples,
libraries,
sampleId,
libId,
multisample = false)
val flexiprepBaseSummary: Map[String, Any] = FlexiprepBaseSummary.values(summary,
runId,
samples,
libraries,
sampleId,
libId,
multisample = false)
Map("flexiprepReadSummary" -> flexiprepReadSummary,
"flexiprepBaseSummary" -> flexiprepBaseSummary
)
"flexiprepBaseSummary" -> flexiprepBaseSummary)
}
def flexiprepPage(summaries: Map[String, Map[String, Any]]): Future[ReportPage] = {
......
......@@ -345,10 +345,10 @@ object GearsReport extends MultisampleReportBuilder {
val flexiprepReportPage =
if (flexiprepExecuted) {
val flexiprepPageSummaries = FlexiprepReport.flexiprepPageSummaries(summary,sampleId,libId)
val flexiprepPageSummaries =
FlexiprepReport.flexiprepPageSummaries(summary, sampleId, libId)
Some("QC" -> FlexiprepReport.flexiprepPage(flexiprepPageSummaries))
}
else None
} else None
val centrifugePageAllMappingsKronaPlot = GearsKronaPlot.values(summary,
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