Skip to content

Commit d92ce42

Browse files
committed
Make subsampling seed input optional
1 parent 9551810 commit d92ce42

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/WGD/bin/medianCoverage.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ option_list <- list(
1919
help="compute median absolute deviation of all bins per sample [default: FALSE]"),
2020
make_option(c("-H","--header"), action="store_true", default=FALSE,
2121
help="input coverage matrix has header with sample IDs [default: FALSE]"),
22-
make_option(c("-s","--seed"), type="integer", default=NULL,
22+
make_option(c("-s","--seed"), type="integer", default=42,
2323
help="random seed for reproducible sampling [default: no seed set]"))
2424

2525
# Get command-line arguments and options
@@ -28,10 +28,8 @@ args <- parse_args(OptionParser(usage="%prog [options] covMatrix.bed OUTFILE",
2828
positional_arguments=TRUE)
2929
opts <- args$options
3030

31-
# Set random seed if provided
32-
if(!is.null(opts$seed)){
33-
set.seed(opts$seed)
34-
}
31+
# Set random seed
32+
set.seed(opts$seed)
3533

3634
# Checks for appropriate positional arguments
3735
if(length(args$args) != 2)

wdl/MedianCov.wdl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ workflow MedianCov {
1111
Float? mem_gb_override
1212
String sv_pipeline_qc_docker
1313
RuntimeAttr? runtime_attr
14-
Int? subsample_seed = 42
14+
Int? subsample_seed
1515
}
1616

1717
call CalcMedCov {
@@ -33,7 +33,7 @@ task CalcMedCov {
3333
input {
3434
File bincov_matrix
3535
String cohort_id
36-
Int sesubsample_seeded
36+
Int? subsample_seed
3737
Float? mem_gb_override
3838
String sv_pipeline_qc_docker
3939
RuntimeAttr? runtime_attr_override
@@ -56,7 +56,11 @@ task CalcMedCov {
5656
5757
set -euo pipefail
5858
zcat ~{bincov_matrix} > ~{cohort_id}_fixed.bed
59-
Rscript /opt/WGD/bin/medianCoverage.R ~{cohort_id}_fixed.bed -H --seed ~{subsample_seed} ~{cohort_id}_medianCov.bed
59+
Rscript /opt/WGD/bin/medianCoverage.R \
60+
~{cohort_id}_fixed.bed \
61+
-H \
62+
~{if defined(subsample_seed) then "--seed ~{subsample_seed}" else ""}
63+
~{cohort_id}_medianCov.bed
6064
Rscript -e "x <- read.table(\"~{cohort_id}_medianCov.bed\",check.names=FALSE); xtransposed <- t(x[,c(1,2)]); write.table(xtransposed,file=\"~{cohort_id}_medianCov.transposed.bed\",sep=\"\\t\",row.names=F,col.names=F,quote=F)"
6165
6266
>>>

0 commit comments

Comments
 (0)