Thank you for developing a useful library.
But, there seems to be a bug in getTagMatrix.internal function in tagMatrix.R.
# --- from Line 521
windows <- subsetByOverlaps(windows, cov.width,
type="within", ignore.strand=FALSE)
chr.idx <- intersect(names(peak.cov),
unique(as.character(seqnames(windows))))
peakView <- Views(peak.cov[chr.idx], as(windows, "IntegerRangesList")[chr.idx])
tagMatrixList <- lapply(peakView, function(x) t(viewApply(x, as.vector)))
tagMatrix <- do.call("rbind", tagMatrixList)
## get the index of windows, that are reorganized by as(windows, "IntegerRangesList")
idx.list <- split(1:length(windows), as.factor(seqnames(windows)))
idx <- do.call("c", idx.list)
rownames(tagMatrix) <- idx
tagMatrix <- tagMatrix[order(idx),]
I guess it tries to copy the indexes of windows to tagMatrix's rownames.
But, it won't work because peakView and idx.list do not have the same order of chromosome numbers.
peakView: $chr1, $chr2, $chr3, ...
idx.list: $chr1, $chr10, $chr11, ...
It'll cause to disconnect between tagMatrix index and window index.
I suggest the fixed code below, but I don't know it's the best way.
# --- from Line 521
windows <- subsetByOverlaps(windows, cov.width,
type="within", ignore.strand=FALSE)
chr.idx <- intersect(names(peak.cov),
unique(as.character(seqnames(windows))))
peakView <- Views(peak.cov[chr.idx], as(windows, "IntegerRangesList")[chr.idx])
tagMatrixList <- lapply(peakView, function(x) t(viewApply(x, as.vector)))
tagMatrix <- do.call("rbind", tagMatrixList)
## get the index of windows, that are reorganized by as(windows, "IntegerRangesList")
idx.list <- split(1:length(windows), as.factor(seqnames(windows)))
# ---modification
# idx <- do.call("c", idx.list)
idx = c()
for(i in chr.idx){
idx = c(idx, idx.list[[i]])
}
# --- end modification
rownames(tagMatrix) <- idx
tagMatrix <- tagMatrix[order(idx),]
Dear Pr Guangchuang Yu,
Thank you for developing a useful library. But, there seems to be a bug in getTagMatrix.internal function in tagMatrix.R.
I guess it tries to copy the indexes of windows to tagMatrix's rownames. But, it won't work because peakView and idx.list do not have the same order of chromosome numbers.
It'll cause to disconnect between tagMatrix index and window index.
I suggest the fixed code below, but I don't know it's the best way.