monocle3 icon indicating copy to clipboard operation
monocle3 copied to clipboard

Error in plot_cells - None of the provided genes were found in the cds

Open lucygarner opened this issue 3 years ago • 11 comments

** If this is a question and not a bug report or enhancement request, please post to our google group at https://groups.google.com/forum/#!forum/monocle-3-users**

Describe the bug Error in plot_cells in that it can't find the genes in my cell_data_set object. This issue was discussed here: https://github.com/cole-trapnell-lab/monocle3/issues/341 I have installed the devel version from GitHub, but I am still having the issue

To Reproduce The code that produced the bug:

plot_cells(cds, genes = c("IFNG", "GZMB"),
           show_trajectory_graph = FALSE,
           label_cell_groups = FALSE,
           label_leaves = FALSE)

"IFNG" %in% rownames(rowData(cds))   # TRUE
"GZMB" %in% rownames(rowData(cds))    # TRUE

"IFNG" %in% rowData(cds)$gene_name    # TRUE
"GZMB" %in% rowData(cds)$gene_name    # TRUE

traceback() After the error, run traceback() in R and post the output:

2: stop("None of the provided genes were found in the cds") 1: plot_cells(cds, genes = DE_gene_ids, show_trajectory_graph = FALSE, label_cell_groups = FALSE, label_leaves = FALSE)

Expected behavior Expression of IFNG and GZMB plotted along the trajectories.

sessionInfo():

R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] shiny_1.4.0.2               magrittr_1.5                patchwork_1.0.0            
 [4] monocle3_0.2.3.0            SingleCellExperiment_1.10.1 SummarizedExperiment_1.18.2
 [7] DelayedArray_0.14.1         matrixStats_0.56.0          GenomicRanges_1.40.0       
[10] GenomeInfoDb_1.24.2         IRanges_2.22.2              S4Vectors_0.26.1           
[13] Biobase_2.48.0              BiocGenerics_0.34.0         Seurat_3.1.5               
[16] SeuratWrappers_0.3.0       

loaded via a namespace (and not attached):
  [1] backports_1.1.8        plyr_1.8.6             igraph_1.2.5           lazyeval_0.2.2        
  [5] sp_1.4-2               splines_4.0.3          listenv_0.8.0          usethis_1.6.3         
  [9] ggplot2_3.3.1          inline_0.3.15          digest_0.6.25          htmltools_0.5.0       
 [13] viridis_0.5.1          rsconnect_0.8.16       gdata_2.18.0           fansi_0.4.1           
 [17] memoise_1.1.0          cluster_2.1.0          ROCR_1.0-11            remotes_2.2.0         
 [21] globals_0.12.5         gmodels_2.18.1         RcppParallel_5.0.1     prettyunits_1.1.1     
 [25] colorspace_1.4-1       ggrepel_0.8.2          xfun_0.14              dplyr_1.0.0           
 [29] callr_3.5.1            crayon_1.3.4           RCurl_1.98-1.2         jsonlite_1.7.1        
 [33] survival_3.2-7         zoo_1.8-8              ape_5.4                glue_1.4.1            
 [37] gtable_0.3.0           zlibbioc_1.34.0        XVector_0.28.0         leiden_0.3.3          
 [41] pkgbuild_1.1.0         rstan_2.19.3           future.apply_1.5.0     scales_1.1.1          
 [45] DBI_1.1.0              Rcpp_1.0.4.6           viridisLite_0.3.0      xtable_1.8-4          
 [49] spData_0.3.8           units_0.6-7            reticulate_1.16        spdep_1.1-5           
 [53] rsvd_1.0.3             proxy_0.4-24           tsne_0.1-3             StanHeaders_2.21.0-5  
 [57] htmlwidgets_1.5.1      httr_1.4.2             RColorBrewer_1.1-2     speedglm_0.3-2        
 [61] ellipsis_0.3.1         ica_1.0-2              pkgconfig_2.0.3        loo_2.2.0             
 [65] farver_2.0.3           deldir_0.1-29          uwot_0.1.8             tidyselect_1.1.0      
 [69] labeling_0.3           rlang_0.4.8            reshape2_1.4.4         later_1.1.0.1         
 [73] pbmcapply_1.5.0        munsell_0.5.0          tools_4.0.3            cli_2.0.2             
 [77] generics_0.0.2         devtools_2.3.2         ggridges_0.5.2         stringr_1.4.0         
 [81] fastmap_1.0.1          yaml_2.2.1             fs_1.4.1               processx_3.4.4        
 [85] knitr_1.28             fitdistrplus_1.1-1     purrr_0.3.4            RANN_2.6.1            
 [89] packrat_0.5.0          pbapply_1.4-2          future_1.17.0          nlme_3.1-149          
 [93] mime_0.9               slam_0.1-47            compiler_4.0.3         rstudioapi_0.11       
 [97] plotly_4.9.2.1         curl_4.3               png_0.1-7              testthat_2.3.2        
[101] e1071_1.7-4            tibble_3.0.1           stringi_1.4.6          ps_1.3.3              
[105] desc_1.2.0             lattice_0.20-41        Matrix_1.2-18          classInt_0.4-3        
[109] vctrs_0.3.1            LearnBayes_2.15.1      pillar_1.4.4           lifecycle_0.2.0       
[113] BiocManager_1.30.10    lmtest_0.9-38          RcppAnnoy_0.0.16       data.table_1.13.2     
[117] cowplot_1.0.0          bitops_1.0-6           irlba_2.3.3            raster_3.3-13         
[121] httpuv_1.5.4           R6_2.4.1               promises_1.1.1         renv_0.10.0-46        
[125] KernSmooth_2.23-17     gridExtra_2.3          sessioninfo_1.1.1      codetools_0.2-16      
[129] pkgload_1.1.0          gtools_3.8.2           boot_1.3-25            MASS_7.3-53           
[133] assertthat_0.2.1       leidenbase_0.1.2       rprojroot_1.3-2        withr_2.2.0           
[137] sctransform_0.2.1      GenomeInfoDbData_1.2.3 expm_0.999-5           grid_4.0.3            
[141] coda_0.19-4            class_7.3-17           tidyr_1.1.0            Rtsne_0.15            
[145] sf_0.9-6   

lucygarner avatar Oct 28 '20 12:10 lucygarner

Can you try running "IFNG" %in% row.names(rowData(cds)) I'm wondering if this is an issue with the class after conversion from Seurat.

As a quick fix, if you run rowData(cds)$gene_short_name <- rowData(cds)$gene_name should solve the issue in your particular case

hpliner avatar Nov 02 '20 10:11 hpliner

Hi @hpliner,

"IFNG" %in% row.names(rowData(cds)) gives TRUE so I don't think the class is an issue

Thank you, your quick fix seemed to work.

Best wishes, Lucy

lucygarner avatar Nov 02 '20 11:11 lucygarner

I am following the vignette and trying to plot the following from the Differential expression analysis section.

plot_cells(cds,
           genes=gene_module_df %>% filter(module %in% c(27, 10, 7, 30)),
           label_cell_groups=FALSE,
           show_trajectory_graph=FALSE)

My gene_module_df looks as follows:

image

I was wondering where the plot_cells function is getting the module expression values from as mine look very low/hardly expressed.

Best wishes, Lucy

lucygarner avatar Nov 02 '20 14:11 lucygarner

I managed to get mine to work with the following:

rowData(cds)$gene_name <- rownames(cds)
rowData(cds)$gene_short_name <- rowData(cds)$gene_name

Somehow the rownames is not getting through.

mys721tx avatar Nov 25 '20 11:11 mys721tx

Thanks, I will try that.

lucygarner avatar Nov 25 '20 12:11 lucygarner

Hi all,

I do still get troubles to plot genes using plot_cells following the use of as.cell_data_set(seurat_object, reductions "ump") despite the lines from @mys721tx, I got this error:

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 't': attempt to set an attribute on NULL

Any ideas that could help?

Best and thanks for your time.

silvainp avatar Feb 01 '21 16:02 silvainp

In my case, this turned out to be an error propagated from using SeuratWrappers to convert from a Seurat object to a Monocle object. The stepwise conversion discussed in this thread solved the issue for me: https://github.com/satijalab/seurat-wrappers/issues/54

msraredon avatar Feb 15 '21 23:02 msraredon

As msraredon mentioned, I also encountered the same problem after converting a Seurat object into a Monocle object via SeuratWrapper. In my case, these tricks worked well.

  1. Before converting Seurat objects, run this. [email protected] = 'RNA' ref. seurat-wrappers issue

  2. Run these commands as mys721tx presented.

rowData(cds)$gene_name <- rownames(cds)
rowData(cds)$gene_short_name <- rowData(cds)$gene_name
  1. When plotting, "reduction_method" should be "UMAP".
plot_cells(cds, 
           genes="Gapdh",
           show_trajectory_graph=FALSE,
           label_cell_groups=FALSE,
           label_leaves=FALSE,
           reduction_method = "UMAP")

rouninnomi avatar Jun 28 '22 03:06 rouninnomi

Hi all, I also have the same problem after converting seurat object to a cds using the as.cell_data_set function. However, I did integrate some datasets before. So, I have two assays in seurat object, which are "RNA" and "integrated". I met this error: attempt to set an attribute on NULL Because I need integrated assay, so, in addition to @rouninnomi 's methods. I manually modified the names of these two assay before set active.assay as "RNA". names(Seurat_object@assays)<-c("integrated","RNA")

As msraredon mentioned, I also encountered the same problem after converting a Seurat object into a Monocle object via SeuratWrapper. In my case, these tricks worked well.

  1. Before converting Seurat objects, run this. [email protected] = 'RNA' ref. seurat-wrappers issue
  2. Run these commands as mys721tx presented.
rowData(cds)$gene_name <- rownames(cds)
rowData(cds)$gene_short_name <- rowData(cds)$gene_name
  1. When plotting, "reduction_method" should be "UMAP".
plot_cells(cds, 
           genes="Gapdh",
           show_trajectory_graph=FALSE,
           label_cell_groups=FALSE,
           label_leaves=FALSE,
           reduction_method = "UMAP")

xiangmingcai avatar Feb 18 '23 20:02 xiangmingcai

I managed to get mine to work with the following:

rowData(cds)$gene_name <- rownames(cds)
rowData(cds)$gene_short_name <- rowData(cds)$gene_name

Somehow the rownames is not getting through.

Fatemeh99m avatar Apr 10 '24 07:04 Fatemeh99m

Thanks. thats helpful!!

Fatemeh99m avatar Apr 10 '24 07:04 Fatemeh99m