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
74d3c3a9
Commit
74d3c3a9
authored
Feb 21, 2017
by
Peter van 't Hof
Browse files
Fixed compile issues
parent
b27102c7
Changes
6
Hide whitespace changes
Inline
Side-by-side
bammetrics/src/main/resources/nl/lumc/sasc/biopet/pipelines/bammetrics/insertSize.ssp
View file @
74d3c3a9
...
...
@@ -43,7 +43,7 @@
#end
#if (showPlot)
#{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId, libId = libId) }#
#{ BammetricsReport.insertSizePlot(outputDir, "insertsize", summary, !sampleLevel, sampleId = sampleId, lib
rary
Id = libId) }#
<div class="panel-body">
<img src="insertsize.png" class="img-responsive" />
...
...
bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BammetricsReport.scala
View file @
74d3c3a9
...
...
@@ -132,12 +132,11 @@ object BammetricsReport extends ReportBuilder {
"NotPrimaryAlignment"
->
List
(
"flagstats"
,
"NotPrimaryAlignment"
)
)
val
pipelineId
:
Int
=
summary
.
getPipelineId
(
runId
,
"bammetrics"
).
map
(
_
.
get
)
val
moduleId
:
Option
[
Int
]
=
summary
.
getmoduleId
(
runId
,
"bamstats"
,
pipelineId
)
val
results
:
Map
[(
Int
,
Option
[
Int
])
,
Map
[
String
,
Option
[
Any
]]]
=
if
(
libraryLevel
)
{
summary
.
getStatsForLibraries
(
runId
=
runId
,
pipelineName
=
"bammetrics"
,
moduleName
=
Some
(
"bamstats"
),
sampleId
=
sampleId
,
keyValues
=
statsPaths
).
map
(
x
=>
(
x
.
_1
.
_1
,
Some
(
x
.
_1
.
_2
))
->
x
.
_2
)
}
else
summary
.
getStatsForSamples
(
runId
,
pipelineId
,
moduleId
,
sample
=
sampleId
,
keyValues
=
statsPaths
).
map
(
x
=>
(
x
.
_1
,
None
)
->
x
.
_2
)
summary
.
getStatsForLibraries
(
runId
,
Right
(
"bammetrics"
),
Some
(
Right
(
"bamstats"
)),
sampleId
=
sampleId
,
keyValues
=
statsPaths
).
map
(
x
=>
(
x
.
_1
.
_1
,
Some
(
x
.
_1
.
_2
))
->
x
.
_2
)
}
else
summary
.
getStatsForSamples
(
runId
,
Right
(
"bammetrics"
),
Some
(
Right
(
"bamstats"
)),
sample
=
sampleId
.
map
(
Left
(
_
)),
keyValues
=
statsPaths
).
map
(
x
=>
(
x
.
_1
,
None
)
->
x
.
_2
)
for
(((
s
,
l
),
result
)
<-
results
)
{
val
sampleName
:
String
=
summary
.
getSampleName
(
s
).
map
(
_
.
get
)
...
...
@@ -168,6 +167,49 @@ object BammetricsReport extends ReportBuilder {
plot
.
runLocal
()
}
def
writePlotFromSummary
(
outputDir
:
File
,
prefix
:
String
,
summary
:
SummaryDb
,
libraryLevel
:
Boolean
=
false
,
sampleId
:
Option
[
Int
]
=
None
,
libraryId
:
Option
[
Int
]
=
None
,
statsPaths
:
Map
[
String
,
List
[
String
]],
xKey
:
String
,
yKey
:
String
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]],
xlabel
:
Option
[
String
]
=
None
,
ylabel
:
Option
[
String
]
=
None
,
title
:
Option
[
String
]
=
None
,
removeZero
:
Boolean
=
true
)
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
val
results
:
Map
[(
Int
,
Option
[
Int
])
,
Map
[
String
,
Option
[
Array
[
Any
]]]]
=
if
(
libraryLevel
)
{
summary
.
getStatsForLibraries
(
runId
,
pipeline
,
module
,
sampleId
=
sampleId
,
keyValues
=
statsPaths
)
.
map
(
x
=>
(
x
.
_1
.
_1
,
Some
(
x
.
_1
.
_2
))
->
x
.
_2
.
map
(
x
=>
x
.
_1
->
x
.
_2
.
map
(
ConfigUtils
.
any2list
(
_
).
toArray
)))
}
else
summary
.
getStatsForSamples
(
runId
,
pipeline
,
module
,
sample
=
sampleId
.
map
(
Left
(
_
)),
keyValues
=
statsPaths
)
.
map
(
x
=>
(
x
.
_1
,
None
)
->
x
.
_2
.
map
(
x
=>
x
.
_1
->
x
.
_2
.
map
(
ConfigUtils
.
any2list
(
_
).
toArray
)))
val
tables
:
Array
[
Map
[
String
,
Array
[
Any
]]]
=
results
.
map
{
case
((
sample
,
library
),
map
)
=>
val
sampleName
=
Await
.
result
(
summary
.
getSampleName
(
sample
),
Duration
.
Inf
)
.
getOrElse
(
throw
new
IllegalStateException
(
"Sample must be there"
))
val
libraryName
=
library
.
flatMap
(
l
=>
Await
.
result
(
summary
.
getLibraryName
(
l
),
Duration
.
Inf
))
Map
(
yKey
->
map
(
yKey
).
getOrElse
(
Array
()),
(
sampleName
+
libraryName
.
map
(
"-"
+
_
)
getOrElse
(
""
))
->
map
(
xKey
).
getOrElse
(
Array
())
)
}.
toArray
writeTableToTsv
(
tsvFile
,
mergeTables
(
tables
,
yKey
),
yKey
)
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
xlabel
,
ylabel
=
ylabel
,
title
=
title
,
removeZero
=
removeZero
).
runLocal
()
}
/**
* Generate a line plot for insertsize
*
...
...
@@ -182,36 +224,15 @@ object BammetricsReport extends ReportBuilder {
summary
:
SummaryDb
,
libraryLevel
:
Boolean
=
false
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
libraryId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
statsPaths
=
Map
(
"insert_size"
->
List
(
"histogram"
,
"insert_size"
),
"
All_Reads.fr_
count"
->
List
(
"histogram"
,
"All_Reads.fr_count"
)
"count"
->
List
(
"histogram"
,
"All_Reads.fr_count"
)
)
val
pipelineId
:
Int
=
summary
.
getPipelineId
(
runId
,
"bammetrics"
).
map
(
_
.
get
)
val
moduleId
:
Option
[
Int
]
=
summary
.
getmoduleId
(
runId
,
"CollectInsertSizeMetrics"
,
pipelineId
)
val
results
:
Map
[(
Int
,
Option
[
Int
])
,
Map
[
String
,
Option
[
Array
[
Any
]]]]
=
if
(
libraryLevel
)
{
summary
.
getStatsForLibraries
(
runId
,
pipelineId
,
moduleId
,
sampleId
=
sampleId
,
keyValues
=
statsPaths
)
.
map
(
x
=>
(
x
.
_1
.
_1
,
Some
(
x
.
_1
.
_2
))
->
x
.
_2
.
map
(
x
=>
x
.
_1
->
x
.
_2
.
map
(
ConfigUtils
.
any2list
(
_
).
toArray
)))
}
else
summary
.
getStatsForSamples
(
runId
,
pipelineId
,
moduleId
,
sample
=
sampleId
,
keyValues
=
statsPaths
)
.
map
(
x
=>
(
x
.
_1
,
None
)
->
x
.
_2
.
map
(
x
=>
x
.
_1
->
x
.
_2
.
map
(
ConfigUtils
.
any2list
(
_
).
toArray
)))
val
tables
=
getSampleLibraries
(
summary
,
sampleId
,
libId
,
libraryLevel
)
.
map
{
case
(
sample
,
lib
)
=>
getTableFromSummary
(
summary
,
paths
(
lib
.
map
(
l
=>
s
"$sample-$l"
).
getOrElse
(
sample
)),
Some
(
sample
),
lib
)
}
writeTableToTsv
(
tsvFile
,
mergeTables
(
tables
.
toArray
,
"insert_size"
),
"insert_size"
)
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
Some
(
"Insert size"
),
ylabel
=
Some
(
"Reads"
),
title
=
Some
(
"Insert size"
),
removeZero
=
true
).
runLocal
()
writePlotFromSummary
(
outputDir
,
prefix
,
summary
,
libraryLevel
,
sampleId
,
libraryId
,
statsPaths
,
"insert_size"
,
"count"
,
Right
(
"bammetrics"
),
Some
(
Right
(
"CollectInsertSizeMetrics"
)),
"Insert size"
,
"Reads"
,
"Insert size"
)
}
def
mappingQualityPlot
(
outputDir
:
File
,
...
...
@@ -219,27 +240,15 @@ object BammetricsReport extends ReportBuilder {
summary
:
SummaryDb
,
libraryLevel
:
Boolean
=
false
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
def
paths
(
name
:
String
)
=
Map
(
"mapping_quality"
->
List
(
"bammetrics"
,
"stats"
,
"bamstats"
,
"mapping_quality"
,
"histogram"
,
"values"
),
name
->
List
(
"bammetrics"
,
"stats"
,
"bamstats"
,
"mapping_quality"
,
"histogram"
,
"counts"
)
libraryId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
statsPaths
=
Map
(
"mapping_quality"
->
List
(
"mapping_quality"
,
"histogram"
,
"values"
),
"count"
->
List
(
"mapping_quality"
,
"histogram"
,
"counts"
)
)
val
tables
=
getSampleLibraries
(
summary
,
sampleId
,
libId
,
libraryLevel
)
.
map
{
case
(
sample
,
lib
)
=>
getTableFromSummary
(
summary
,
paths
(
lib
.
map
(
l
=>
s
"$sample-$l"
).
getOrElse
(
sample
)),
Some
(
sample
),
lib
)
}
writeTableToTsv
(
tsvFile
,
mergeTables
(
tables
.
toArray
,
"mapping_quality"
),
"mapping_quality"
)
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
Some
(
"Mapping Quality"
),
ylabel
=
Some
(
"Reads"
),
title
=
Some
(
"Mapping Quality"
),
removeZero
=
true
).
runLocal
()
writePlotFromSummary
(
outputDir
,
prefix
,
summary
,
libraryLevel
,
sampleId
,
libraryId
,
statsPaths
,
"mapping_quality"
,
"count"
,
Right
(
"bammetrics"
),
Some
(
Right
(
"bamstats"
)),
"Mapping quality"
,
"Reads"
,
"Mapping quality"
)
}
def
clippingPlot
(
outputDir
:
File
,
...
...
@@ -247,27 +256,15 @@ object BammetricsReport extends ReportBuilder {
summary
:
SummaryDb
,
libraryLevel
:
Boolean
=
false
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
def
paths
(
name
:
String
)
=
Map
(
"clipping"
->
List
(
"bammetrics"
,
"stats"
,
"bamstats"
,
"clipping"
,
"histogram"
,
"values"
),
name
->
List
(
"bammetrics"
,
"stats"
,
"bamstats"
,
"clipping"
,
"histogram"
,
"counts"
)
libraryId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
statsPaths
=
Map
(
"clipping"
->
List
(
"clipping"
,
"histogram"
,
"values"
),
"count"
->
List
(
"clipping"
,
"histogram"
,
"counts"
)
)
val
tables
=
getSampleLibraries
(
summary
,
sampleId
,
libId
,
libraryLevel
)
.
map
{
case
(
sample
,
lib
)
=>
getTableFromSummary
(
summary
,
paths
(
lib
.
map
(
l
=>
s
"$sample-$l"
).
getOrElse
(
sample
)),
Some
(
sample
),
lib
)
}
writeTableToTsv
(
tsvFile
,
mergeTables
(
tables
.
toArray
,
"clipping"
),
"clipping"
)
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
Some
(
"Clipping"
),
ylabel
=
Some
(
"Reads"
),
title
=
Some
(
"Clipping"
),
removeZero
=
true
).
runLocal
()
writePlotFromSummary
(
outputDir
,
prefix
,
summary
,
libraryLevel
,
sampleId
,
libraryId
,
statsPaths
,
"clipping"
,
"count"
,
Right
(
"bammetrics"
),
Some
(
Right
(
"bamstats"
)),
"Clipping"
,
"Reads"
,
"Clipping"
)
}
/**
...
...
@@ -284,27 +281,15 @@ object BammetricsReport extends ReportBuilder {
summary
:
SummaryDb
,
libraryLevel
:
Boolean
=
false
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
def
paths
(
name
:
String
)
=
Map
(
"coverage"
->
List
(
"bammetrics"
,
"stats"
,
"wgs"
,
"histogram"
,
"coverage"
),
name
->
List
(
"bammetrics"
,
"stats"
,
"wgs"
,
"histogram"
,
"count"
)
libraryId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
statsPaths
=
Map
(
"coverage"
->
List
(
"wgs"
,
"histogram"
,
"coverage"
),
"count"
->
List
(
"wgs"
,
"histogram"
,
"count"
)
)
val
tables
=
getSampleLibraries
(
summary
,
sampleId
,
libId
,
libraryLevel
)
.
map
{
case
(
sample
,
lib
)
=>
getTableFromSummary
(
summary
,
paths
(
lib
.
map
(
l
=>
s
"$sample-$l"
).
getOrElse
(
sample
)),
Some
(
sample
),
lib
)
}
writeTableToTsv
(
tsvFile
,
mergeTables
(
tables
.
toArray
,
"coverage"
),
"coverage"
)
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
Some
(
"Coverage"
),
ylabel
=
Some
(
"Bases"
),
title
=
Some
(
"Whole genome coverage"
),
removeZero
=
true
).
runLocal
()
writePlotFromSummary
(
outputDir
,
prefix
,
summary
,
libraryLevel
,
sampleId
,
libraryId
,
statsPaths
,
"coverage"
,
"count"
,
Right
(
"bammetrics"
),
Some
(
Right
(
"wgs"
)),
"Coverage"
,
"Bases"
,
"Whole genome coverage"
)
}
/**
...
...
@@ -320,51 +305,16 @@ object BammetricsReport extends ReportBuilder {
prefix
:
String
,
summary
:
SummaryDb
,
libraryLevel
:
Boolean
=
false
,
sampleId
:
Option
[
String
]
=
None
,
libId
:
Option
[
String
]
=
None
)
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
def
paths
(
name
:
String
)
=
Map
(
"normalized_position"
->
List
(
"bammetrics"
,
"stats"
,
"rna"
,
"histogram"
,
"normalized_position"
),
name
->
List
(
"bammetrics"
,
"stats"
,
"rna"
,
"histogram"
,
"All_Reads.normalized_coverage"
)
sampleId
:
Option
[
Int
]
=
None
,
libraryId
:
Option
[
Int
]
=
None
)
:
Unit
=
{
val
statsPaths
=
Map
(
"position"
->
List
(
"rna"
,
"histogram"
,
"normalized_position"
),
"count"
->
List
(
"rna"
,
"histogram"
,
"All_Reads.normalized_coverage"
)
)
val
tables
=
getSampleLibraries
(
summary
,
sampleId
,
libId
,
libraryLevel
)
.
map
{
case
(
sample
,
lib
)
=>
getTableFromSummary
(
summary
,
paths
(
lib
.
map
(
l
=>
s
"$sample-$l"
).
getOrElse
(
sample
)),
Some
(
sample
),
lib
)
}
writeTableToTsv
(
tsvFile
,
mergeTables
(
tables
.
toArray
,
"normalized_position"
),
"normalized_position"
)
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
Some
(
"Relative position"
),
ylabel
=
Some
(
"Coverage"
),
title
=
Some
(
"Rna coverage"
),
removeZero
=
true
).
runLocal
()
}
private
def
getSampleLibraries
(
summary
:
SummaryDb
,
sampleId
:
Option
[
Int
]
=
None
,
LibId
:
Option
[
Int
]
=
None
,
libraryLevel
:
Boolean
=
false
)
:
List
[(
Int
,
Option
[
Int
])]
=
{
if
(
LibId
.
isDefined
)
require
(
sampleId
.
isDefined
)
if
(
libraryLevel
||
LibId
.
isDefined
)
for
((
sample
,
libs
)
<-
summary
.
libraries
.
toList
;
lib
<-
libs
)
yield
(
sample
,
Some
(
lib
))
else
for
((
sample
,
libs
)
<-
summary
.
libraries
.
toList
)
yield
(
sample
,
None
)
}
def
getTableFromSummary
(
summary
:
SummaryDb
,
paths
:
Map
[
String
,
List
[
String
]],
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
)
:
Map
[
String
,
Array
[
Any
]]
=
{
val
pathValues
:
Map
[
String
,
Array
[
Any
]]
=
paths
.
map
{
case
(
key
,
path
)
=>
val
value
=
summary
.
getValueAsArray
(
sampleId
,
libId
,
path
:
_
*
)
key
->
value
.
getOrElse
(
Array
())
}
require
(
pathValues
.
map
(
_
.
_2
.
size
).
toList
.
distinct
.
size
==
1
,
s
"Arrays in summary does not have the same number of values, $paths"
)
pathValues
writePlotFromSummary
(
outputDir
,
prefix
,
summary
,
libraryLevel
,
sampleId
,
libraryId
,
statsPaths
,
"coverage"
,
"count"
,
Right
(
"bammetrics"
),
Some
(
Right
(
"rna"
)),
"Relative position"
,
"Coverage"
,
"Rna coverage"
)
}
def
mergeTables
(
tables
:
Array
[
Map
[
String
,
Array
[
Any
]]],
...
...
mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/MappingReport.scala
View file @
74d3c3a9
...
...
@@ -19,6 +19,9 @@ import nl.lumc.sasc.biopet.core.report._
import
nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport
import
nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import
scala.concurrent.Await
import
scala.concurrent.duration.Duration
class
MappingReport
(
val
parent
:
Configurable
)
extends
ReportBuilderExtension
{
def
builder
=
MappingReport
}
...
...
@@ -35,12 +38,17 @@ object MappingReport extends ReportBuilder {
override
def
extFiles
=
super
.
extFiles
++
List
(
"js/gears.js"
,
"js/krona-2.0.js"
,
"img/krona/loading.gif"
,
"img/krona/hidden.png"
,
"img/krona/favicon.ico"
)
.
map
(
x
=>
ExtFile
(
"/nl/lumc/sasc/biopet/pipelines/gears/report/ext/"
+
x
,
x
))
def
krakenExecuted
=
summary
.
getValue
(
sampleId
,
libId
,
"gears"
,
"stats"
,
"krakenreport"
).
isDefined
summary
.
getStatsSize
(
runId
,
Right
(
"gears"
),
Some
(
Right
(
"krakenreport"
)),
sample
=
sampleId
.
map
(
Left
(
_
)),
library
=
libId
.
map
(
Left
(
_
)))
def
krakenExecuted
:
Boolean
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"gears"
),
Some
(
Right
(
"krakenreport"
)),
sample
=
sampleId
.
map
(
Left
(
_
)),
library
=
libId
.
map
(
Left
(
_
))),
Duration
.
Inf
)
>=
1
/** Root page for single BamMetrcis report */
def
indexPage
=
{
val
skipFlexiprep
=
summary
.
getValue
(
sampleId
,
libId
,
"mapping"
,
"settings"
,
"skip_flexiprep"
).
getOrElse
(
false
)
==
true
val
bamMetricsPage
=
if
(
summary
.
getValue
(
sampleId
,
libId
,
"mapping"
,
"settings"
,
"skip_metrics"
).
getOrElse
(
false
)
!=
true
)
{
val
mappingSettings
=
summary
.
getSettingKeys
(
runId
,
Right
(
"mapping"
),
None
,
sample
=
sampleId
.
map
(
Left
(
_
)),
library
=
libId
.
map
(
Left
(
_
)),
keyValues
=
Map
(
"skip_flexiprep"
->
List
(
"skip_flexiprep"
),
"skip_metrics"
->
List
(
"skip_metrics"
)))
val
skipFlexiprep
=
mappingSettings
.
get
(
"skip_flexiprep"
).
flatten
.
getOrElse
(
false
)
==
true
val
bamMetricsPage
=
if
(
mappingSettings
.
get
(
"skip_metrics"
).
flatten
.
getOrElse
(
false
)
==
true
)
{
Some
(
BammetricsReport
.
bamMetricsPage
(
summary
,
sampleId
,
libId
))
}
else
None
ReportPage
((
if
(
skipFlexiprep
)
Nil
else
List
(
"QC"
->
FlexiprepReport
.
flexiprepPage
))
:::
...
...
mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/MultisampleMappingReport.scala
View file @
74d3c3a9
...
...
@@ -14,11 +14,14 @@
*/
package
nl.lumc.sasc.biopet.pipelines.mapping
import
nl.lumc.sasc.biopet.core.report.
{
ReportBuilder
Extension
,
ReportSection
,
ReportPage
,
MultisampleReportBuilder
}
import
nl.lumc.sasc.biopet.core.report.
{
Multisample
ReportBuilder
,
ReportBuilderExtension
,
ReportPage
,
ReportSection
}
import
nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport
import
nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
scala.concurrent.Await
import
scala.concurrent.duration.Duration
/**
* Created by pjvanthof on 11/01/16.
*/
...
...
@@ -45,15 +48,20 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Root page for the carp report */
def
indexPage
=
{
val
krakenExecuted
=
summary
.
getSampleValues
(
"gearskraken"
,
"stats"
,
"krakenreport"
).
values
.
forall
(
_
.
isDefined
)
val
centrifugeExecuted
=
summary
.
getSampleValues
(
"gearscentrifuge"
,
"stats"
,
"centrifuge_report"
).
values
.
forall
(
_
.
isDefined
)
val
wgsExecuted
=
summary
.
getSampleValues
(
"bammetrics"
,
"stats"
,
"wgs"
).
values
.
exists
(
_
.
isDefined
)
val
rnaExecuted
=
summary
.
getSampleValues
(
"bammetrics"
,
"stats"
,
"rna"
).
values
.
exists
(
_
.
isDefined
)
val
insertsizeExecuted
=
summary
.
getSampleValues
(
"bammetrics"
,
"stats"
,
"CollectInsertSizeMetrics"
,
"metrics"
).
values
.
exists
(
_
!=
Some
(
None
))
val
mappingExecuted
=
summary
.
getLibraryValues
(
"mapping"
).
exists
(
_
.
_2
.
isDefined
)
val
pairedFound
=
!
mappingExecuted
||
summary
.
getLibraryValues
(
"mapping"
,
"settings"
,
"paired"
).
exists
(
_
.
_2
==
Some
(
true
))
val
flexiprepExecuted
=
summary
.
getLibraryValues
(
"flexiprep"
)
.
exists
{
case
((
sample
,
lib
),
value
)
=>
value
.
isDefined
}
val
krakenExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"gearskraken"
),
Some
(
Right
(
"krakenreport"
)),
library
=
Some
(
None
),
mustHaveSample
=
true
),
Duration
.
Inf
)
>=
1
val
centrifugeExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"gearscentrifuge"
),
Some
(
Right
(
"centrifuge_report"
)),
library
=
Some
(
None
),
mustHaveSample
=
true
),
Duration
.
Inf
)
>=
1
val
wgsExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"bammetrics"
),
Some
(
Right
(
"wgs"
)),
library
=
Some
(
None
),
mustHaveSample
=
true
),
Duration
.
Inf
)
>=
1
val
rnaExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"bammetrics"
),
Some
(
Right
(
"rna"
)),
library
=
Some
(
None
),
mustHaveSample
=
true
),
Duration
.
Inf
)
>=
1
val
insertsizeExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"bammetrics"
),
Some
(
Right
(
"CollectInsertSizeMetrics"
)),
library
=
Some
(
None
),
mustHaveSample
=
true
),
Duration
.
Inf
)
>=
1
val
mappingExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"mapping"
),
Some
(
None
),
mustHaveLibrary
=
true
),
Duration
.
Inf
)
>=
1
val
pairedFound
=
!
mappingExecuted
||
summary
.
getSettingsForLibraries
(
runId
,
Right
(
"mapping"
),
None
,
keyValues
=
Map
(
"paired"
->
List
(
"paired"
)))
.
exists
(
_
.
_2
.
exists
(
_
.
_2
==
Some
(
true
)))
val
flexiprepExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"flexiprep"
),
Some
(
None
),
mustHaveLibrary
=
true
),
Duration
.
Inf
)
>=
1
ReportPage
(
List
(
"Samples"
->
generateSamplesPage
(
pageArgs
))
++
...
...
@@ -105,8 +113,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Files page, can be used general or at sample level */
def
filesPage
:
ReportPage
=
{
val
flexiprepExecuted
=
summary
.
getLibraryValues
(
"flexiprep"
)
.
exists
{
case
((
sample
,
lib
),
value
)
=>
value
.
isDefined
}
val
flexiprepExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"flexiprep"
),
Some
(
None
),
mustHaveLibrary
=
true
),
Duration
.
Inf
)
>=
1
ReportPage
(
List
(),
(
if
(
flexiprepExecuted
)
List
(
"Input fastq files"
->
ReportSection
(
"/nl/lumc/sasc/biopet/pipelines/flexiprep/flexiprepInputfiles.ssp"
),
...
...
@@ -118,11 +125,13 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
}
/** Single sample page */
def
samplePage
(
sampleId
:
String
,
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
krakenExecuted
=
summary
.
getValue
(
Some
(
sampleId
),
None
,
"gearskraken"
,
"stats"
,
"krakenreport"
).
isDefined
val
centrifugeExecuted
=
summary
.
getValue
(
Some
(
sampleId
),
None
,
"gearscentrifuge"
,
"stats"
,
"centrifuge_report"
).
isDefined
val
flexiprepExecuted
=
summary
.
getLibraryValues
(
"flexiprep"
)
.
exists
{
case
((
sample
,
lib
),
value
)
=>
sample
==
sampleId
&&
value
.
isDefined
}
def
samplePage
(
sampleId
:
Int
,
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
krakenExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"gearskraken"
),
Some
(
Right
(
"krakenreport"
)),
library
=
Some
(
None
),
sample
=
Some
(
Left
(
sampleId
))),
Duration
.
Inf
)
>=
1
val
centrifugeExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"gearscentrifuge"
),
Some
(
Right
(
"centrifuge_report"
)),
library
=
Some
(
None
),
sample
=
Some
(
Left
(
sampleId
)),
mustHaveSample
=
true
),
Duration
.
Inf
)
>=
1
val
flexiprepExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"flexiprep"
),
Some
(
None
),
sample
=
Some
(
Left
(
sampleId
)),
mustHaveLibrary
=
true
),
Duration
.
Inf
)
>=
1
ReportPage
(
List
(
"Libraries"
->
generateLibraryPage
(
args
),
...
...
@@ -149,10 +158,13 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
}
/** Library page */
def
libraryPage
(
sampleId
:
String
,
libId
:
String
,
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
krakenExecuted
=
summary
.
getValue
(
Some
(
sampleId
),
Some
(
libId
),
"gearskraken"
,
"stats"
,
"krakenreport"
).
isDefined
val
centrifugeExecuted
=
summary
.
getValue
(
Some
(
sampleId
),
Some
(
libId
),
"gearscentrifuge"
,
"stats"
,
"centrifuge_report"
).
isDefined
val
flexiprepExecuted
=
summary
.
getValue
(
Some
(
sampleId
),
Some
(
libId
),
"flexiprep"
).
isDefined
def
libraryPage
(
sampleId
:
Int
,
libId
:
Int
,
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
krakenExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"gearskraken"
),
Some
(
Right
(
"krakenreport"
)),
library
=
Some
(
Left
(
libId
)),
sample
=
Some
(
Left
(
sampleId
))),
Duration
.
Inf
)
>=
1
val
centrifugeExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"gearscentrifuge"
),
Some
(
Right
(
"centrifuge_report"
)),
library
=
Some
(
Left
(
libId
)),
sample
=
Some
(
Left
(
sampleId
)),
mustHaveSample
=
true
),
Duration
.
Inf
)
>=
1
val
flexiprepExecuted
=
Await
.
result
(
summary
.
getStatsSize
(
runId
,
Right
(
"flexiprep"
),
Some
(
None
),
library
=
Some
(
Left
(
libId
)),
sample
=
Some
(
Left
(
sampleId
)),
mustHaveLibrary
=
true
),
Duration
.
Inf
)
>=
1
ReportPage
(
(
"Alignment"
->
BammetricsReport
.
bamMetricsPage
(
summary
,
Some
(
sampleId
),
Some
(
libId
)))
::
...
...
shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaReport.scala
View file @
74d3c3a9
...
...
@@ -14,13 +14,17 @@
*/
package
nl.lumc.sasc.biopet.pipelines.shiva
import
java.io.
{
File
,
PrintWriter
}
import
java.io.
{
File
,
PrintWriter
}
import
nl.lumc.sasc.biopet.core.report._
import
nl.lumc.sasc.biopet.pipelines.mapping.MultisampleMappingReportTrait
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.utils.rscript.StackedBarPlot
import
nl.lumc.sasc.biopet.utils.summary.
{
Summary
,
SummaryValue
}
import
nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import
nl.lumc.sasc.biopet.utils.summary.
{
Summary
,
SummaryValue
}
import
scala.concurrent.Await
import
scala.concurrent.duration.Duration
/**
* With this extension the report is executed within a pipeline
...
...
@@ -37,7 +41,8 @@ object ShivaReport extends ShivaReportTrait
/** Trait for report generation for Shiva pipeline, this can be extended */
trait
ShivaReportTrait
extends
MultisampleMappingReportTrait
{
def
variantcallingExecuted
=
summary
.
getValue
(
"shiva"
,
"settings"
,
"multisample_variantcalling"
)
match
{
def
variantcallingExecuted
=
summary
.
getSettingKeys
(
runId
,
Right
(
"shiva"
),
None
,
keyValues
=
Map
(
"multisample_variantcalling"
->
List
(
"multisample_variantcalling"
))).
get
(
"multisample_variantcalling"
)
.
flatten
match
{
case
Some
(
true
)
=>
true
case
_
=>
false
}
...
...
@@ -60,8 +65,8 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
/** Generate a page with all target coverage stats */
def
regionsPage
:
Option
[(
String
,
ReportPage
)]
=
{
val
roi
=
summary
.
get
Value
(
"shiva"
,
"settings"
,
"regions_of_interest"
)
val
amplicon
=
summary
.
get
Value
(
"shiva"
,
"settings"
,
"amplicon_bed"
)
val
roi
=
summary
.
get
Setting
(
runId
,
Right
(
"shiva"
)).
get
(
"regions_of_interest"
)
val
amplicon
=
summary
.
get
Setting
(
runId
,
Right
(
"shiva"
)).
get
(
"amplicon_bed"
)
var
regionPages
:
Map
[
String
,
ReportPage
]
=
Map
()
...
...
@@ -108,7 +113,7 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
}
/** Single sample page */
override
def
samplePage
(
sampleId
:
String
,
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
override
def
samplePage
(
sampleId
:
Int
,
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
variantcallingSection
=
if
(
variantcallingExecuted
)
List
(
"Variantcalling"
->
ReportSection
(
"/nl/lumc/sasc/biopet/pipelines/shiva/sampleVariants.ssp"
))
else
Nil
val
oldPage
=
super
.
samplePage
(
sampleId
,
args
)
oldPage
.
copy
(
sections
=
variantcallingSection
++
oldPage
.
sections
)
...
...
@@ -123,51 +128,37 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
* @param outputDir OutputDir for the tsv and png file
* @param prefix Prefix of the tsv and png file
* @param summary Summary class
* @param libraryLevel Default false, when set true plot will be based on library stats instead of sample stats
* @param sampleId Default it selects all sampples, when sample is giving it limits to selected sample
*/
def
variantSummaryPlot
(
outputDir
:
File
,
prefix
:
String
,
summary
:
Summary
,
libraryLevel
:
Boolean
=
false
,
sampleId
:
Option
[
String
]
=
None
,
summary
:
SummaryDb
,
sampleId
:
Option
[
Int
]
=
None
,
caller
:
String
=
"final"
,
target
:
Option
[
String
]
=
None
)
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
val
tsvWriter
=
new
PrintWriter
(
tsvFile
)
if
(
libraryLevel
)
tsvWriter
.
print
(
"Library"
)
else
tsvWriter
.
print
(
"Sample"
)
tsvWriter
.
println
(
"\tHomVar\tHet\tHomRef\tNoCall"
)
def
getLine
(
summary
:
Summary
,
sample
:
String
,
summarySample
:
Option
[
String
],
lib
:
Option
[
String
]
=
None
)
:
String
=
{
val
path
=
target
match
{
case
Some
(
t
)
=>
List
(
"shivavariantcalling"
,
"stats"
,
s
"multisample-vcfstats-$caller-$t"
,
"genotype"
,
sample
)
case
_
=>
List
(
"shivavariantcalling"
,
"stats"
,
s
"multisample-vcfstats-$caller"
,
"total"
,
"genotype"
,
"general"
,
sample
)
}
val
homVar
=
new
SummaryValue
(
path
:+
"HomVar"
,
summary
,
summarySample
,
lib
).
value
.
getOrElse
(
0
).
toString
.
toLong
val
homRef
=
new
SummaryValue
(
path
:+
"HomRef"
,
summary
,
summarySample
,
lib
).
value
.
getOrElse
(
0
).
toString
.
toLong
val
noCall
=
new
SummaryValue
(
path
:+
"NoCall"
,
summary
,
summarySample
,
lib
).
value
.
getOrElse
(
0
).
toString
.
toLong
val
het
=
new
SummaryValue
(
path
:+
"Het"
,
summary
,
summarySample
,
lib
).
value
.
getOrElse
(
0
).
toString
.
toLong
val
sb
=
new
StringBuffer
()
if
(
lib
.
isDefined
)
sb
.
append
(
sample
+
"-"
+
lib
.
get
+
"\t"
)
else
sb
.
append
(
sample
+
"\t"
)
sb
.
append
(
homVar
+
"\t"
)
sb
.
append
(
het
+
"\t"
)
sb
.
append
(
homRef
+
"\t"
)
sb
.
append
(
noCall
)
sb
.
toString
tsvWriter
.
print
(
"Sample"
)
val
field
=
List
(
"HomVar"
,
"Het"
,
"HomRef"
,
"NoCall"
)
tsvWriter
.
println
(
s
"\t${field.mkString("
\
t
")}"
)
val
samples
=
Await
.
result
(
summary
.
getSamples
(
runId
=
runId
,
sampleId
=
sampleId
),
Duration
.
Inf
)
val
statsPaths
=
{
(
for
(
sample
<-
Await
.
result
(
summary
.
getSamples
(
runId
=
runId
),
Duration
.
Inf
))
yield
{
field
.
map
(
f
=>
s
"${sample.name};HomVar"
->
List
(
"total"
,
"genotype"
,
"general"
,
sample
.
name
,
f
)).
toMap
}).
fold
(
Map
())(
_
++
_
)
}
val
moduleName
=
target
match
{
case
Some
(
t
)
=>
s
"multisample-vcfstats-$caller-$t"
case
_
=>
s
"multisample-vcfstats-$caller"
}
if
(
libraryLevel
)
{
for
(
sample
<-
summary
.
samples
if
sampleId
.
isEmpty
||
sample
==
sampleId
.
get
;
lib
<-
summary
.
libraries
(
sample
)
)
{
tsvWriter
.
println
(
getLine
(
summary
,
sample
,
sampleId
,
Some
(
lib
)))
}
}
else
{
for
(
sample
<-
summary
.
samples
if
sampleId
.
isEmpty
||
sample
==
sampleId
.
get
)
{
tsvWriter
.
println
(
getLine
(
summary
,
sample
,
sampleId
))
}
val
results
=
summary
.
getStatKeys
(
runId
,
Right
(
"shivavariantcalling"
),
Some
(
Right
(
moduleName
)),
sampleId
.
map
(
Left
(
_
)),
keyValues
=
statsPaths
)
for
(
sample
<-
samples
if
sampleId
.
isEmpty
||
sample
.
id
==
sampleId
.
get
)
{
tsvWriter
.
println
(
sample
.
name
+
"\t"
+
field
.
map
(
f
=>
results
(
s
"${sample.name};$f"
).
getOrElse
(
""
)).
mkString
(
"\t"
))
}
tsvWriter
.
close
()
...
...
@@ -176,9 +167,7 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
plot
.
input
=
tsvFile
plot
.
output
=
pngFile
plot
.
ylabel
=
Some
(
"VCF records"
)
if
(
libraryLevel
)
{
plot
.
width
=
Some
(
200
+
(
summary
.
libraries
.
filter
(
s
=>
sampleId
.
getOrElse
(
s
.
_1
)
==
s
.
_1
).
foldLeft
(
0
)(
_
+
_
.
_2
.
size
)
*
10
))
}
else
plot
.
width
=
Some
(
200
+
(
summary
.
samples
.
count
(
s
=>
sampleId
.
getOrElse
(
s
)
==
s
)
*
10
))