flexiprepReadSummary.ssp 8.63 KB
Newer Older
1 2
#import(nl.lumc.sasc.biopet.core.summary.Summary)
#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 %>
13 14 15 16 17 18
#{
    val samples = sampleId match {
        case Some(sample) => List(sample.toString)
        case _ => summary.samples.toList
    }
}#
Sander Bollen's avatar
Sander Bollen committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

#{
    def flexiprepConfig: String = {
        val skip_trim = summary.getLibraryValues("flexiprep", "settings", "skip_trim")
        val skip_clip = summary.getLibraryValues("flexiprep", "settings", "skip_clip")

        // this means both adaptor trimming and clipping are enabled
        if(skip_clip.forall(_._2 == Some(false)) && skip_trim.forall(_._2 == Some(false))) "trim_clip"
            // This means everything was disabled
        else if(skip_clip.forall(_._2 == Some(true)) && skip_trim.forall(_._2 == Some(true))) "None"
            // this means trimming was partially disabled, but not clipping
        else if(skip_trim.exists(_._2 == Some(true)) && skip_clip.map(_._2).toList.distinct.size == 1) "partial_trim"
            //this means clipping was partially disabled, but not trimming
        else if(skip_clip.exists(_._2 == Some(true)) && skip_trim.map(_._2).toList.distinct.size == 1) "partial_clip"
            // this means both trimming and clipping were partially disabled
        else "partial_both"
    }

    /**
    * TODO: This should probably be an enum in stead.
    * It's likely best to do this in a separate reporting module rather than in one big jar.
    */
    val flexiprepConfigMap = Map(
       "trim_clip" -> """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""",
        "None" -> """You have selected no pre-processing step to be performed""",
        "partial_trim" ->  """You have chosen to turn <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.""",
        "partial_clip" -> """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.""",
        "partial_both" ->  """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."""
    )

   val flexiprepDisplayed = flexiprepConfigMap(flexiprepConfig)


}#
Peter van 't Hof's avatar
Peter van 't Hof committed
53 54 55 56 57 58
#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
59 60 61 62 63 64 65 66
        ${unescape(flexiprepDisplayed)}
        </p>
        <p>
        #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
Sander Bollen's avatar
Sander Bollen committed
67
            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.
Sander Bollen's avatar
Sander Bollen committed
68 69 70 71 72
            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
73 74 75 76
        </p>
    </div>
    </div>
#end
77 78 79 80 81 82

#if (showPlot)
    #{
        FlexiprepReport.readSummaryPlot(outputDir, "QC_Reads_R1","R1", summary, sampleId = sampleId)
        FlexiprepReport.readSummaryPlot(outputDir, "QC_Reads_R2","R2", summary, sampleId = sampleId)
    }#
83 84 85 86 87 88 89 90 91 92 93 94
    <div class="panel-body">
        <div class="row">
            <div class="col-sm-6 col-md-6">
                <img src="QC_Reads_R1.png" class="img-responsive">
            </div>
            <div class="col-sm-6 col-md-6">
                <img src="QC_Reads_R2.png" class="img-responsive">
            </div>
        </div>

    </div>
    <div class="panel-footer">
Peter van 't Hof's avatar
Peter van 't Hof committed
95
        #if (showTable)
Peter van 't Hof's avatar
Peter van 't Hof committed
96 97
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#QC_ReadsTable">Hide table</button>
        #else
Peter van 't Hof's avatar
Peter van 't Hof committed
98 99
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#QC_ReadsTable">Show table</button>
        #end
100 101 102
        <i class="glyphicon glyphicon-file"></i> <a href="QC_Reads_R1.tsv">R1 reads stats</a> -
        <i class="glyphicon glyphicon-file"></i> <a href="QC_Reads_R2.tsv">R2 reads stats</a>
    </div>
103
#end
104

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

Peter van 't Hof's avatar
Peter van 't Hof committed
107
<!-- Table -->
Peter van 't Hof's avatar
Peter van 't Hof committed
108
<table class="table sortable-theme-bootstrap">
Peter van 't Hof's avatar
Peter van 't Hof committed
109
    <thead><tr>
Peter van 't Hof's avatar
Peter van 't Hof committed
110
        <th>Sample</th>
Peter van 't Hof's avatar
Peter van 't Hof committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
        <th colspan="2">Library</th>
        <th>Before QC</th>
        <th>Clipping</th>
        <th>Trimming</th>
        <th>After QC</th>
    </tr></thead>
    <tbody>
        #for (sample <- samples.toList.sorted)
            #{
                val libs = libId match {
                case Some(libId) => List(libId.toString)
                case _ => summary.libraries(sample).toList
                }
                val sampleRowspan = {
                libs.size +
                libs.count(summary.getLibraryValue(sample, _, "flexiprep", "settings", "paired").getOrElse(false) == true)
                }
            }#
            <tr><td rowspan="${sampleRowspan}"><a href="${rootPath}Samples/${sample}/index.html">${sample}</a></td>
            #for (libId <- libs)
                #if (libs.head != libId) <tr> #end
                    #{ val paired = summary.getLibraryValue(sample, libId, "flexiprep", "settings", "paired").getOrElse(false) }#
                    <td #if (paired == true) rowspan="2" #end><a href="${rootPath}Samples/${sample}/Libraries/${libId}/index.html">${libId}</a></td>
                    #{ val reads = if (paired == true) List("R1", "R2") else List("R1") }#
                    #for (read <- reads)
                        #if (read == "R2") </tr><tr> #end
                        #{
                            val beforeTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read, "reads", "num_total")
                            val afterTotal = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "seqstat_" + read + "_after", "reads", "num_total")
                            val clippingDiscardedToShort = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "clipping_" + read, "num_reads_discarded_too_short").getOrElse(0).asInstanceOf[Long]
                            val clippingDiscardedToLong = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "clipping_" + read, "num_reads_discarded_too_long").getOrElse(0).asInstanceOf[Long]
                            val trimmingDiscarded = summary.getLibraryValue(sample, libId, "flexiprep", "stats", "trimming", "num_reads_discarded_" + read).getOrElse(0).asInstanceOf[Long]
                        }#
                        <td>${read}</td>
                        <td>${beforeTotal}</td>
                        <td>${clippingDiscardedToShort + clippingDiscardedToLong}</td>
                        <td>${trimmingDiscarded}</td>
                        <td>${afterTotal}</td>
                    #end
                </tr>
            #end
        #end
    </tbody>
154

Peter van 't Hof's avatar
Peter van 't Hof committed
155 156
</table>
</div>