alignmentSummary.ssp 6.31 KB
Newer Older
1
#import(nl.lumc.sasc.biopet.utils.summary.Summary)
2
#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 %>
Peter van 't Hof's avatar
Peter van 't Hof committed
13
<%@ var showIntro: Boolean = true%>
14 15
#{
    val samples = sampleId match {
16 17 18 19
        case Some(sample) => {
            List(sample.toString)
        }
        case _ => summary.samples.toList
20 21
    }
}#
Peter van 't Hof's avatar
Peter van 't Hof committed
22 23 24 25 26 27
#if (showIntro)
    <br/>
    <div class="row">
    <div class="col-md-1"></div>
    <div class="col-md-6">
        <p>
Sander Bollen's avatar
Sander Bollen committed
28 29
        #if (sampleId.isDefined && libId.isDefined)
            Here we show basic <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Alignment">alignment</a> statistics for this run for sample ${sampleId} with library ${libId}. Total number of reads, number of alignments reads and number of duplicate reads are given, and the percentages thereof as a percentage of total.
Sander Bollen's avatar
Sander Bollen committed
30
        #elseif(sampleId.isDefined && showPlot)
31
            The following plot shows basic <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Alignment">alignment</a> statistics for this run for sample ${sampleId}. Every library is represented by a multi-color bar. Red represents the total number of properly mapped reads for this sample. Green represents the total number of duplicates reads, which is usually caused by <a href="http://www.cureffi.org/2012/12/11/how-pcr-duplicates-arise-in-next-generation-sequencing/">PCR duplicates</a>. Blue denotes the number of unmapped reads, and purple denotes reads flagged <em>secondary</em> (this depends on the aligner used). A table showing similar statistics, including values represented as percent of total, can be downloaded as a tab-delimited file.
Sander Bollen's avatar
Sander Bollen committed
32 33
        #elseif(sampleId.isDefined && !showPlot)
            Here we show basic <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Alignment">alignment</a> statistics for this run for every library of sample ${sampleId}. Total number of reads, number of alignments reads and number of duplicate reads are given, and the percentages thereof as a percentage of total.
Sander Bollen's avatar
Sander Bollen committed
34 35 36
        #else
            The following plot shows basic <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Alignment">alignment</a> statistics for this run. Every sample is represented by a multi-color bar. Red represents the total number of properly mapped reads for this sample. Green represents the total number of duplicates reads, which is usually caused by <a href="http://www.cureffi.org/2012/12/11/how-pcr-duplicates-arise-in-next-generation-sequencing/">PCR duplicates</a>. Blue denotes the number of unmapped reads, and purple denotes reads flagged <em>secondary</em> (this is dependent on the aligner used). A table showing similar statistics, including values represented as percent of total, can be downloaded as a tab-delimited file.
        #end
Peter van 't Hof's avatar
Peter van 't Hof committed
37 38 39 40
        </p>
    </div>
    </div>
#end
41 42
#if (showPlot)
#{ BammetricsReport.alignmentSummaryPlot(outputDir, "alignmentSummary", summary, !sampleLevel, sampleId = sampleId) }#
43 44 45 46 47

    <div class="panel-body">
        <img src="alignmentSummary.png" class="img-responsive" />
    </div>
        <div class="panel-footer">
Peter van 't Hof's avatar
Peter van 't Hof committed
48
            #if (showTable)
49 50
                <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#alignmentSummaryTable">
                <i class="glyphicon glyphicon-eye-close"></i> Hide table</button>
Peter van 't Hof's avatar
Peter van 't Hof committed
51
            #else
52 53
                <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#alignmentSummaryTable">
                <i class="glyphicon glyphicon-eye-open"></i> Show table</button>
Peter van 't Hof's avatar
Peter van 't Hof committed
54
            #end
55
            <a href="alignmentSummary.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i> TSV file</button></a>
56
        </div>
57
#end
Peter van 't Hof's avatar
Peter van 't Hof committed
58 59
<div class="panel-body collapse #if (showTable)in#end" id="alignmentSummaryTable">
<!-- Table -->
60
<table class="table">
Peter van 't Hof's avatar
Peter van 't Hof committed
61 62 63 64 65
    <thead><tr>
        <th data-sorted="true" data-sorted-direction="ascending">Sample</th>
        #if (!sampleLevel) <th>Library</th> #end
        <th>Total</th>
        <th>Mapped</th>
66
        <th>Secondary</th>
Peter van 't Hof's avatar
Peter van 't Hof committed
67 68 69 70 71 72 73 74 75
        <th>(%)</th>
        <th>Duplicates</th>
        <th>(%)</th>
    </tr></thead>
    <tbody>
        #for (sample <- samples.toList.sorted)
            #{
                val libs = (libId, sampleLevel) match {
                case (_, true) => List("")
76 77
                case (Some(libId), _) => List(libId.toString).sorted
                case _ => summary.libraries(sample).toList.sorted
Peter van 't Hof's avatar
Peter van 't Hof committed
78 79 80 81 82 83 84 85 86 87 88
                }
            }#
            <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]
89
                        val secondary = summary.getValue((prefixPath ::: List("biopet_flagstat", "NotPrimaryAlignment")):_*).getOrElse(0L).asInstanceOf[Long]
Peter van 't Hof's avatar
Peter van 't Hof committed
90 91 92
                    }#
                    <td>${total}</td>
                    <td>${mapped}</td>
93 94
                    <td>${secondary}</td>
                    <td>${(mapped - secondary).toDouble / (total - secondary) * 100}%</td>
Peter van 't Hof's avatar
Peter van 't Hof committed
95
                    <td>${duplicates}</td>
96
                    <td>${duplicates.toDouble / (total - secondary) * 100}%</td>
Peter van 't Hof's avatar
Peter van 't Hof committed
97
                </tr>
98
            #end
Peter van 't Hof's avatar
Peter van 't Hof committed
99 100 101
        #end
    </tbody>
</table>
102

Peter van 't Hof's avatar
Peter van 't Hof committed
103
</div>