flexiprepBaseSummary.ssp 8.81 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)
Peter van 't Hof's avatar
Peter van 't Hof committed
8
9
#import(scalaz._)
#import(Scalaz._)
10
11
12
13
<%@ var summary: SummaryDb %>
<%@ var runId: Int %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
14
<%@ var rootPath: String %>
15
16
17
<%@ var outputDir: File %>
<%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %>
Peter van 't Hof's avatar
Peter van 't Hof committed
18
<%@ var showIntro: Boolean = true %>
Peter van 't Hof's avatar
Peter van 't Hof committed
19
<%@ var multisample: Boolean = true %>
20
#{
21
22
    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)
Peter van 't Hof's avatar
Peter van 't Hof committed
23
    val settings = summary.getSettingsForLibraries(runId, "flexiprep".right, keyValues = Map(
24
25
26
27
28
29
30
    "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)
Peter van 't Hof's avatar
Peter van 't Hof committed
31
    summary.getSettingKeys(runId, "flexiprep".right, 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
32
    else settings.count(_._2.getOrElse("paired", None) == Some(true)) >= 1
33
}#
Peter van 't Hof's avatar
Peter van 't Hof committed
34
35
36
37
38
39
#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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
            #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
55
56
        </p>
        <p>
Peter van 't Hof's avatar
Peter van 't Hof committed
57
        #if (sampleId.isDefined && libId.isDefined)
Sander Bollen's avatar
Sander Bollen committed
58
            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
59
        #elseif (sampleId.isDefined)
Sander Bollen's avatar
Sander Bollen committed
60
61
            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
62
            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
63
        #end
Peter van 't Hof's avatar
Peter van 't Hof committed
64
65
66
67
        </p>
    </div>
    </div>
#end
68
69
70
#if (showPlot)
    #{
        FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R1","R1", summary, sampleId = sampleId)
71
        if (paired) FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R2","R2", summary, sampleId = sampleId)
72
    }#
73
74
75
76
77
    <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>
78
79
            #if (paired)
                <div class="col-sm-6 col-md-6">
80
                <img src="QC_Bases_R2.png" class="img-responsive" />
81
82
                </div>
            #end
83
84
85
86
        </div>

    </div>
    <div class="panel-footer">
Peter van 't Hof's avatar
Peter van 't Hof committed
87
        #if (showTable)
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">Hide table</button>
        #else
Peter van 't Hof's avatar
Peter van 't Hof committed
90
91
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#QC_BasesTable">Show table</button>
        #end
92
93

        <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>
94
        #if (paired)
95
        <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>
96
        #end
97
    </div>
98
#end
99

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

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

Peter van 't Hof's avatar
Peter van 't Hof committed
105
    <thead><tr>
Peter van 't Hof's avatar
Peter van 't Hof committed
106
        <th>Sample</th>
Peter van 't Hof's avatar
Peter van 't Hof committed
107
108
109
110
111
112
113
        <th colspan="2">Library</th>
        <th>Before QC</th>
        <th>Discarded</th>
        <th>(%)</th>
        <th>After QC</th>
    </tr></thead>
    <tbody>
114
        #for (sample <- samples.sortBy(_.name))
Peter van 't Hof's avatar
Peter van 't Hof committed
115
116
            #{
                val sampleRowspan = {
Peter van 't Hof's avatar
Peter van 't Hof committed
117
118
                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
119
120
                }
            }#
Peter van 't Hof's avatar
Peter van 't Hof committed
121
122
            <tr><td rowspan="${sampleRowspan}">
            #if (multisample)
123
                <a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a>
Peter van 't Hof's avatar
Peter van 't Hof committed
124
125
126
127
            #else
                ${sample}
            #end
            </td>
128
            #for (lib <- libraries.filter(_.sampleId == sample.id))
Peter van 't Hof's avatar
Peter van 't Hof committed
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"))
Peter van 't Hof's avatar
Peter van 't Hof committed
142
143
                        val seqstatStats = summary.getStatKeys(runId, "flexiprep".right, Some(("seqstat_" + read).right), sample = Some(sample.id.left), library = Some(lib.id.left), keyValues = statsPaths)
                        val seqstatQcStats = summary.getStatKeys(runId, "flexiprep".right, Some(("seqstat_" + read + "_qc").right), sample = Some(sample.id.left), library = Some(lib.id.left), keyValues = statsPaths)
144

Peter van 't Hof's avatar
Peter van 't Hof committed
145
146
147
148
149
150
151
152
153
                        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
154
                </tr>
155
            #end
Peter van 't Hof's avatar
Peter van 't Hof committed
156
157
158
        #end
    </tbody>
</table>
159

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