1
$\begingroup$

I am having a SingleCellExperiment (sce) object:

sce <- SingleCellExperiment(list(counts=UMI_count))

which has two dimensions:

dim(sce)
[1] 46761 68027

When I am trying to get column sums for all rows the following does not work:

colSums(assay(sce), na.rm = FALSE, dims = 1)

Giving me an error:

Error in colSums(assay(sce)) : 'x' must be an array of at least two dimensions

Apparently the issue was already described:

https://support.bioconductor.org/p/100954/

However, I can not find the solution. Is there another way of getting sums of columns of either SingleCellExperiment object or just dgcMatrix?

$\endgroup$
  • $\begingroup$ Are you trying to get the sum of the rows or the columns? $\endgroup$ – AudileF Dec 20 '17 at 9:09
  • $\begingroup$ Did you check what does assay(sce) return? Which is the output of dim(assay(sce)) ? $\endgroup$ – llrs Dec 21 '17 at 8:17
0
$\begingroup$

Ultimately I just implemented it manually with the precursor to SingleCellExperiment matrix (UMI_count which is dgcMatrix type) object in the following way:

# Removing genes with 0 - counts in all of the columns
num_removed = 0
for(i in 1:nrow(UMI_count)) {
  idx = i - num_removed
  if(sum(UMI_count[idx,]) < 1) {
    UMI_count <- UMI_count[-idx,]
    num_removed = num_removed + 1
    print(i)
  }
}

sce <- SingleCellExperiment(list(counts=UMI_count))

I am getting sums of the columns for each row and then filtering out rows with the sum < 1. So, sum function for the slices - rows (numeric type) is working.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.