-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Hi, I am using the FractionCountsInRegion(object, some_peaks, assay="peaks")
and it occasionaly throws me this error:
Error in base::colSums(x, na.rm = na.rm, dims = dims, ...) :
'x' must be an array of at least two dimensions
Called from: base::colSums(x, na.rm = na.rm, dims = dims, ...)
I tried using only CountsInRegion so then to eliminate colSum error but then it gave me this error:
Error in match(x, table, nomatch = 0L) :
'match' requires vector arguments
Called from: i %in% colnames(x = slot(object = x, name = "meta.data"))
I have noticed that seldom this error goes away if I specify an alternative option in FractionCountsInRegion(), for example FractionCountsInRegion(type="start"). So I am guessing this is related to the function not able to find overlaps with the peaks in the object. However, I'd expect it to return 0 as it does usually, and not throw this error.
Please let me know how could I resolve this.
Update: I broke down the code,
overlaps <- findOverlaps(query = granges(atac8), subject = da_regions[15])
hit.regions <- queryHits(x = overlaps)
data.matrix <- GetAssayData(object = atac8, assay = "peaks", slot = "counts")[hit.regions, ]
data_matrix <- data.frame(data.matrix)
a <- colSums(data_matrix$data.matrix)
Error in base::colSums(x, na.rm = na.rm, dims = dims, ...) :
'x' must be an array of at least two dimensions
Interesting, doing this resolves the error:
data_matrix <- data.frame(data.matrix)
a <- colSums(data_matrix)
So, I think that the problem is when "regions" specified don't produce a 2-d matrix but a 1-d list.
> head(overlaps)
Hits object with 1 hit and 0 metadata columns:
queryHits subjectHits
<integer> <integer>
[1] 73331 1
-------
versus
Hits object with 2 hits and 0 metadata columns:
queryHits subjectHits
<integer> <integer>
[1] 84297 1
[2] 84298 1
It would be great if CountsInRegion and FractionCountsInRegion could be updated to remove this error, or if you could suggest a work around it.
In addition, is it possible that slot="data" can be added to the function, to get TF-IDF normalized counts, instead of only by default overlaps with "count"
Thanks!