-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I subset based on RAW counts? #9459
Comments
Hi, Not member of dev team but hopefully can be helpful. Can you please post the full code you are running and the full text of the error messages? Thanks, |
For subsetting based on non-default assay data, I find that some use of the If I had a transgene called Tgx and wanted to retain only the cells with at least two reads for Tgx in the raw RNA counts matrix, I would do something like: object %<>% (\(o) o[ , o$RNA$counts["Tgx", ] >= 2 ]) Here's an example where I subset pbmc_small %>% (\(o) o[ , o$RNA$counts["CTSS", ] > 0 ])
|
Hi, You can do this a couple of ways using the accessor functions provided in Seurat or directly using subset.
Best, |
@alexwskh the short answers:
I suppose an enhancement could be to parse out assay names from the |
Thank you everyone who responded, I really appreciate the help! @samuel-marsh, let me try to lay out the relevant pieces... The quick summary of the seurat object is as such (with SCT as default assay) I'm trying to subset on raw counts for a transgene because I noticed after SCT normalization and across assays, some cells are normalized to zero transcript counts. If I pick up a single transgenic count (which might be overly lenient sure), I want to keep those cells. So I switch the default assay to RNA and try to subset based on counts. DefaultAssay(seurthresh2) <- "RNA"
On other Seurat functions it will default to counts if the data layer is not present, so I wasn't sure how to grab what I wanted. It looks like both you and @rharao confirmed that I can use slot = "counts" after switching my assay to RNA in order to subset based on raw counts, and then switching back to SCT on the main object. Thanks! To highlight my issue, here is the truncated table of eGFP counts after subsetting gfp > 0 from the RNA assay, counts slot. First from the RNA assay and then from the SCT assay. RNA Assay, Table() of FetchData for transgenic GFP 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 SCT Assay, Table() of FetchData for transgenic GFP 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 If I subset based on the transformed counts on the SCT assay, I am losing 1346 cells from my analysis as the normalized counts are zeroed for those cells. Thanks again, though please point out if I am misunderstanding anything. |
Hello,
I am having trouble subsetting a seurat object based on raw counts (expression of transgenes). I simply want to subset based on non-transformed data. I tried this by setting the assay to RNA and then subsetting, but I get an error saying that the data layer does not exist. Is the counts layer from the SCT assay equivalent to the counts layer of RNA? If so, can I just specify slot = "counts" in the subset function?
I think I am losing some cells of interest when subsetting expression based on transformed data, so that is why I am pursuing this.
This is a dataset that is integrated from several scRNAseq experiments.
Thanks for any help.
The text was updated successfully, but these errors were encountered: