Skip to content
Snippets Groups Projects
Unverified Commit 8159674a authored by Peter van 't Hof's avatar Peter van 't Hof Committed by GitHub
Browse files

Merge pull request #6 from biowdl/mergeCounts

add merge counts
parents fddfd687 bd611a3b
No related branches found
No related tags found
No related merge requests found
task MergeCounts {
String? preCommand
Array[File] inputFiles
String outputFile
String idVar
String measurementVar
# Based on a script by Szymon Kielbasa/Ioannis Moustakas
command <<<
set -e -o pipefail
${preCommand}
R --no-save --slave <<CODE > ${outputFile}
library(dplyr)
library(reshape2)
listOfFiles <- c("${sep='", "' inputFiles}")
d <- do.call(rbind, lapply(listOfFiles, function(file){
d <- read.table(file, header=TRUE, comment.char="#")
colI <- grep(${measurementVar}, colnames(d))
colnames(d)[colI] <- strsplit(file, "/")[[1]][3]
d <- d %>% melt(id.vars=${idVar}, measure.vars=colI,
variable.name="sample", value.name="count")
}))
d <- d %>% dcast(paste0(${idVar}, " ~ sample"), value.var="count")
write.table(d, sep="\t", quote=FALSE, row.names=FALSE)
CODE
>>>
output {
File mergedCounts = outputFile
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment