clipping.ssp 4.07 KB
Newer Older
1
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema._)
Peter van 't Hof's avatar
Peter van 't Hof committed
2
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
Peter van 't Hof's avatar
Peter van 't Hof committed
3 4
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb._)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.Implicts._)
5 6 7
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
Peter van 't Hof's avatar
Peter van 't Hof committed
8 9 10
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
11
<%@ var sampleLevel: Boolean = false %>
Peter van 't Hof's avatar
Peter van 't Hof committed
12
<%@ var rootPath: String %>
13 14 15 16
<%@ var outputDir: File %>
<%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %>
<%@ var showIntro: Boolean = true%>
Peter van 't Hof's avatar
Peter van 't Hof committed
17 18
<%@ var runId: Int %>
<%@ var fields: List[String] = List("min", "max", "mean", "median", "modal")%>
19 20
<%@ var allSamples: Seq[Sample] %>
<%@ var allLibraries: Seq[Library] %>
21
#{
22 23 24 25
    val samples = sampleId match {
    case Some(id) => allSamples.filter(_.id == id).toList
    case _ => allSamples.toList
    }
26 27 28 29 30 31 32 33
}#
#if (showIntro)
    <br/>
    <div class="row">
    <div class="col-md-1"></div>
    <div class="col-md-6">
        <p>
        #if (sampleId.isDefined && libId.isDefined)
Peter van 't Hof's avatar
Peter van 't Hof committed
34
            This plot shows the clipping distribution for library <b>${libId}</b> of sample <b>${sampleId}</b>.
35 36 37 38 39 40 41 42 43 44 45
        #elseif(sampleId.isDefined)
            This plot shows the clipping distribution for the libraries of sample <b>${sampleId}</b>.
        #else
            This plot shows the clipping distribution for each of the <b>${samples.size}</b> samples.
        #end
        </p>
    </div>
    </div>
#end

#if (showPlot)
Peter van 't Hof's avatar
Peter van 't Hof committed
46
    #{ BammetricsReport.clippingPlot(outputDir, "clipping", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
47 48 49 50 51 52 53 54 55 56 57 58

    <div class="panel-body">
    <img src="clipping.png" class="img-responsive" />
    </div>
    <div class="panel-footer">
        #if (showTable)
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#clippingTable">
                <i class="glyphicon glyphicon-eye-close"></i> Hide table</button>
        #else
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#clippingTable">
            <i class="glyphicon glyphicon-eye-open"></i> Show table</button>
        #end
Peter van 't Hof's avatar
Peter van 't Hof committed
59
      <a href="clipping.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i>TSV file</button></a>
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

    </div>
#end

<div class="panel-body collapse #if (showTable)in#end" id="clippingTable">
<!-- Table -->
<table class="table">
    <thead><tr>
        <th data-sorted="true" data-sorted-direction="ascending">Sample</th>
        #if (!sampleLevel) <th>Library</th> #end
        #for (field <- fields)
            <th>${field.replaceAll("_", " ")}</th>
        #end
    </tr></thead>
    <tbody>
Peter van 't Hof's avatar
Peter van 't Hof committed
75
        #for (sample <- samples.sortBy(_.name))
76
            #{
Peter van 't Hof's avatar
Peter van 't Hof committed
77 78 79
                val libs: List[Option[Int]] = (libId, sampleLevel) match {
                case (_, true) => List(None)
                case (Some(_), _) => List(libId)
80
                case _ => allLibraries.filter(_.sampleId == sample.id).map(x => Some(x.id)).toList
81 82
                }
            }#
83
            <tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a></td>
84
            #for (libId <- libs)
85
                #{ val libName = libId.map(l => allLibraries.find(_.id == l).get.name) }#
86
                #if (libs.head != libId) <tr> #end
87
                    #if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
88
                    #{
Peter van 't Hof's avatar
Peter van 't Hof committed
89
                        val statsPaths = fields.map(x => x -> List("clipping", "general", x)).toMap
Peter van 't Hof's avatar
Peter van 't Hof committed
90
                        val results = summary.getStatKeys(runId, "bammetrics", "bamstats", sample = sample.id, library = libId.map(LibraryId).getOrElse(NoLibrary), keyValues = statsPaths)
91
                    }#
Peter van 't Hof's avatar
Peter van 't Hof committed
92 93
                    #for (field <- fields)
                        <td>${results(field)}</td>
94 95 96 97 98 99 100 101
                    #end
                </tr>
            #end
        #end
    </tbody>
</table>

</div>