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

Added single sample coverage plot

parent a03a1b88
#import(nl.lumc.sasc.biopet.utils.IoUtils)
#import(nl.lumc.sasc.biopet.core.summary.Summary)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(org.apache.commons.io.FileUtils)
#import(java.io.File)
<%@ var summary: Summary %>
<%@ var sampleId: Option[String] %>
<%@ var libId: Option[String] = None %>
<%@ var outputDir: File %>
<%@ var target: String %>
#{
val originalPlot = new File(summary.getLibraryValue(sampleId, libId, "bammetrics", "files", target + "_cov_stats", "plot", "path")
.getOrElse(throw new IllegalArgumentException("No plot found in summary")).toString)
val plot = new File(outputDir, target + "_cov_stats.png")
IoUtils.copyFile(originalPlot, plot)
}#
<img src="${plot}">
......@@ -14,26 +14,32 @@ object BammetricsReport extends ReportBuilder {
val reportName = "Bam Metrics"
def indexPage = ReportPage(Map(
"Bam Metrics" -> bamMetricsPage
), List(
"Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/bamMetricsFront.ssp")
),
Map()
)
def bamMetricsPage = ReportPage(
Map(),
List(
"Summary" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"),
"Bam Stats" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/bamStats.ssp"),
"Insert Size" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/insertSize.ssp", Map("showPlot" -> true)),
"RNA (optional)" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/rna.ssp"),
"Target (optional)" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/target.ssp"),
"GC Bias" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/gcBias.ssp")
),
Map()
)
def indexPage = ReportPage(Map(), List(), Map())
def bamMetricsPage(summary:Summary, sampleId: Option[String], libId: Option[String]) = {
val targets = (
summary.getLibraryValue(sampleId, libId, "bammetrics", "settings", "amplicon_name"),
summary.getLibraryValue(sampleId, libId, "bammetrics", "settings", "roi_name")
) match {
case (Some(amplicon:String), Some(roi:List[_])) => amplicon :: roi.map(_.toString)
case (_, Some(roi:List[_])) => roi.map(_.toString)
case _ => Nil
}
ReportPage(
(if (targets.isEmpty) Map() else Map("Targets" -> ReportPage(
Map(),
targets.map(t => (t -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/covstatsPlot.ssp", Map("target" -> t)))),
Map()))),
List(
"Summary" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"),
"Bam Stats" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/bamStats.ssp"),
"Insert Size" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/insertSize.ssp", Map("showPlot" -> true))
),
Map()
)
}
def alignmentSummaryPlot(outputDir: File,
prefix: String,
......@@ -168,6 +174,5 @@ object BammetricsReport extends ReportBuilder {
plot.removeZero = true
plot.title = Some("Insert size")
plot.runLocal()
}
}
......@@ -12,7 +12,7 @@ trait MultisampleReportBuilder extends ReportBuilder {
)
}
def libraryPage(libraryId: String, args: Map[String, Any]): ReportPage
def libraryPage(sampleId:String, libraryId: String, args: Map[String, Any]): ReportPage
def libririesSections: List[(String, ReportSection)] = {
List(
......@@ -28,11 +28,13 @@ trait MultisampleReportBuilder extends ReportBuilder {
}
def generateLibraryPage(args: Map[String, Any]): ReportPage = {
val libPages = summary.libraries(args("sampleId") match {
val sampleId = args("sampleId") match {
case Some(x) => x.toString
case None => throw new IllegalStateException("Sample not found")
})
.map(libId => (libId -> libraryPage(libId, args ++ Map("libId" -> Some(libId)))))
}
val libPages = summary.libraries(sampleId)
.map(libId => (libId -> libraryPage(sampleId, libId, args ++ Map("libId" -> Some(libId)))))
.toMap
ReportPage(libPages, libririesSections, args)
}
......
......@@ -86,7 +86,7 @@ object ShivaReport extends MultisampleReportBuilder {
def samplePage(sampleId: String, args: Map[String, Any]) = {
ReportPage(Map(
"Libraries" -> generateLibraryPage(args),
"Alignment" -> BammetricsReport.bamMetricsPage,
"Alignment" -> BammetricsReport.bamMetricsPage(summary, Some(sampleId), None),
"Files" -> filesPage
), List(
"Alignment" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp",
......@@ -98,9 +98,9 @@ object ShivaReport extends MultisampleReportBuilder {
), args)
}
def libraryPage(libId: String, args: Map[String, Any]) = {
def libraryPage(sampleId:String, libId: String, args: Map[String, Any]) = {
ReportPage(Map(
"Alignment" -> BammetricsReport.bamMetricsPage,
"Alignment" -> BammetricsReport.bamMetricsPage(summary, Some(sampleId), Some(libId)),
"QC" -> FlexiprepReport.flexiprepPage
), List(
"Alignment" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp"),
......
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