constantAmateur / SoupX

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

PlotMarkerDistribution Error #35

Closed deevdevil88 closed 4 years ago

deevdevil88 commented 4 years ago

Hello, I am trying to use the PlotMarkerDistrbution function to infer the non-expressedgene list . However, i keep getting an error regarding indexing. I believe the error is popping up because i am switching out the toc matrix in the SoupChannel with the filtered Seurat count matrix. This filtered matrix has less number of genes than the raw count matrix. Now i tried only filtering out the cellids in the Cellranger filtered matrix that are not used in seurat object to keep the same gene counts as in the ambient profile or soup. But then the resulting graphs from the plotmarkemap changes drastically. Can i possibly reduce the raw gene matrix gene numbers to the same as the one in the seurat object, or is that biasing the analysis?

Thanks, Devika

constantAmateur commented 4 years ago

I see no issue in removing genes you're not interested in from the raw matrix if that fixes your problem. If you are willing to share a saved version of your loaded data at the point it's throwing the error I'm willing to see if there's an easy fix that can be implemented.

deevdevil88 commented 4 years ago

Hi @constantAmateur ok its good to know that i can also filter out the genes in the raw matrix if they dont pass QC in Seurat for the toc. However like you said i dont know an easy way of swapping out the raw matrix. so here is a the loaded data google drive link (https://drive.google.com/file/d/18AoOVrtu9HDfyqwcV719YZnur3lx-pn7/view?usp=sharing)after swapping out the toc (Cell Ranger filtered object) with the Seurat analysed data.

This is the error i get plotMarkerDistribution(MaleVNSRep1_sc) Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : invalid character indexing

constantAmateur commented 4 years ago

Did you drop the rows from your table of counts before or after constructing the soup channel object? It looks to me like you subsetted the table of counts after constructing the soup channel object.

I don't think there's an issue with using a reduced matrix, but you should make this adjustment before loading your data with SoupChannel. You can "fix up" the object you sent me by doing the following:

sc$tod = sc$tod[rownames(sc$toc),]
sc$soupProfile = sc$soupProfile[rownames(sc$toc),]

But I would recommend just making whatever adjustments to the count matrix you are going to do first, rather than modifying the SoupChannel object after it is loaded.

deevdevil88 commented 4 years ago

You are right , as i based it on the tutorial i first created a SoupCahnnel object then dropped the rows. As i wasnt sure how i could do it before. i guess , I should have the reduced matrix for both the raw data and the filtered data in one directory exactly like the cellranger raw and filtered in the tutorial and then load SoupChannel? it wasnt obvious to me how i can point the SoupChannel function to the relevant folders before the SC object is loaded. As the function you have in the tutorial is load10x, which takes cellranger naming convention.

Thank you for getting back to me.