satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.26k stars 905 forks source link

VlnPlot error when use seurat V5 assays. Error in if (all(data[, feature] == data[, feature][1])) { : missing value where TRUE/FALSE needed #9064

Open wangbenwang123 opened 3 months ago

wangbenwang123 commented 3 months ago

When I use assays separated by sample in V5 format to plot the VlnPlot of the RPS4Y1 gene, I get the error:

Error in if (all(data[, feature] == data[, feature][1])) { : 
  missing value where TRUE/FALSE needed

However, when using assays from an object combined by JoinLayers, the error does not occur. I would like to understand why this happens and how to resolve it. Below is the record of my code execution.

sc[['origin']] <- JoinLayers(sc[["RNA"]], layers= "counts")

> DefaultAssay(sc) = 'RNA' # RNA or origin

> p1 = VlnPlot(sc, features = "XIST",group.by = "sample")
Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.
Warning messages:
1: Removing 9539 cells missing data for features requested 
2: Removing 9539 cells missing data for vars requested 

> p2 = VlnPlot(sc, features = "RPS4Y1",group.by = "sample")
Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.
Error in if (all(data[, feature] == data[, feature][1])) { : 
  missing value where TRUE/FALSE needed
In addition: Warning messages:
1: Removing 10874 cells missing data for features requested 
2: Removing 10874 cells missing data for vars requested 

> DefaultAssay(sc) = 'origin' # RNA or origin

> p3 = VlnPlot(sc, features = "RPS4Y1",group.by = "sample")
Warning: Default search for "data" layer in "origin" assay yielded no results; utilizing "counts" layer instead.
apal6 commented 1 month ago

Hi, I would like to follow up on this as I am having the same issue. I was able to run the command before but now it is giving me this error. Would you mind sharing how you fixed it? sobj[["percent.mt"]] <- PercentageFeatureSet(sobj, pattern = "^MT") VlnPlot(sobj, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3) error: Warning: Default search for "data" layer in "origin" assay yielded no results; utilizing "counts" layer instead. Error in if (all(data[, feature] == data[, feature][1])) { : missing value where TRUE/FALSE needed

Thank you in advance.

wangbenwang123 commented 2 weeks ago

嗨,我想跟进这个问题,因为我遇到了同样的问题。我以前能够运行该命令,但现在它给我这个错误。您介意分享您是如何修复它的吗? 错误:sobj[["percent.mt"]] <- PercentageFeatureSet(sobj, pattern = "^MT") VlnPlot(sobj, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3) Warning: Default search for "data" layer in "origin" assay yielded no results; utilizing "counts" layer instead. Error in if (all(data[, feature] == data[, feature][1])) { : missing value where TRUE/FALSE needed

提前谢谢你。

As you can see, I used sc[['origin']] <- JoinLayers(sc[["RNA"]], layers= "counts") to store an 'origin' assay that contains data from before the split. Therefore, when visualizing with VlnPlot, the unsplit assay should preferably be used.