constantAmateur / SoupX

R package to quantify and remove cell free mRNAs from droplet based scRNA-seq data
254 stars 35 forks source link

Loading count matrix #9

Closed Jemkon closed 5 years ago

Jemkon commented 5 years ago

Hi,

I have been using SoupX for my 10X data and it seems to be working great.

But I am having issues with SoupX when I try to load count matrix. I have one count matrix. How do I create subset of it to remove empty droplets?

Here are commands:

tod <- read.delim("Maligant50.csv", row.names = 1, sep=",")    
toc <- read.delim("Maligant50.csv", row.names = 1, sep=",")    

channel1 = SoupChannel(tod,toc,channelName="channel1")
spObj = SoupChannelList(list(channel1))
spObj$channels$channel1 = estimateSoup(spObj$channels$channel1)

I am getting following error:

spObj$channels$channel1 = estimateSoup(spObj$channels$channel1)
Error in base::rowSums(x, na.rm = na.rm, dims = dims, ...) : 
  'x' must be an array of at least two dimensions

Am I doing anything wrong?

Many thanks,

spalit commented 5 years ago

Hi, I am also currently facing a similar issue. With 10X raw and filtered files, SoupX works quite well. However, I am not quite sure how one could estimate the soup with just a table of counts. Would be really helpful if you can share a workaround in case you have managed to find one. Many thanks in advance!

constantAmateur commented 5 years ago

Hmm, this looks like an issue with the loading of the sparse matrix row/column sum functions. I will try and track down the exact cause, but in the meantime I would suggest running the following before you execute the function currently throwing an error:

library(Matrix)
rowSums = Matrix::rowSums
colSums = Matrix::colSums
Jemkon commented 5 years ago

Hmm, this looks like an issue with the loading of the sparse matrix row/column sum functions. I will try and track down the exact cause, but in the meantime I would suggest running the following before you execute the function currently throwing an error:

library(Matrix)
rowSums = Matrix::rowSums
colSums = Matrix::colSums

Many thanks Matthew. I have tried running above code but got the same error.

tod <- read.delim("Maligant50.csv", row.names = 1, sep=",")    
toc <- read.delim("Maligant50.csv", row.names = 1, sep=",")    

channel1 = SoupChannel(tod,toc,channelName="channel1")
spObj = SoupChannelList(list(channel1))

library(Matrix)
rowSums = Matrix::rowSums 
colSums = Matrix::colSums

spObj$channels$channel1 = estimateSoup(spObj$channels$channel1)

Error in base::rowSums(x, na.rm = na.rm, dims = dims, ...) : 
  'x' must be an array of at least two dimensions

Have you had a chance to look at the actual cause for this error?

@spalit did you manage to find the workaround for the above issue of loading data in SoupX?

Many thanks, Jemkon

SNRNS commented 5 years ago

Hi,

I got the same error, but found the source of it. To prevent that error you just have to do:

channel1 = SoupChannel(tod,toc,channelName="Channel1", keepDroplets = TRUE)

Otherwise keepDroplets is FALSE by default, and your channel1 object does not have the tod object stored.

estimateSoup has this line of code:

sc$soupProfile = estRateLims(rowSums(sc$tod[,w,drop=FALSE]),sum(sc$tod[,w]))

If sc does not have tod, then that results in NULL and rowSums complains (of course).

ivonyao commented 4 years ago

I tried the same code, I still get the same error. basically what I did is: count=read.delim("count.csv", row.names = 1, sep=",") tod=count toc=count sc = SoupChannel(tod, toc, keepDroplets = TRUE) sc=estimateSoup(sc)

I am getting the same error

Error in base::rowSums(x, na.rm = na.rm, dims = dims, ...) : 'x' must be an array of at least two dimensions

Any comments?

brianpenghe commented 4 years ago

I've got the same error

nonafarbehi2018 commented 3 years ago

Hi all, I got the same error. Has anyone sort the problem out?

hviolaphd commented 1 year ago

Hey guys, I solved this issue for those who didn't get the other solution to work. The problem is that even if you keep droplets, the 'tod' data isn't saved in the soupx object. You have to manually add it:

sc$tod <- tod

that will enable the rest of the code to run. This seems like a dev bug