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

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