Skip to content
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

plot_measure_dim error #20

Open
WesAus10 opened this issue Apr 13, 2022 · 3 comments
Open

plot_measure_dim error #20

WesAus10 opened this issue Apr 13, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@WesAus10
Copy link

Hi, I recently found your package and love it but I ran into an error when trying to call plot_measure_dim. Example below uses the tutorial data.

> plot_measure_dim(dataset = scRNA_int, 
+          measures = c("nFeature_RNA","nCount_RNA","percent.mt","KRT14"))
Error in `plot_measure_dim()`:
! Can't subset `.data` outside of a data mask context.
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/rlang_error>
Error in `plot_measure_dim()`:
! Can't subset `.data` outside of a data mask context.
---
Backtrace:
 1. Scillus::plot_measure_dim(...)
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/rlang_error>
Error in `plot_measure_dim()`:
! Can't subset `.data` outside of a data mask context.
---
Backtrace:
    ▆
 1. └─**Scillus**::plot_measure_dim(...)
 2.   ├─ggplot2::scale_color_viridis_c(...)
 3.   │ └─ggplot2::continuous_scale(...)
 4.   ├─**stats**::quantile(.data[[measures[i]]], probs = 0.1)
 5.   ├─<unknown>
 6.   └─**rlang**:::`[[.rlang_fake_data_pronoun`(.data, measures[i])
 7.     └─rlang:::stop_fake_data_subset(call)
 8.       └─rlang::abort(...)

Here's my sessionInfo

> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.3

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] magrittr_2.0.3     SeuratObject_4.0.4 Seurat_4.1.0       forcats_0.5.1     
 [5] stringr_1.4.0      dplyr_1.0.8        purrr_0.3.4        readr_2.1.2       
 [9] tidyr_1.2.0        tibble_3.1.6       ggplot2_3.3.5      tidyverse_1.3.1   
[13] Scillus_0.5.0     

loaded via a namespace (and not attached):
  [1] readxl_1.4.0          backports_1.4.1       circlize_0.4.14      
  [4] plyr_1.8.7            igraph_1.3.0          lazyeval_0.2.2       
  [7] splines_4.1.3         listenv_0.8.0         scattermore_0.8      
 [10] digest_0.6.29         foreach_1.5.2         htmltools_0.5.2      
 [13] formattable_0.2.1     fansi_1.0.3           tensor_1.5           
 [16] cluster_2.1.3         doParallel_1.0.17     ROCR_1.0-11          
 [19] tzdb_0.3.0            ComplexHeatmap_2.10.0 globals_0.14.0       
 [22] modelr_0.1.8          matrixStats_0.61.0    R.utils_2.11.0       
 [25] spatstat.sparse_2.1-0 colorspace_2.0-3      rvest_1.0.2          
 [28] ggrepel_0.9.1         haven_2.4.3           xfun_0.30            
 [31] crayon_1.5.1          jsonlite_1.8.0        spatstat.data_2.1-4  
 [34] survival_3.3-1        zoo_1.8-9             iterators_1.0.14     
 [37] glue_1.6.2            polyclip_1.10-0       gtable_0.3.0         
 [40] leiden_0.3.9          GetoptLong_1.0.5      future.apply_1.8.1   
 [43] shape_1.4.6           BiocGenerics_0.40.0   abind_1.4-5          
 [46] scales_1.1.1          DBI_1.1.2             spatstat.random_2.2-0
 [49] miniUI_0.1.1.1        Rcpp_1.0.8.3          viridisLite_0.4.0    
 [52] xtable_1.8-4          clue_0.3-60           reticulate_1.24      
 [55] spatstat.core_2.4-2   stats4_4.1.3          htmlwidgets_1.5.4    
 [58] httr_1.4.2            RColorBrewer_1.1-3    ellipsis_0.3.2       
 [61] ica_1.0-2             farver_2.1.0          R.methodsS3_1.8.1    
 [64] pkgconfig_2.0.3       uwot_0.1.11           dbplyr_2.1.1         
 [67] deldir_1.0-6          utf8_1.2.2            labeling_0.4.2       
 [70] tidyselect_1.1.2      rlang_1.0.2           reshape2_1.4.4       
 [73] later_1.3.0           cellranger_1.1.0      munsell_0.5.0        
 [76] tools_4.1.3           cli_3.2.0             generics_0.1.2       
 [79] broom_0.8.0           ggridges_0.5.3        evaluate_0.15        
 [82] fastmap_1.1.0         goftest_1.2-3         fs_1.5.2             
 [85] knitr_1.38            fitdistrplus_1.1-8    RANN_2.6.1           
 [88] pbapply_1.5-0         future_1.24.0         nlme_3.1-157         
 [91] mime_0.12             R.oo_1.24.0           xml2_1.3.3           
 [94] rstudioapi_0.13       compiler_4.1.3        plotly_4.10.0        
 [97] png_0.1-7             spatstat.utils_2.3-0  reprex_2.0.1         
[100] stringi_1.7.6         RSpectra_0.16-0       lattice_0.20-45      
[103] Matrix_1.4-1          vctrs_0.4.1           pillar_1.7.0         
[106] lifecycle_1.0.1       spatstat.geom_2.4-0   lmtest_0.9-40        
[109] GlobalOptions_0.1.2   RcppAnnoy_0.0.19      data.table_1.14.2    
[112] cowplot_1.1.1         irlba_2.3.5           httpuv_1.6.5         
[115] patchwork_1.1.1       R6_2.5.1              promises_1.2.0.1     
[118] KernSmooth_2.23-20    gridExtra_2.3         IRanges_2.28.0       
[121] parallelly_1.31.0     codetools_0.2-18      MASS_7.3-56          
[124] assertthat_0.2.1      rjson_0.2.21          withr_2.5.0          
[127] sctransform_0.3.3     S4Vectors_0.32.4      mgcv_1.8-40          
[130] parallel_4.1.3        hms_1.1.1             grid_4.1.3           
[133] rpart_4.1.16          rmarkdown_2.13        Rtsne_0.15           
[136] shiny_1.7.1           lubridate_1.8.0
@WesAus10 WesAus10 added the bug Something isn't working label Apr 13, 2022
@yaqi2731
Copy link

The same mistake!

@yaqi2731
Copy link

Excuse me, has this problem been solved? Is there any technician who can help to solve it?

@NCtraveling
Copy link

NCtraveling commented Jan 12, 2024

ISSUE SOLVED @WesAus10 @yaqi2731

I got this error too. I tried to change every .data to df in the source code of the function plot_measure_dim()

Fortunately, it works!!! But I don't understand why...

You could build a new function (e.g. plot_measure_dim2) by yourselves:

plot_measure_dim2 <- function (dataset, measures, split_by = NA, point.size = 1) 
  {
    l <- get_measure_data(dataset = dataset, measures = measures, 
                          return_df = FALSE)
    split_by <- ifelse(split_by == "No Split", NA, split_by)
    df <- l[[1]]
    measures <- l[[2]]
    p <- list()
    for (i in seq_along(1:length(measures))) {
      p[[i]] <- ggplot(df) + geom_point(aes(x = UMAP_1, 
                                            y = UMAP_2, color = df[[measures[i]]]), 
                                        size = point.size) + scale_color_viridis_c(option = "A", 
                                                                                   name = "", direction = -1, limits = c(quantile(df[[measures[i]]], 
                                                                                                                                  probs = 0.1), quantile(df[[measures[i]]], 
                                                                                                                                                         probs = 0.9)), oob = scales::squish) + theme(panel.grid.major = element_blank(), 
                                                                                                                                                                                                      panel.grid.minor = element_blank(), panel.background = element_blank(), 
                                                                                                                                                                                                      axis.text = element_text(size = 12), axis.title = element_text(size = 12), 
                                                                                                                                                                                                      panel.border = element_rect(colour = "black", fill = NA, 
                                                                                                                                                                                                                                  linewidth = 1, linetype = 1), axis.line = element_blank()) + 
        labs(x = "UMAP_1", y = "UMAP_2") + ggtitle(measures[i]) + 
        if (!is.na(split_by)) {
          facet_wrap(as.formula(paste("~", split_by)))
        }
      else {
        theme(aspect.ratio = 1)
      }
    }
    patchwork::wrap_plots(p)
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants