alignmentSummary.ssp 2.82 KB
Newer Older
1 2
#import(nl.lumc.sasc.biopet.core.summary.Summary)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
3 4
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
5 6 7 8 9
<%@ var summary: Summary %>
<%@ var sampleId: Option[String] = None %>
<%@ var libId: Option[String] = None %>
<%@ var sampleLevel: Boolean = false %>
<%@ var rootPath: String %>
10 11 12
<%@ var outputDir: File %>
<%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %>
13 14
#{
    val samples = sampleId match {
15 16 17 18
        case Some(sample) => {
            List(sample.toString)
        }
        case _ => summary.samples.toList
19 20
    }
}#
21 22 23 24 25 26 27

#if (showPlot)
#{ BammetricsReport.alignmentSummaryPlot(outputDir, "alignmentSummary", summary, !sampleLevel, sampleId = sampleId) }#
    <img src="alignmentSummary.png"><br>
    <a href="alignmentSummary.tsv">Tsv file</a>
#end
#if (showTable)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
<table>
    <thead><tr>
        <th>Sample</th>
        #if (!sampleLevel) <th>Library</th> #end
        <th>Total</th>
        <th>Mapped</th>
        <th>(%)</th>
        <th>Duplicates</th>
        <th>(%)</th>
        <th>Insert size</th>
    </tr></thead>
    <tbody>
        #for (sample <- samples.toList.sorted)
            #{
                val libs = (libId, sampleLevel) match {
                    case (_, true) => List("")
                    case (Some(libId), _) => List(libId.toString)
                    case _ => summary.libraries(sample).toList
                }
            }#
            <tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample}/index.html">${sample}</a></td>
            #for (libId <- libs)
                #if (libs.head != libId) <tr> #end
                #if (!sampleLevel) <td><a href="${rootPath}Samples/${sample}/Libraries/${libId}/index.html">${libId}</a></td> #end
                #{
                    val prefixPath = List("samples", sample) ::: (if (libId.isEmpty) Nil else List("libraries", libId)) ::: List("bammetrics", "stats")
                    val total = summary.getValue((prefixPath ::: List("biopet_flagstat", "All")):_*).getOrElse(0L).asInstanceOf[Long]
                    val mapped = summary.getValue((prefixPath ::: List("biopet_flagstat", "Mapped")):_*).getOrElse(0L).asInstanceOf[Long]
                    val duplicates = summary.getValue((prefixPath ::: List("biopet_flagstat", "Duplicates")):_*).getOrElse(0L).asInstanceOf[Long]
                    val insertsizeMean = summary.getValue((prefixPath ::: List("insert_size_metrics", "mean_insert_size")):_*)
                }#
                <td>${total}</td>
                <td>${mapped}</td>
                <td>${mapped.toDouble / total * 100}%</td>
                <td>${duplicates}</td>
                <td>${duplicates.toDouble / total * 100}%</td>
                <td>${insertsizeMean}</td>
                </tr>
            #end
        #end
    </tbody>
69 70
</table>
#end