flexiprepReadSummary.ssp 8.94 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
2
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Sample)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Library)
3
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
4
#import(java.io.File)
5
6
7
8
#import(nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport)
<%@ var runId: Int %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
9
<%@ 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 %>
Peter van 't Hof's avatar
Peter van 't Hof committed
14
<%@ var multisample: Boolean = true %>
Peter van 't Hof's avatar
Peter van 't Hof committed
15
16
<%@ var allSamples: Seq[Sample] %>
<%@ var allLibraries: Seq[Library] %>
17
18
19
<%-- variables to be added to remove dependency upon futures --%>
<%@ var settings: Map[(Int, Int), Map[String, Option[Any]]] %>
<%@ var paired: Boolean %>
20
21
22
23
24
<%@ var samples: Seq[Sample] %>
<%@ var libraries: Seq[Library] %>
<%@ var librariesCount: Int %>
<%@ var clipCount: Int %>
<%@ var trimCount: Int %>
Ruben Vorderman's avatar
Ruben Vorderman committed
25
26
27
28
<%@ var seqstatStats: Map[(Int, Int), Map[String, Option[Any]]] %>
<%@ var seqstatQCStats: Map[(Int, Int), Map[String, Option[Any]]] %>
<%@ var clippingStats: Map[(Int, Int), Map[String, Option[Any]]] %>
<%@ var trimmingStats: Map[(Int, Int), Map[String, Option[Any]]] %>
29
30
<%@ var summaryPlotLinesR1: Seq[String] %>
<%@ var summaryPlotLinesR2: Seq[String] %>
31

32
#if (showIntro)
Peter van 't Hof's avatar
Peter van 't Hof committed
33
34
35
36
37
    <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
            #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)
akaljuvee's avatar
akaljuvee committed
47
                You have chosen to perform <a href="https://en.wikibooks.org/wiki/Next_Generation_Sequencing_%28NGS%29/Pre-processing#Sequence_Quality_Trimming">read trimming</a> for some libraries, but not all.
Peter van 't Hof's avatar
Peter van 't Hof committed
48
49
50
51
52
            #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>
Wai Yi Leung's avatar
Wai Yi Leung committed
55
56
57
58
59
60
61
62
63
64
65
            #if(sampleId.isDefined && libId.isDefined)
                Here we show aggregated quality statistics for sequencing library ${libId} for sample ${sampleId}. It shows the total number of reads used after quality control, and the total number of reads discarded during quality control. This is done for both forward and reverse reads.
            #elseif(sampleId.isDefined)
                Here we show aggregated quality statistics for every sequencing library for sample ${sampleId}. It shows the total number of reads used after quality control, and the total number of reads discarded during quality control. This is done for both forward and reverse reads.
            #else
                Here we show aggregated quality statistics for every sequencing library. It shows the total number of reads used after quality control, and the total number of reads discarded during quality control. This is done for both forward and reverse reads.
                We show two plots; one for the forward read in the pair, and another one of the reverse read in the pair.
                Red denotes number of reads left after QC. Green denotes reads filtered by adaptor clipping.
                Blue denotes number of reads filtered by read trimming.
                Purple denotes the amount of <em>synced</em> reads. That is, reads removed in one orientation should be removed in the other as well to ensure correctness.
            #end
Peter van 't Hof's avatar
Peter van 't Hof committed
66
67
68
69
        </p>
    </div>
    </div>
#end
70
71

#if (showPlot)
72
    #{
73
74
        FlexiprepReport.readSummaryPlot(outputDir, "QC_Reads_R1","R1", summaryPlotLinesR1)
        if (paired) FlexiprepReport.readSummaryPlot(outputDir, "QC_Reads_R2","R2", summaryPlotLinesR2)
75
    }#
76
    <div class="panel-body">
Wai Yi Leung's avatar
Wai Yi Leung committed
77
    <div class="row">
Wai Yi Leung's avatar
Wai Yi Leung committed
78
79
80
        <div class="col-sm-6 col-md-6">
            <img src="QC_Reads_R1.png" class="img-responsive">
        </div>
81
        #if (paired)
Wai Yi Leung's avatar
Wai Yi Leung committed
82
83
        <div class="col-sm-6 col-md-6">
            <img src="QC_Reads_R2.png" class="img-responsive">
84
        </div>
Wai Yi Leung's avatar
Wai Yi Leung committed
85
        #end
Wai Yi Leung's avatar
Wai Yi Leung committed
86
    </div>
87
88
89

    </div>
    <div class="panel-footer">
Wai Yi Leung's avatar
Wai Yi Leung committed
90
91
92
93
94
    #if (showTable)
        <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#QC_ReadsTable">Hide table</button>
    #else
        <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#QC_ReadsTable">Show table</button>
    #end
95

Wai Yi Leung's avatar
Wai Yi Leung committed
96
    <a href="QC_Reads_R1.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i> R1 reads stats</button></a>
Wai Yi Leung's avatar
Wai Yi Leung committed
97
    #if (paired)
Wai Yi Leung's avatar
Wai Yi Leung committed
98
    <a href="QC_Reads_R2.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i> R2 reads stats</button></a>
Wai Yi Leung's avatar
Wai Yi Leung committed
99
    #end
100
    </div>
101
#end
102

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

Peter van 't Hof's avatar
Peter van 't Hof committed
105
<!-- Table -->
Peter van 't Hof's avatar
Peter van 't Hof committed
106
<table class="table sortable-theme-bootstrap">
Peter van 't Hof's avatar
Peter van 't Hof committed
107
    <thead><tr>
Peter van 't Hof's avatar
Peter van 't Hof committed
108
        <th>Sample</th>
Peter van 't Hof's avatar
Peter van 't Hof committed
109
110
111
112
        <th colspan="2">Library</th>
        <th>Before QC</th>
        <th>Clipping</th>
        <th>Trimming</th>
Peter van 't Hof's avatar
Peter van 't Hof committed
113
        #if (paired == true) <th>Out of Sync</th> #end
Peter van 't Hof's avatar
Peter van 't Hof committed
114
115
116
        <th>After QC</th>
    </tr></thead>
    <tbody>
117
        #for (sample <- samples.sortBy(_.name))
Peter van 't Hof's avatar
Peter van 't Hof committed
118
119
            #{
                val sampleRowspan = {
Peter van 't Hof's avatar
Peter van 't Hof committed
120
                libraries.filter(_.sampleId == sample.id).size +
Ruben Vorderman's avatar
Ruben Vorderman committed
121
                settings.filter(_._1._1 == sample.id).count(_._2("paired").getOrElse(false) == true)
Peter van 't Hof's avatar
Peter van 't Hof committed
122
123
                }
            }#
Peter van 't Hof's avatar
Peter van 't Hof committed
124
125
            <tr><td rowspan="${sampleRowspan}">
            #if (multisample)
126
                <a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a>
Peter van 't Hof's avatar
Peter van 't Hof committed
127
            #else
Peter van 't Hof's avatar
Peter van 't Hof committed
128
                ${sample.name}
Peter van 't Hof's avatar
Peter van 't Hof committed
129
130
            #end
            </td>
131
            #for (lib <- libraries.filter(_.sampleId == sample.id))
Peter van 't Hof's avatar
Peter van 't Hof committed
132
133
                #{ 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>
Ruben Vorderman's avatar
Ruben Vorderman committed
134
135
136
137
138
                    #if (multisample)
                        <a href="${rootPath}Samples/${sample.name}/Libraries/${lib.name}/index.html">${lib.name}</a>
                    #else
                        ${lib.name}
                    #end
Peter van 't Hof's avatar
Peter van 't Hof committed
139
                </td>
Ruben Vorderman's avatar
Ruben Vorderman committed
140
                #{ val reads = if (paired) List("R1", "R2") else List("R1") }#
Peter van 't Hof's avatar
Peter van 't Hof committed
141
142
143
                #for (read <- reads)
                    #if (read == "R2") </tr><tr> #end
                    #{
Ruben Vorderman's avatar
Ruben Vorderman committed
144
145
146
147
148
                        val beforeTotal = seqstatStats(sample.id,lib.id)("num_total").getOrElse(0).toString.toLong
                        val afterTotal = seqstatQCStats(sample.id,lib.id)("num_total").getOrElse(0).toString.toLong
                        val clippingDiscardedToShort = clippingStats(sample.id,lib.id)("num_reads_discarded_too_short").getOrElse(0).toString.toLong
                        val clippingDiscardedToLong = clippingStats(sample.id,lib.id)("num_reads_discarded_too_long").getOrElse(0).toString.toLong
                        val trimmingDiscarded = trimmingStats(sample.id,lib.id)("num_reads_discarded").getOrElse(0).toString.toLong
Peter van 't Hof's avatar
Peter van 't Hof committed
149
150
151
                    }#
                    <td>${read}</td>
                    <td>${beforeTotal}</td>
Ruben Vorderman's avatar
Ruben Vorderman committed
152
                    <td>${clippingDiscardedToShort + clippingDiscardedToLong}</td>
Peter van 't Hof's avatar
Peter van 't Hof committed
153
                    <td>${trimmingDiscarded}</td>
Ruben Vorderman's avatar
Ruben Vorderman committed
154
                    #if (paired == true) <td>${beforeTotal - clippingDiscardedToShort - clippingDiscardedToLong - trimmingDiscarded - afterTotal}</td> #end
Peter van 't Hof's avatar
Peter van 't Hof committed
155
156
                    <td>${afterTotal}</td>
                #end
Peter van 't Hof's avatar
Peter van 't Hof committed
157
158
159
160
                </tr>
            #end
        #end
    </tbody>
161

Peter van 't Hof's avatar
Peter van 't Hof committed
162
163
</table>
</div>