flexiprepBaseSummary.ssp 8.78 KB
Newer Older
1 2 3 4
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
5
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
6 7
#import(nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport)
#import(java.io.File)
8 9 10 11
<%@ var summary: SummaryDb %>
<%@ var runId: Int %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
12
<%@ var rootPath: String %>
13 14 15
<%@ var outputDir: File %>
<%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %>
Peter van 't Hof's avatar
Peter van 't Hof committed
16
<%@ var showIntro: Boolean = true %>
Peter van 't Hof's avatar
Peter van 't Hof committed
17
<%@ var multisample: Boolean = true %>
18
#{
19 20 21 22 23 24 25 26 27 28 29
    val samples = Await.result(summary.getSamples(runId = Some(runId), sampleId = sampleId), Duration.Inf)
    val libraries = Await.result(summary.getLibraries(runId = Some(runId), sampleId = sampleId), Duration.Inf)
    val settings = summary.getSettingsForLibraries(runId, Right("flexiprep"), keyValues = Map(
    "skip_trim" -> List("skip_trim"), "skip_clip" -> List("skip_clip"), "paired" -> List("paired")))
    settings.count(_._2.getOrElse("skip_trim", None) == Some(true))
    val trimCount = settings.count(_._2.getOrElse("skip_trim", None) == Some(true))
    val clipCount = settings.count(_._2.getOrElse("skip_clip", None) == Some(true))
    val librariesCount = libraries.size

    val paired: Boolean = if (sampleId.isDefined && libId.isDefined)
    summary.getSettingKeys(runId, Right("flexiprep"), None, sampleId.map(Left(_)), libId.map(Left(_)), keyValues = Map("paired" -> List("paired"))).getOrElse("paired", None) == Some(true)
Peter van 't Hof's avatar
Peter van 't Hof committed
30
    else settings.count(_._2.getOrElse("paired", None) == Some(true)) >= 1
31
}#
Peter van 't Hof's avatar
Peter van 't Hof committed
32 33 34 35 36 37
#if (showIntro)
    <br/>
    <div class="row">
    <div class="col-md-1"></div>
    <div class="col-md-6">
        <p>
Peter van 't Hof's avatar
Peter van 't Hof committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
            #if (trimCount == librariesCount && clipCount == librariesCount)
                You have selected both <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Pre-processing#Alternative_clipping_strategies_.28Adaptor_clipping.29">adaptor clipping</a> and <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Pre-processing#Sequence_Quality_Trimming">read trimming</a> as pre-processing steps
            #elseif (trimCount == librariesCount && clipCount == 0)
                You have selected only <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Pre-processing#Sequence_Quality_Trimming">read trimming</a> as pre-processing step
            #elseif (trimCount == 0 && clipCount == librariesCount)
                You have selected only <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Pre-processing#Alternative_clipping_strategies_.28Adaptor_clipping.29">adaptor clipping</a> as pre-processing step
            #elseif (trimCount == 0 && clipCount == 0)
                You have selected no pre-processing step to be performed
            #elseif (trimCount > 0 && clipCount == 0)
                You have selected <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Pre-processing#Alternative_clipping_strategies_.28Adaptor_clipping.29">adaptor clipping</a> as pre-processing steps
            #elseif (trimCount == 0 && clipCount > 0)
                You have chosen to turn <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Pre-processing#Alternative_clipping_strategies_.28Adaptor_clipping.29">adaptor clipping</a> for some libraries, but not all.
            #else
                You have chosen to turn <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Pre-processing#Alternative_clipping_strategies_.28Adaptor_clipping.29">adaptor clipping</a> and <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Pre-processing#Sequence_Quality_Trimming">read trimming</a> off for some libraries, but not all.
            #end
Sander Bollen's avatar
Sander Bollen committed
53 54
        </p>
        <p>
Peter van 't Hof's avatar
Peter van 't Hof committed
55
        #if (sampleId.isDefined && libId.isDefined)
Sander Bollen's avatar
Sander Bollen committed
56
            Here we show aggregated quality statistics sequencing library ${libId} for sample ${sampleId}. It shows the total number of bases used after quality control, and the total number of bases discarded during quality control. This is done for both forward and reverse reads.
Peter van 't Hof's avatar
Peter van 't Hof committed
57
        #elseif (sampleId.isDefined)
Sander Bollen's avatar
Sander Bollen committed
58 59
            Here we show aggregated quality statistics for every sequencing library for sample ${sampleId}. It shows the total number of bases used after quality control, and the total number of bases discarded during quality control. This is done for both forward and reverse reads.
        #else
Sander Bollen's avatar
Sander Bollen committed
60
            Here we show aggregated quality statistics for every sequencing library. It shows the total number of bases used after quality control, and the total number of bases discarded during quality control. This is done for both forward and reverse reads.
Sander Bollen's avatar
Sander Bollen committed
61
        #end
Peter van 't Hof's avatar
Peter van 't Hof committed
62 63 64 65
        </p>
    </div>
    </div>
#end
66 67 68
#if (showPlot)
    #{
        FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R1","R1", summary, sampleId = sampleId)
69
        if (paired) FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R2","R2", summary, sampleId = sampleId)
70
    }#
71 72 73 74 75
    <div class="panel-body">
        <div class="row">
            <div class="col-sm-6 col-md-6">
                <img src="QC_Bases_R1.png" class="img-responsive" />
            </div>
76 77
            #if (paired)
                <div class="col-sm-6 col-md-6">
78
                <img src="QC_Bases_R2.png" class="img-responsive" />
79 80
                </div>
            #end
81 82 83 84
        </div>

    </div>
    <div class="panel-footer">
Peter van 't Hof's avatar
Peter van 't Hof committed
85
        #if (showTable)
Peter van 't Hof's avatar
Peter van 't Hof committed
86 87
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#QC_BasesTable">Hide table</button>
        #else
Peter van 't Hof's avatar
Peter van 't Hof committed
88 89
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#QC_BasesTable">Show table</button>
        #end
90 91

        <a href="QC_Bases_R1.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i> R1 base stats</button></a>
92
        #if (paired)
93
        <a href="QC_Bases_R2.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i> R2 base stats</button></a>
94
        #end
95
    </div>
96
#end
97

Peter van 't Hof's avatar
Peter van 't Hof committed
98
<div class="panel-body collapse #if (showTable)in#end" id="QC_BasesTable">
99

Peter van 't Hof's avatar
Peter van 't Hof committed
100
<!-- Table -->
Peter van 't Hof's avatar
Peter van 't Hof committed
101
<table class="table sortable-theme-bootstrap">
102

Peter van 't Hof's avatar
Peter van 't Hof committed
103
    <thead><tr>
Peter van 't Hof's avatar
Peter van 't Hof committed
104
        <th>Sample</th>
Peter van 't Hof's avatar
Peter van 't Hof committed
105 106 107 108 109 110 111
        <th colspan="2">Library</th>
        <th>Before QC</th>
        <th>Discarded</th>
        <th>(%)</th>
        <th>After QC</th>
    </tr></thead>
    <tbody>
112
        #for (sample <- samples.sortBy(_.name))
Peter van 't Hof's avatar
Peter van 't Hof committed
113 114
            #{
                val sampleRowspan = {
115 116
                libraries.filter(_.sampleId == sample.id).size +
                settings.filter(_._1._1 == sample.id).count(_._2("paired").getOrElse(false) == true)
Peter van 't Hof's avatar
Peter van 't Hof committed
117 118
                }
            }#
Peter van 't Hof's avatar
Peter van 't Hof committed
119 120
            <tr><td rowspan="${sampleRowspan}">
            #if (multisample)
121
                <a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a>
Peter van 't Hof's avatar
Peter van 't Hof committed
122 123 124 125
            #else
                ${sample}
            #end
            </td>
126
            #for (lib <- libraries.filter(_.sampleId == sample.id))
Peter van 't Hof's avatar
Peter van 't Hof committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
                #{ val paired = settings.filter(_._1._1 == sample.id).filter(_._1._2 == lib.id).head._2("paired") == Some(true) }#
                <td #if (paired == true) rowspan="2" #end>
                #if (multisample)
                    <a href="${rootPath}Samples/${sample.name}/Libraries/${lib.name}/index.html">${lib.name}</a>
                #else
                    ${lib.name}
                #end
                </td>
                #{ val reads = if (paired == true) List("R1", "R2") else List("R1") }#
                #for (read <- reads)
                    #if (read == "R2") </tr><tr> #end
                    #{
                        val statsPaths = Map("num_total" -> List("bases", "num_total"))
                        val seqstatStats = summary.getStatKeys(runId, Right("flexiprep"), Some(Right("seqstat_" + read)), sample = Some(Left(sample.id)), library = Some(Left(lib.id)), keyValues = statsPaths)
                        val seqstatQcStats = summary.getStatKeys(runId, Right("flexiprep"), Some(Right("seqstat_" + read + "_qc")), sample = Some(Left(sample.id)), library = Some(Left(lib.id)), keyValues = statsPaths)
142

Peter van 't Hof's avatar
Peter van 't Hof committed
143 144 145 146 147 148 149 150 151
                        val beforeTotal = seqstatStats("num_total").getOrElse(0).toString.toLong
                        val afterTotal = seqstatQcStats("num_total").getOrElse(0).toString.toLong
                    }#
                    <td>${read}</td>
                    <td>${beforeTotal}</td>
                    <td>${beforeTotal - afterTotal}</td>
                    <td>${(beforeTotal - afterTotal).toDouble / beforeTotal * 100}%</td>
                    <td>${afterTotal}</td>
                #end
Peter van 't Hof's avatar
Peter van 't Hof committed
152
                </tr>
153
            #end
Peter van 't Hof's avatar
Peter van 't Hof committed
154 155 156
        #end
    </tbody>
</table>
157

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