Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
biopet.biopet
Commits
97661f8f
Commit
97661f8f
authored
Jul 26, 2017
by
Ruben Vorderman
Browse files
defutured flexiprepBaseSummary.ssp
parent
dd62378d
Changes
3
Hide whitespace changes
Inline
Side-by-side
flexiprep/src/main/resources/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepBaseSummary.ssp
View file @
97661f8f
...
...
@@ -21,20 +21,19 @@
<%@ var multisample: Boolean = true %>
<%@ var allSamples: Seq[Sample] %>
<%@ var allLibraries: Seq[Library] %>
#{
val samples = sampleId.map(id => allSamples.filter(_.id == id)).getOrElse(allSamples)
val libraries = libId.map(id => allLibraries.filter(_.id == id)).getOrElse(allLibraries)
val settings = summary.getSettingsForLibraries(runId, "flexiprep", keyValues = Map(
"skip_trim" -> List("skip_trim"), "skip_clip" -> List("skip_clip"), "paired" -> List("paired")))
settings.count(_._2.getOrElse("skip_trim", None) == Some(true))
val trimCount = settings.count(_._2.getOrElse("skip_trim", None) == Some(false))
val clipCount = settings.count(_._2.getOrElse("skip_clip", None) == Some(false))
val librariesCount = libraries.size
val paired: Boolean = if (sampleId.isDefined && libId.isDefined)
summary.getSettingKeys(runId, "flexiprep", NoModule, SampleId(sampleId.get), LibraryId(libId.get), keyValues = Map("paired" -> List("paired"))).getOrElse("paired", None) == Some(true)
else settings.count(_._2.getOrElse("paired", None) == Some(true)) >= 1
}#
<%@ var trimCount: Int %>
<%@ var librariesCount: Int %>
<%@ var clipCount: Int %>
<%@ var paired: Boolean %>
<%@ var summaryPlotLinesR1: Seq[String] %>
<%@ var summaryPlotLinesR2: Seq[String] %>
<%@ var samples: Seq[Sample] %>
<%@ var libraries: Seq[Library] %>
<%@ var settings: Map[(Int, Int), Map[String, Option[Any]]]%>
<%@ var seqstatStats: Map[(Int, Int), Map[String, Option[Any]]] %>
<%@ var seqstatQCStats: Map[(Int, Int), Map[String, Option[Any]]] %>
#if (showIntro)
<br/>
<div class="row">
...
...
@@ -71,8 +70,8 @@
#end
#if (showPlot)
#{
FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R1","R1", summary
, sampleId = sampleId
)
if (paired) FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R2","R2", summary
, sampleId = sampleId
)
FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R1","R1", summary
PlotLinesR1
)
if (paired) FlexiprepReport.baseSummaryPlot(outputDir, "QC_Bases_R2","R2", summary
PlotLinesR2
)
}#
<div class="panel-body">
<div class="row">
...
...
@@ -142,12 +141,8 @@
#for (read <- reads)
#if (read == "R2") </tr><tr> #end
#{
val statsPaths = Map("num_total" -> List("bases", "num_total"))
val seqstatStats = summary.getStatKeys(runId, "flexiprep", "seqstat_" + read, sample = sample.id, library = lib.id, keyValues = statsPaths)
val seqstatQcStats = summary.getStatKeys(runId, "flexiprep", "seqstat_" + read + "_qc", sample = sample.id, library = lib.id, keyValues = statsPaths)
val beforeTotal = seqstatStats("num_total").getOrElse(0).toString.toLong
val afterTotal = seqstatQcStats("num_total").getOrElse(0).toString.toLong
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
}#
<td>${read}</td>
<td>${beforeTotal}</td>
...
...
flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepReport.scala
View file @
97661f8f
...
...
@@ -90,7 +90,7 @@ object FlexiprepReport extends ReportBuilder {
* @param summary Summary class
* @param sampleId Default selects all samples, when given plot is limits on given sample
*/
def
s
ummaryPlotLines
(
read
:
String
,
def
readS
ummaryPlotLines
(
read
:
String
,
summary
:
SummaryDb
,
sampleId
:
Option
[
Int
]
=
None
)
:
Seq
[
String
]
=
{
...
...
@@ -150,7 +150,7 @@ object FlexiprepReport extends ReportBuilder {
* @param outputDir OutputDir for plot
* @param prefix prefix for tsv and png file
* @param read Must give "R1" or "R2"
* @param summaryPlotLines
the lines for the
tsv
* @param summaryPlotLines
A sequence of strings written to the summary
tsv
*/
def
readSummaryPlot
(
outputDir
:
File
,
prefix
:
String
,
...
...
@@ -176,34 +176,29 @@ object FlexiprepReport extends ReportBuilder {
}
/**
* Generated a stacked bar plot for bases QC
* @param outputDir OutputDir for plot
* @param prefix prefix for tsv and png file
* Generates the lines for baseSummaryPlotLines
* @param read Must give "R1" or "R2"
* @param summary Summary class
* @param sampleId Default selects all samples, when given plot is limits on given sample
*/
def
baseSummaryPlot
(
outputDir
:
File
,
prefix
:
String
,
read
:
String
,
summary
:
SummaryDb
,
sampleId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
val
tsvWriter
=
new
PrintWriter
(
tsvFile
)
tsvWriter
.
println
(
"Library\tAfter_QC\tDiscarded"
)
def
baseSummaryPlotLines
(
read
:
String
,
summary
:
SummaryDb
,
sampleId
:
Option
[
Int
]
=
None
)
:
Seq
[
String
]
=
{
val
statsPaths
=
Map
(
"num_total"
->
List
(
"bases"
,
"num_total"
))
val
seqstatStats
=
summary
.
getStatsForLibraries
(
runId
,
"flexiprep"
,
"seqstat_"
+
read
,
keyValues
=
statsPaths
)
val
seqstatQcStats
=
summary
.
getStatsForLibraries
(
runId
,
"flexiprep"
,
"seqstat_"
+
read
+
"_qc"
,
keyValues
=
statsPaths
)
"flexiprep"
,
"seqstat_"
+
read
+
"_qc"
,
keyValues
=
statsPaths
)
val
libraries
=
Await
.
result
(
summary
.
getLibraries
(
runId
=
runId
,
sampleId
=
sampleId
),
Duration
.
Inf
)
val
summaryPlotLines
=
ArrayBuffer
[
String
]()
for
(
lib
<-
libraries
)
{
val
beforeTotal
=
seqstatStats
((
lib
.
sampleId
,
lib
.
id
))(
"num_total"
).
getOrElse
(
0
).
toString
.
toLong
...
...
@@ -218,7 +213,29 @@ object FlexiprepReport extends ReportBuilder {
sb
.
append
(
afterTotal
+
"\t"
)
sb
.
append
(
beforeTotal
-
afterTotal
)
tsvWriter
.
println
(
sb
.
toString
)
summaryPlotLines
+=
sb
.
toString
}
summaryPlotLines
}
/**
* Generated a stacked bar plot for bases QC
* @param outputDir OutputDir for plot
* @param prefix prefix for tsv and png file
* @param read Must give "R1" or "R2"
* @param summaryPlotLines A sequence of strings written to the summary tsv
*/
def
baseSummaryPlot
(
outputDir
:
File
,
prefix
:
String
,
read
:
String
,
summaryPlotLines
:
Seq
[
String
])
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
val
tsvWriter
=
new
PrintWriter
(
tsvFile
)
tsvWriter
.
println
(
"Library\tAfter_QC\tDiscarded"
)
for
(
line
<-
summaryPlotLines
){
tsvWriter
.
println
(
line
)
}
tsvWriter
.
close
()
...
...
@@ -235,7 +252,6 @@ object FlexiprepReport extends ReportBuilder {
object
FlexiprepReadSummary
{
def
values
(
summary
:
SummaryDb
,
outputDir
:
File
,
runId
:
Int
,
allSamples
:
Seq
[
Sample
],
allLibraries
:
Seq
[
Library
],
...
...
@@ -272,8 +288,8 @@ object FlexiprepReadSummary {
val
clipCount
=
settings
.
count
(
_
.
_2
.
getOrElse
(
"skip_clip"
,
None
).
contains
(
false
))
val
librariesCount
=
libraries
.
size
val
summaryPlotLinesR1
=
if
(
showPlot
)
FlexiprepReport
.
s
ummaryPlotLines
(
"R1"
,
summary
,
sampleId
=
sampleId
)
val
summaryPlotlinesR2
=
if
(
showPlot
&&
paired
)
FlexiprepReport
.
s
ummaryPlotLines
(
"R2"
,
summary
,
sampleId
=
sampleId
)
val
summaryPlotLinesR1
=
if
(
showPlot
)
FlexiprepReport
.
readS
ummaryPlotLines
(
"R1"
,
summary
,
sampleId
=
sampleId
)
val
summaryPlotlinesR2
=
if
(
showPlot
&&
paired
)
FlexiprepReport
.
readS
ummaryPlotLines
(
"R2"
,
summary
,
sampleId
=
sampleId
)
val
seqstatPaths
=
Map
(
"num_total"
->
List
(
"reads"
,
"num_total"
))
val
clippingPaths
=
Map
(
...
...
@@ -291,7 +307,6 @@ object FlexiprepReadSummary {
Map
(
"summary"
->
summary
,
"outputDir"
->
outputDir
,
"runId"
->
runId
,
"sampleId"
->
sampleId
,
"libId"
->
libId
,
...
...
@@ -311,3 +326,51 @@ object FlexiprepReadSummary {
)
}
}
object
FlexiprepBaseSummary
{
def
values
(
summary
:
SummaryDb
,
runId
:
Int
,
allSamples
:
Seq
[
Sample
],
allLibraries
:
Seq
[
Library
],
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
,
showPlot
:
Boolean
=
false
,
showTable
:
Boolean
=
true
,
showIntro
:
Boolean
=
true
,
multisample
:
Boolean
=
true
)
:
Map
[
String
,
Any
]
=
{
val
samples
=
sampleId
.
map
(
id
=>
allSamples
.
filter
(
_
.
id
==
id
)).
getOrElse
(
allSamples
)
val
libraries
=
libId
.
map
(
id
=>
allLibraries
.
filter
(
_
.
id
==
id
)).
getOrElse
(
allLibraries
)
val
librariesCount
=
libraries
.
size
val
settings
=
summary
.
getSettingsForLibraries
(
runId
,
"flexiprep"
,
keyValues
=
Map
(
"skip_trim"
->
List
(
"skip_trim"
),
"skip_clip"
->
List
(
"skip_clip"
),
"paired"
->
List
(
"paired"
)))
settings
.
count
(
_
.
_2
.
getOrElse
(
"skip_trim"
,
None
)
==
Some
(
true
))
val
trimCount
=
settings
.
count
(
_
.
_2
.
getOrElse
(
"skip_trim"
,
None
)
==
Some
(
false
))
val
clipCount
=
settings
.
count
(
_
.
_2
.
getOrElse
(
"skip_clip"
,
None
)
==
Some
(
false
))
val
paired
:
Boolean
=
if
(
sampleId
.
isDefined
&&
libId
.
isDefined
)
summary
.
getSettingKeys
(
runId
,
"flexiprep"
,
NoModule
,
SampleId
(
sampleId
.
get
),
LibraryId
(
libId
.
get
),
keyValues
=
Map
(
"paired"
->
List
(
"paired"
))).
getOrElse
(
"paired"
,
None
)
==
Some
(
true
)
else
settings
.
count
(
_
.
_2
.
getOrElse
(
"paired"
,
None
)
==
Some
(
true
))
>=
1
val
summaryPlotLinesR1
=
if
(
showPlot
)
FlexiprepReport
.
readSummaryPlotLines
(
"R1"
,
summary
,
sampleId
=
sampleId
)
val
summaryPlotlinesR2
=
if
(
showPlot
&&
paired
)
FlexiprepReport
.
readSummaryPlotLines
(
"R2"
,
summary
,
sampleId
=
sampleId
)
val
statsPaths
=
Map
(
"num_total"
->
List
(
"bases"
,
"num_total"
))
val
seqstatStats
=
summary
.
getStatsForLibraries
(
runId
,
"flexiprep"
,
"seqstat_R1"
,
sampleId
,
statsPaths
)
val
seqstatQCStats
=
summary
.
getStatsForLibraries
(
runId
,
"flexiprep"
,
"seqstat_R1_QC"
,
sampleId
,
statsPaths
)
Map
(
"trimCount"
->
trimCount
,
"librariesCount"
->
librariesCount
,
"clipCount"
->
clipCount
,
"paired"
->
paired
,
"summaryPlotLinesR1"
->
summaryPlotLinesR1
,
"summaryPlotLinesR2"
->
summaryPlotlinesR2
)
}
}
\ No newline at end of file
gears/src/main/scala/nl/lumc/sasc/biopet/pipelines/gears/GearsReport.scala
View file @
97661f8f
...
...
@@ -141,7 +141,7 @@ object GearsReport extends MultisampleReportBuilder {
)))
else
None
val
flexiprepReadSummary
=
FlexiprepReadSummary
.
values
(
summary
,
,
runId
,
samples
,
libraries
,
sampleId
,
libId
,
true
,
false
)
val
flexiprepReadSummary
=
FlexiprepReadSummary
.
values
(
summary
,
runId
,
samples
,
libraries
,
sampleId
,
libId
,
true
,
false
)
Future
{
ReportPage
(
List
(
centrifugePage
,
krakenPage
,
qiimeClosedPage
,
qiimeOpenPage
).
flatten
:::
List
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment