Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
biopet.biopet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Mirrors
biopet.biopet
Commits
0636ae0a
Commit
0636ae0a
authored
Jan 10, 2015
by
Peter van 't Hof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First version of VcfStats tool for #93
parent
06536548
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
0 deletions
+110
-0
public/biopet-framework/src/main/resources/nl/lumc/sasc/biopet/tools/plotHeatmap.R
...rc/main/resources/nl/lumc/sasc/biopet/tools/plotHeatmap.R
+24
-0
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VcfStats.scala
...k/src/main/scala/nl/lumc/sasc/biopet/tools/VcfStats.scala
+86
-0
No files found.
public/biopet-framework/src/main/resources/nl/lumc/sasc/biopet/tools/plotHeatmap.R
0 → 100644
View file @
0636ae0a
library
(
'gplots'
)
args
<-
commandArgs
(
TRUE
)
inputArg
<-
args
[
1
]
outputArg
<-
args
[
2
]
outputArgClustering
<-
args
[
3
]
col
<-
heat.colors
(
250
)
col
[
250
]
<-
"#00FF00"
heat
<-
read.table
(
inputArg
,
header
=
1
,
sep
=
'\t'
)
rownames
(
heat
)
<-
heat
[,
1
]
heat
<-
heat
[,
-1
]
heat
<-
as.matrix
(
heat
)
png
(
file
=
outputArg
,
width
=
1000
,
height
=
1000
)
heatmap.2
(
heat
,
trace
=
'none'
,
col
=
col
,
Colv
=
NA
,
Rowv
=
NA
,
dendrogram
=
"none"
)
dev.off
()
png
(
file
=
outputArgClustering
,
width
=
1000
,
height
=
1000
)
heatmap.2
(
heat
,
trace
=
'none'
,
col
=
col
,
Colv
=
"Rowv"
,
dendrogram
=
"row"
)
dev.off
()
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VcfStats.scala
0 → 100644
View file @
0636ae0a
package
nl.lumc.sasc.biopet.tools
import
java.io.
{
PrintWriter
,
File
}
import
htsjdk.variant.vcf.VCFFileReader
import
nl.lumc.sasc.biopet.core.ToolCommand
import
org.broadinstitute.gatk.utils.R.RScriptExecutor
import
org.broadinstitute.gatk.utils.io.Resource
import
scala.collection.JavaConversions._
import
scala.collection.mutable
/**
* Created by pjvan_thof on 1/10/15.
*/
class
VcfStats
{
//TODO: add Queue wrapper
}
object
VcfStats
extends
ToolCommand
{
case
class
Args
(
inputFile
:
File
=
null
,
outputDir
:
String
=
null
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
'I'
,
"inputFile"
)
required
()
unbounded
()
valueName
(
"<file>"
)
action
{
(
x
,
c
)
=>
c
.
copy
(
inputFile
=
x
)
}
opt
[
String
](
'o'
,
"outputDir"
)
required
()
unbounded
()
valueName
(
"<file>"
)
action
{
(
x
,
c
)
=>
c
.
copy
(
outputDir
=
x
)
}
}
/**
* @param args the command line arguments
*/
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
logger
.
info
(
"Started"
)
val
argsParser
=
new
OptParser
val
commandArgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
sys
.
exit
(
1
)
val
reader
=
new
VCFFileReader
(
commandArgs
.
inputFile
,
false
)
val
header
=
reader
.
getFileHeader
val
samples
=
header
.
getSampleNamesInOrder
.
toList
val
genotypeOverlap
:
mutable.Map
[
String
,
mutable.Map
[
String
,
Int
]]
=
mutable
.
Map
()
for
(
record
<-
reader
)
{
for
(
sample1
<-
samples
)
{
for
(
sample2
<-
samples
)
{
if
(
record
.
getGenotype
(
sample1
).
getAlleles
==
record
.
getGenotype
(
sample2
).
getAlleles
)
{
if
(!
genotypeOverlap
.
contains
(
sample1
))
genotypeOverlap
(
sample1
)
=
mutable
.
Map
()
val
current
=
genotypeOverlap
(
sample1
).
getOrElse
(
sample2
,
0
)
genotypeOverlap
(
sample1
)(
sample2
)
=
current
+
1
}
}
}
}
writeOverlap
(
genotypeOverlap
,
commandArgs
.
outputDir
+
"/sample_genotype_overlap"
,
samples
)
plot
(
new
File
(
commandArgs
.
outputDir
+
"/sample_genotype_overlap.rel.tsv"
))
logger
.
info
(
"Done"
)
}
def
writeOverlap
(
overlap
:
mutable.Map
[
String
,
mutable.Map
[
String
,
Int
]],
prefix
:
String
,
samples
:
List
[
String
])
:
Unit
=
{
val
absWriter
=
new
PrintWriter
(
new
File
(
prefix
+
".abs.tsv"
))
val
relWriter
=
new
PrintWriter
(
new
File
(
prefix
+
".rel.tsv"
))
absWriter
.
println
(
samples
.
mkString
(
"\t"
,
"\t"
,
""
))
relWriter
.
println
(
samples
.
mkString
(
"\t"
,
"\t"
,
""
))
for
(
sample1
<-
samples
)
{
val
values
=
for
(
sample2
<-
samples
)
yield
overlap
.
getOrElse
(
sample1
,
mutable
.
Map
()).
getOrElse
(
sample2
,
0
)
absWriter
.
println
(
values
.
mkString
(
sample1
+
"\t"
,
"\t"
,
""
))
val
total
=
overlap
.
getOrElse
(
sample1
,
mutable
.
Map
()).
getOrElse
(
sample1
,
0
)
relWriter
.
println
(
values
.
map
(
_
.
toFloat
/
total
).
mkString
(
sample1
+
"\t"
,
"\t"
,
""
))
}
absWriter
.
close
()
relWriter
.
close
()
}
def
plot
(
file
:
File
)
{
val
executor
=
new
RScriptExecutor
executor
.
addScript
(
new
Resource
(
"plotHeatmap.R"
,
getClass
))
executor
.
addArgs
(
file
,
file
.
getAbsolutePath
.
stripSuffix
(
".tsv"
)
+
".png"
,
file
.
getAbsolutePath
.
stripSuffix
(
".tsv"
)
+
".clustering.png"
)
executor
.
exec
()
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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