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
0a868bd9
Commit
0a868bd9
authored
Mar 30, 2017
by
akaljuvee
Browse files
sv-s are grouped by type also for the tables
parent
ddada7c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaSvCallingReport.scala
View file @
0a868bd9
...
...
@@ -7,37 +7,70 @@ import nl.lumc.sasc.biopet.utils.summary.Summary
object
ShivaSvCallingReport
{
val
histogramBinBoundaries
:
Array
[
Int
]
=
Array
(
100
,
1000
,
10000
,
100000
,
1000000
,
10000000
)
val
histogramText
:
List
[
String
]
=
List
(
"<=100bp"
,
"0.1-1kb"
,
"1-10kb"
,
"10-100kb"
,
"0.1-1Mb"
,
"1-10Mb"
,
">10Mb"
)
def
parseSummaryForSvCounts
(
summary
:
Summary
)
:
Map
[
String
,
Map
[
String
,
Array
[
Any
]]]
=
{
var
result
:
Map
[
String
,
Map
[
String
,
Array
[
Any
]]]
=
Map
()
var
delCounts
,
insCounts
,
dupCounts
,
invCounts
:
Map
[
String
,
Array
[
Any
]]
=
Map
()
for
(
sampleName
<-
summary
.
samples
)
{
var
sampleCounts
:
Map
[
String
,
Any
]
=
summary
.
getSampleValue
(
sampleName
,
"shivasvcalling"
,
"stats"
,
"variantsBySizeAndType"
).
get
.
asInstanceOf
[
Map
[
String
,
Any
]]
result
=
result
+
(
sampleName
->
sampleCounts
.
collect
({
case
(
k
,
v
:
List
[
_
])
=>
(
k
,
v
.
toArray
[
Any
])
}))
for
((
svType
,
counts
)
<-
sampleCounts
.
collect
({
case
(
k
,
v
:
List
[
_
])
=>
(
k
,
v
.
toArray
[
Any
])
}))
{
svType
match
{
case
"DEL"
=>
delCounts
=
delCounts
+
(
sampleName
->
counts
)
case
"INS"
=>
insCounts
=
insCounts
+
(
sampleName
->
counts
)
case
"DUP"
=>
dupCounts
=
dupCounts
+
(
sampleName
->
counts
)
case
"INV"
=>
invCounts
=
invCounts
+
(
sampleName
->
counts
)
}
}
}
var
result
:
Map
[
String
,
Map
[
String
,
Array
[
Any
]]]
=
Map
()
if
(!
delCounts
.
isEmpty
)
result
=
Map
(
"DEL"
->
delCounts
)
if
(!
insCounts
.
isEmpty
)
result
=
result
+
(
"INS"
->
insCounts
)
if
(!
dupCounts
.
isEmpty
)
result
=
result
+
(
"DUP"
->
dupCounts
)
if
(!
invCounts
.
isEmpty
)
result
=
result
+
(
"INV"
->
invCounts
)
result
}
def
writeTsvForPlots
(
counts
:
Map
[
String
,
Map
[
String
,
Array
[
Any
]]],
svTypes
:
List
[
SvTypeForReport
],
outDir
:
File
)
:
Unit
=
{
val
sampleNames
=
counts
.
keys
def
writeTsvFiles
(
sampleNames
:
List
[
String
],
counts
:
Map
[
String
,
Map
[
String
,
Array
[
Any
]]],
svTypes
:
List
[
SvTypeForReport
],
outFileAllTypes
:
String
,
outDir
:
File
)
:
Unit
=
{
val
tsvWriter
=
new
PrintWriter
(
new
File
(
outDir
,
outFileAllTypes
))
tsvWriter
.
print
(
"sv_type\tsample"
)
histogramText
.
foreach
(
bin
=>
tsvWriter
.
print
(
"\t"
+
bin
))
tsvWriter
.
println
()
for
(
sv
<-
svTypes
)
{
val
tsvFile
=
new
File
(
outDir
,
sv
.
tsvFileName
)
val
tsvWriter
=
new
PrintWriter
(
tsvFile
)
val
countsForSvType
:
Map
[
String
,
Array
[
Any
]]
=
counts
.
get
(
sv
.
svType
).
get
tsvWriter
.
print
(
"binMax"
)
sampleNames
.
foreach
(
sampleName
=>
tsvWriter
.
print
(
"\t"
+
sampleName
))
tsvWriter
.
println
()
writeTsvFileForSvType
(
sv
,
countsForSvType
,
sampleNames
,
outDir
)
for
(
i
<-
ShivaSvCalling
.
histogramBinBoundaries
.
indices
)
{
tsvWriter
.
print
(
ShivaSvCalling
.
histogramBinBoundaries
(
i
))
sampleNames
.
foreach
(
sampleName
=>
tsvWriter
.
print
(
"\t"
+
counts
.
get
(
sampleName
).
get
.
get
(
sv
.
svType
).
get
(
i
)))
tsvWriter
.
println
()
for
(
sampleName
<-
sampleNames
)
{
tsvWriter
.
print
(
sv
.
svType
+
"\t"
+
sampleName
+
"\t"
)
tsvWriter
.
println
(
countsForSvType
.
get
(
sampleName
).
get
.
mkString
(
"\t"
))
}
val
i
=
ShivaSvCalling
.
histogramBinBoundaries
.
length
tsvWriter
.
print
(
ShivaSvCalling
.
histogramBinBoundaries
(
i
-
1
)
*
10
)
sampleNames
.
foreach
(
sampleName
=>
tsvWriter
.
print
(
"\t"
+
counts
.
get
(
sampleName
).
get
.
get
(
sv
.
svType
).
get
(
i
)))
tsvWriter
.
println
()
}
tsvWriter
.
close
()
}
tsvWriter
.
close
()
def
writeTsvFileForSvType
(
svType
:
SvTypeForReport
,
counts
:
Map
[
String
,
Array
[
Any
]],
sampleNames
:
List
[
String
],
outDir
:
File
)
:
Unit
=
{
val
tsvWriter
=
new
PrintWriter
(
new
File
(
outDir
,
svType
.
tsvFileName
))
tsvWriter
.
print
(
"histogramBin"
)
sampleNames
.
foreach
(
sampleName
=>
tsvWriter
.
print
(
"\t"
+
sampleName
))
tsvWriter
.
println
()
for
(
i
<-
histogramBinBoundaries
.
indices
)
{
tsvWriter
.
print
(
histogramBinBoundaries
(
i
))
sampleNames
.
foreach
(
sampleName
=>
tsvWriter
.
print
(
"\t"
+
counts
.
get
(
sampleName
).
get
(
i
)))
tsvWriter
.
println
()
}
val
i
=
histogramBinBoundaries
.
length
tsvWriter
.
print
(
histogramBinBoundaries
(
i
-
1
)
*
10
)
sampleNames
.
foreach
(
sampleName
=>
tsvWriter
.
print
(
"\t"
+
counts
.
get
(
sampleName
).
get
(
i
)))
tsvWriter
.
println
()
tsvWriter
.
close
()
}
def
createPlots
(
svTypes
:
List
[
SvTypeForReport
],
outDir
:
File
)
:
Unit
=
{
...
...
@@ -45,11 +78,12 @@ object ShivaSvCallingReport {
val
tsvFile
=
new
File
(
outDir
,
sv
.
tsvFileName
)
val
pngFile
:
File
=
new
File
(
outDir
,
sv
.
pngFileName
)
val
plot
=
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
Some
(
s
"${sv.displayText} size"
),
xlabel
=
Some
(
s
"${sv.displayText
.substring(0, sv.displayText.length - 1)
} size"
),
ylabel
=
Some
(
"Number of loci"
),
title
=
Some
(
sv
.
displayText
+
"s"
),
width
=
6
00
,
title
=
Some
(
sv
.
displayText
),
width
=
4
00
,
removeZero
=
false
)
plot
.
height
=
Some
(
300
)
plot
.
llabel
=
Some
(
"Sample"
)
plot
.
xLog10
=
true
plot
.
yLog10
=
true
...
...
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