Skip to content

Commit

Permalink
Removed redundant writeCalls function. CNV calls are now stored in
Browse files Browse the repository at this point in the history
standard calls slot, so exportBins can now be used.

Modified exportVCF to take data from the objects calls data slot.
  • Loading branch information
daoud-sie committed Oct 18, 2016
1 parent aa82c1b commit 911f6ed
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions R/exportBins.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@ exportBins <- function(object, file, format=c("tsv", "igv", "bed"),

exportVCF <- function(obj) {

calls <- assayDataElement(obj, "cnvCalls")
segments <- log2(assayDataElement(obj, "segmented"))
calls <- assayDataElement(obj, "calls")
segments <- log2adhoc(assayDataElement(obj, "segmented"))

fd <- fData(obj)
pd <- pData(obj)

vcfHeader <- cbind(c(
'##fileformat=VCFv4.2',
paste('##source=QDNAseq-', packageVersion("QDNAseq"), sep=""),
Expand All @@ -178,13 +181,10 @@ exportVCF <- function(obj) {
'##INFO=<ID=LOG2CNT,Number=1,Type=Float,Description="Log 2 count">',
'##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">'
))
fd <- fData(obj)
pd <- pData(obj)


for (i in 1:ncol(calls)) {
d <- cbind(fd[,1:3],calls[,i], segments[,i])
sel <- d[,4] != 0
sel <- d[,4] != 0 & !is.na(d[,4])

dsel <- d[sel,]

Expand Down Expand Up @@ -233,18 +233,4 @@ exportVCF <- function(obj) {
}
}

writeCalls <- function(calls, file, object) {
fd <- fData(object)
chromosome <- fd$chromosome
start <- fd$start
end <- fd$end
feature <- rownames(fd)
dat <- calls
out <- data.frame(chromosome = chromosome, start = start,
end = end, feature = feature, dat, check.names = FALSE,
stringsAsFactors = FALSE)
cat("#type=COPY_NUMBER\n#track coords=1\n", file = file)
suppressWarnings(write.table(out, file = file, append = TRUE, quote = FALSE, sep = "\t", na = "", row.names = FALSE))
}

#EOF

0 comments on commit 911f6ed

Please sign in to comment.