flexiprepBaseSummary.ssp 8.24 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.flexiprep.FlexiprepReport)
#import(java.io.File)
5 6 7
<%@ var summary: Summary %>
<%@ var sampleId: Option[String] = None %>
<%@ var libId: Option[String] = None %>
8
<%@ var rootPath: String %>
9 10 11
<%@ var outputDir: File %>
<%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %>
Peter van 't Hof's avatar
Peter van 't Hof committed
12
<%@ var showIntro: Boolean = true %>
Peter van 't Hof's avatar
Peter van 't Hof committed
13
<%@ var multisample: Boolean = true %>
14 15 16 17 18
#{
    val samples = sampleId match {
        case Some(sample) => List(sample.toString)
        case _ => summary.samples.toList
    }
Peter van 't Hof's avatar
Peter van 't Hof committed
19 20 21
    val trimCount = summary.getLibraryValues("flexiprep", "settings", "skip_trim").count(_._2 == Some(false))
    val clipCount = summary.getLibraryValues("flexiprep", "settings", "skip_clip").count(_._2 == Some(false))
    val librariesCount = summary.samples.foldLeft(0)(_ + summary.libraries(_).size)
22
}#
Peter van 't Hof's avatar
Peter van 't Hof committed
23 24 25 26 27 28
#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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
            #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
44 45
        </p>
        <p>
Peter van 't Hof's avatar
Peter van 't Hof committed
46
        #if (sampleId.isDefined && libId.isDefined)
Sander Bollen's avatar
Sander Bollen committed
47
            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
48
        #elseif (sampleId.isDefined)
Sander Bollen's avatar
Sander Bollen committed
49 50
            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
51
            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
52
        #end
Peter van 't Hof's avatar
Peter van 't Hof committed
53 54 55 56
        </p>
    </div>
    </div>
#end
57 58
#if (showPlot)
    #{
59 60 61
        val paired: Boolean = if (sampleId.isDefined && libId.isDefined)
            summary.getLibraryValue(sampleId.get, libId.get, "flexiprep", "settings", "paired").get.asInstanceOf[Boolean]
        else summary.getLibraryValues("flexiprep", "settings", "paired").values.exists(_ == Some(true))
62
        FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R1","R1", summary, sampleId = sampleId)
63
        if (paired) FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R2","R2", summary, sampleId = sampleId)
64
    }#
65 66 67 68 69
    <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>
70 71
            #if (paired)
                <div class="col-sm-6 col-md-6">
72
                <img src="QC_Bases_R2.png" class="img-responsive" />
73 74
                </div>
            #end
75 76 77 78
        </div>

    </div>
    <div class="panel-footer">
Peter van 't Hof's avatar
Peter van 't Hof committed
79
        #if (showTable)
Peter van 't Hof's avatar
Peter van 't Hof committed
80 81
            <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
82 83
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#QC_BasesTable">Show table</button>
        #end
84 85

        <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>
86
        #if (paired)
87
        <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>
88
        #end
89
    </div>
90
#end
91

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

Peter van 't Hof's avatar
Peter van 't Hof committed
94
<!-- Table -->
Peter van 't Hof's avatar
Peter van 't Hof committed
95
<table class="table sortable-theme-bootstrap">
96

Peter van 't Hof's avatar
Peter van 't Hof committed
97
    <thead><tr>
Peter van 't Hof's avatar
Peter van 't Hof committed
98
        <th>Sample</th>
Peter van 't Hof's avatar
Peter van 't Hof committed
99 100 101 102 103 104 105 106 107 108
        <th colspan="2">Library</th>
        <th>Before QC</th>
        <th>Discarded</th>
        <th>(%)</th>
        <th>After QC</th>
    </tr></thead>
    <tbody>
        #for (sample <- samples.toList.sorted)
            #{
                val libs = libId match {
109 110
                case Some(libId) => List(libId.toString).sorted
                case _ => summary.libraries(sample).toList.sorted
Peter van 't Hof's avatar
Peter van 't Hof committed
111 112 113 114 115 116 117
                }

                val sampleRowspan = {
                libs.size +
                libs.count(summary.getLibraryValue(sample, _, "flexiprep", "settings", "paired").getOrElse(false) == true)
                }
            }#
Peter van 't Hof's avatar
Peter van 't Hof committed
118 119 120 121 122 123 124
            <tr><td rowspan="${sampleRowspan}">
            #if (multisample)
                <a href="${rootPath}Samples/${sample}/index.html">${sample}</a>
            #else
                ${sample}
            #end
            </td>
Peter van 't Hof's avatar
Peter van 't Hof committed
125 126 127
            #for (libId <- libs)
                #if (libs.head != libId) <tr> #end
                    #{ val paired = summary.getLibraryValue(sample, libId, "flexiprep", "settings", "paired").getOrElse(false) }#
Peter van 't Hof's avatar
Peter van 't Hof committed
128 129 130 131 132 133 134
                    <td #if (paired == true) rowspan="2" #end>
                    #if (multisample)
                        <a href="${rootPath}Samples/${sample}/Libraries/${libId}/index.html">${libId}</a>
                    #else
                        ${libId}
                    #end
                    </td>
Peter van 't Hof's avatar
Peter van 't Hof committed
135 136 137 138
                    #{ val reads = if (paired == true) List("R1", "R2") else List("R1") }#
                    #for (read <- reads)
                        #if (read == "R2") </tr><tr> #end
                        #{
139
                            val beforeTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read, "bases", "num_total").getOrElse(0).toString.toLong
Peter van 't Hof's avatar
Peter van 't Hof committed
140
                            val afterTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read + "_qc", "bases", "num_total").getOrElse(0).toString.toLong
Peter van 't Hof's avatar
Peter van 't Hof committed
141 142 143 144 145 146 147 148
                        }#
                        <td>${read}</td>
                        <td>${beforeTotal}</td>
                        <td>${beforeTotal - afterTotal}</td>
                        <td>${(beforeTotal - afterTotal).toDouble / beforeTotal * 100}%</td>
                        <td>${afterTotal}</td>
                    #end
                </tr>
149
            #end
Peter van 't Hof's avatar
Peter van 't Hof committed
150 151 152
        #end
    </tbody>
</table>
153

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