insertSize.ssp 4.52 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
Peter van 't Hof's avatar
Peter van 't Hof committed
2
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
Peter van 't Hof's avatar
Peter van 't Hof committed
3
4
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
5
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
Peter van 't Hof's avatar
Peter van 't Hof committed
6
#import(java.io.File)
Peter van 't Hof's avatar
Peter van 't Hof committed
7
8
#import(scalaz._)
#import(Scalaz._)
Peter van 't Hof's avatar
Peter van 't Hof committed
9
10
11
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
Peter van 't Hof's avatar
Peter van 't Hof committed
12
13
<%@ var rootPath: String %>
<%@ var metricsTag: String = "bammetrics" %>
14
<%@ var sampleLevel: Boolean = false %>
Peter van 't Hof's avatar
Peter van 't Hof committed
15
16
<%@ var outputDir: File %>
<%@ var fields: List[String] = List("mean_insert_size", "standard_deviation", "median_insert_size")%>
17
18
<%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %>
Peter van 't Hof's avatar
Peter van 't Hof committed
19
<%@ var showIntro: Boolean = true%>
Peter van 't Hof's avatar
Peter van 't Hof committed
20
<%@ var runId: Int %>
Peter van 't Hof's avatar
Peter van 't Hof committed
21
#{
Peter van 't Hof's avatar
Peter van 't Hof committed
22
    val samples = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf)
Peter van 't Hof's avatar
Peter van 't Hof committed
23
24
}#

Peter van 't Hof's avatar
Peter van 't Hof committed
25
26
27
28
29
30
#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
31
        #if (sampleId.isDefined && libId.isDefined)
Wai Yi Leung's avatar
Wai Yi Leung committed
32
            This plot shows the insert size distribution for all libraries combined in sample <b>${sampleId}</b>.
Sander Bollen's avatar
Sander Bollen committed
33
        #elseif(sampleId.isDefined)
Wai Yi Leung's avatar
Wai Yi Leung committed
34
            This plot shows the insert size distribution for the libraries of sample <b>${sampleId}</b>.
Sander Bollen's avatar
Sander Bollen committed
35
        #else
Wai Yi Leung's avatar
Wai Yi Leung committed
36
            This plot shows the insert size distribution for each of the <b>${samples.size}</b> samples.
Sander Bollen's avatar
Sander Bollen committed
37
        #end
Wai Yi Leung's avatar
Wai Yi Leung committed
38
        <a href="http://thegenomefactory.blogspot.nl/2013/08/paired-end-read-confusion-library.html">Insert size</a> denotes the size of the so-called <em>insert</em> between two read pairs in a paired-end sequencing run. This should correspond to the length of the sequence between the sequencing adaptors. The provided table shows mean and median insert size for each sample, together with the standard deviation.
Peter van 't Hof's avatar
Peter van 't Hof committed
39
40
41
42
43
        </p>
    </div>
    </div>
#end

44
#if (showPlot)
Peter van 't Hof's avatar
Peter van 't Hof committed
45
    #{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
46
47
48
49
50

    <div class="panel-body">
    <img src="insertsize.png" class="img-responsive" />
    </div>
    <div class="panel-footer">
Peter van 't Hof's avatar
Peter van 't Hof committed
51
        #if (showTable)
52
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#insertsizeTable">
Peter van 't Hof's avatar
Peter van 't Hof committed
53
                <i class="glyphicon glyphicon-eye-close"></i>Hide table</button>
Peter van 't Hof's avatar
Peter van 't Hof committed
54
        #else
55
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#insertsizeTable">
Peter van 't Hof's avatar
Peter van 't Hof committed
56
            <i class="glyphicon glyphicon-eye-open"></i>Show table</button>
Peter van 't Hof's avatar
Peter van 't Hof committed
57
        #end
Peter van 't Hof's avatar
Peter van 't Hof committed
58
      <a href="insertsize.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i>TSV file</button></a>
59

60
61
62
    </div>
#end

Peter van 't Hof's avatar
Peter van 't Hof committed
63
64
<div class="panel-body collapse #if (showTable)in#end" id="insertsizeTable">
<!-- Table -->
65
<table class="table">
Peter van 't Hof's avatar
Peter van 't Hof committed
66
67
68
69
    <thead><tr>
        <th data-sorted="true" data-sorted-direction="ascending">Sample</th>
        #if (!sampleLevel) <th>Library</th> #end
        #for (field <- fields)
Peter van 't Hof's avatar
Peter van 't Hof committed
70
            <th>${field.replaceAll("_", " ")}</th>
Peter van 't Hof's avatar
Peter van 't Hof committed
71
72
73
        #end
    </tr></thead>
    <tbody>
Peter van 't Hof's avatar
Peter van 't Hof committed
74
        #for (sample <- samples.sortBy(_.name))
Peter van 't Hof's avatar
Peter van 't Hof committed
75
            #{
Peter van 't Hof's avatar
Peter van 't Hof committed
76
77
78
79
                val libs: List[Option[Int]] = (libId, sampleLevel) match {
                case (_, true) => List(None)
                case (Some(_), _) => List(libId)
                case _ => Await.result(summary.getLibraries(sampleId = Some(sample.id), runId = Some(runId)), Duration.Inf).map(x => Some(x.id)).toList
Peter van 't Hof's avatar
Peter van 't Hof committed
80
81
                }
            }#
82
            <tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a></td>
Peter van 't Hof's avatar
Peter van 't Hof committed
83
            #for (libId <- libs)
Peter van 't Hof's avatar
Peter van 't Hof committed
84
                #{ val libName = libId.map(l => Await.result(summary.getLibraryName(l), Duration.Inf)) }#
Peter van 't Hof's avatar
Peter van 't Hof committed
85
                #if (libs.head != libId) <tr> #end
Peter van 't Hof's avatar
Peter van 't Hof committed
86
87
                        #if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
                        #{
88
                            val statsPaths = fields.map(x => x -> List("metrics", x.toUpperCase)).toMap
Peter van 't Hof's avatar
Peter van 't Hof committed
89
                            val results = summary.getStatKeys(runId, "bammetrics".right, Some("CollectInsertSizeMetrics".right), sample = Some(sample.id.left), library = libId.map(_.left), keyValues = statsPaths)
Peter van 't Hof's avatar
Peter van 't Hof committed
90
91
92
93
94
                        }#
                        #for (field <- fields)
                            <td>${results(field)}</td>
                        #end
                    </tr>
Peter van 't Hof's avatar
Peter van 't Hof committed
95
96
97
98
99
                </tr>
            #end
        #end
    </tbody>
</table>
100

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