saezlab / liana

LIANA: a LIgand-receptor ANalysis frAmework
https://saezlab.github.io/liana/
GNU General Public License v3.0
173 stars 30 forks source link

Error running Squidpy #13

Closed ccruizm closed 3 years ago

ccruizm commented 3 years ago

Good day,

Thanks for developing this tool. I am trying to use squidpy but got the error below, either calling the function independently call_squidpy or within liana_wrap:

 Error in .subset2(x, i, exact = exact): attempt to select less than one element in get1index
Traceback:

1. call_squidpy(reference, op_resource = select_resource("OmniPath")[[1]], 
 .     .seed = 1004)
2. is.factor(seurat_object@meta.data[[kwargs$cluster_key]])
3. seurat_object@meta.data[[kwargs$cluster_key]]
4. `[[.data.frame`(seurat_object@meta.data, kwargs$cluster_key)
5. (function(x, i, exact) if (is.matrix(i)) as.matrix(x)[[i]] else .subset2(x, 

     i, exact = exact))(x, ..., exact = exact)

Other tools work as expected (have tested connectome and cellchat). Any idea where the problem might be?

Thanks in advance!

My session info:

R version 4.0.3 (2020-10-10)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /hpc/pmc_stunnenberg/cruiz/miniconda3/envs/r_pHGG_project/lib/libopenblasp-r0.3.12.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] future_1.21.0               patchwork_1.1.1            
 [3] cowplot_1.1.1               stringr_1.4.0              
 [5] dittoSeq_1.5.1              tibble_3.1.2               
 [7] rlog_0.1.0                  tidyr_1.1.3                
 [9] liana_0.0.1                 OmnipathR_2.99.18          
[11] purrr_0.3.4.9000            SeuratObject_4.0.2         
[13] Seurat_4.0.3.9011           scater_1.18.6              
[15] SingleCellExperiment_1.12.0 SummarizedExperiment_1.20.0
[17] Biobase_2.50.0              GenomicRanges_1.42.0       
[19] GenomeInfoDb_1.26.7         IRanges_2.24.1             
[21] S4Vectors_0.28.1            BiocGenerics_0.36.1        
[23] MatrixGenerics_1.2.1        matrixStats_0.59.0         
[25] ggplot2_3.3.5               reticulate_1.20            

loaded via a namespace (and not attached):
  [1] statnet.common_4.5.0      rsvd_1.0.5               
  [3] ica_1.0-2                 svglite_2.0.0            
  [5] foreach_1.5.1             lmtest_0.9-38            
  [7] crayon_1.4.1              V8_3.4.2                 
  [9] spatstat.core_2.3-0       MASS_7.3-54              
 [11] MAST_1.16.0               nlme_3.1-152             
 [13] backports_1.2.1           qlcMatrix_0.9.7          
 [15] rlang_0.4.11              XVector_0.30.0           
 [17] ROCR_1.0-11               readxl_1.3.1             
 [19] irlba_2.3.3               SparseM_1.81             
 [21] limma_3.46.0              BiocParallel_1.24.1      
 [23] rjson_0.2.20              bit64_4.0.5              
 [25] glue_1.4.2                pheatmap_1.0.12          
 [27] rngtools_1.5              sctransform_0.3.2        
 [29] vipor_0.4.5               spatstat.sparse_2.0-0    
 [31] AnnotationDbi_1.52.0      CellChat_1.1.2           
 [33] spatstat.geom_2.2-2       VGAM_1.1-5               
 [35] tidyselect_1.1.1          fitdistrplus_1.1-5       
 [37] XML_3.99-0.6              DEsingle_1.10.0          
 [39] zoo_1.8-9                 xtable_1.8-4             
 [41] MatrixModels_0.5-0        magrittr_2.0.1           
 [43] evaluate_0.14             scuttle_1.0.4            
 [45] zlibbioc_1.36.0           miniUI_0.1.1.1           
 [47] logger_0.2.1              rpart_4.1-15             
 [49] shiny_1.6.0               BiocSingular_1.6.0       
 [51] clue_0.3-59               multtest_2.46.0          
 [53] cluster_2.1.2             caTools_1.18.2           
 [55] pcaMethods_1.82.0         pbdZMQ_0.3-5             
 [57] quantreg_5.86             ggrepel_0.9.1            
 [59] listenv_0.8.0             png_0.1-7                
 [61] withr_2.4.2               bitops_1.0-7             
 [63] slam_0.1-48               plyr_1.8.6               
 [65] cellranger_1.1.0          sparsesvd_0.2            
 [67] pracma_2.3.3              coda_0.19-4              
 [69] pillar_1.6.1              gplots_3.1.1             
 [71] GlobalOptions_0.1.2       cachem_1.0.5             
 [73] pscl_1.5.5                flexmix_2.3-17           
 [75] GetoptLong_1.0.5          DelayedMatrixStats_1.12.3
 [77] gamlss.data_6.0-1         vctrs_0.3.8              
 [79] ellipsis_0.3.2            generics_0.1.0           
 [81] randomcoloR_1.1.0.1       NMF_0.23.0               
 [83] tools_4.0.3               beeswarm_0.4.0           
 [85] munsell_0.5.0             distillery_1.2-1         
 [87] DelayedArray_0.16.3       fastmap_1.1.0            
 [89] compiler_4.0.3            HSMMSingleCell_1.10.0    
 [91] abind_1.4-5               httpuv_1.6.1             
 [93] extRemes_2.1-1            pkgmaker_0.32.2          
 [95] plotly_4.9.3.9000         GenomeInfoDbData_1.2.4   
 [97] gridExtra_2.3             edgeR_3.32.1             
 [99] lattice_0.20-44           deldir_0.2-10            
[101] utf8_1.2.1                later_1.2.0              
[103] dplyr_1.0.7               jsonlite_1.7.2           
[105] scales_1.1.1              docopt_0.7.1             
[107] pbapply_1.4-3             sparseMatrixStats_1.2.1  
[109] genefilter_1.72.1         lazyeval_0.2.2           
[111] promises_1.2.0.9000       doParallel_1.0.16        
[113] goftest_1.2-2             brew_1.0-6               
[115] spatstat.utils_2.2-0      sna_2.6                  
[117] checkmate_2.0.0           sandwich_3.0-1           
[119] Rtsne_0.15                uwot_0.1.10              
[121] igraph_1.2.6              Rook_1.1-1               
[123] survival_3.2-11           numDeriv_2016.8-1.1      
[125] yaml_2.2.1                systemfonts_1.0.2        
[127] DDRTree_0.1.5             htmltools_0.5.1.1        
[129] memoise_2.0.0             SCAomni_0.0.1.8          
[131] modeltools_0.2-23         locfit_1.5-9.4           
[133] viridisLite_0.4.0         digest_0.6.27            
[135] assertthat_0.2.1          mime_0.11                
[137] rappdirs_0.3.3            repr_1.1.3               
[139] densityClust_0.3          registry_0.5-1           
[141] SIMLR_1.16.0              Connectome_1.0.1         
[143] RSQLite_2.2.7             future.apply_1.7.0       
[145] RcppArmadillo_0.10.6.0.0  data.table_1.14.0        
[147] blob_1.2.1                fastICA_1.2-2            
[149] splines_4.0.3             Cairo_1.5-12.2           
[151] RCurl_1.98-1.3            monocle_2.18.0           
[153] hms_1.1.0                 colorspace_2.0-2         
[155] base64enc_0.1-3           ggbeeswarm_0.6.0         
[157] shape_1.4.6               maxLik_1.4-8             
[159] nnet_7.3-16               Rcpp_1.0.7               
[161] RANN_2.6.1                mvtnorm_1.1-2            
[163] circlize_0.4.13           fansi_0.5.0              
[165] conquer_1.0.2             tzdb_0.1.2               
[167] parallelly_1.27.0         IRdisplay_1.0            
[169] R6_2.5.0                  grid_4.0.3               
[171] ggridges_0.5.3            lifecycle_1.0.0          
[173] miscTools_0.6-26          curl_4.3.2               
[175] leiden_0.3.8              Matrix_1.3-3             
[177] scde_2.18.0               RcppAnnoy_0.0.18         
[179] RColorBrewer_1.1-2        iterators_1.0.13         
[181] htmlwidgets_1.5.3         RMTstat_0.3              
[183] beachmat_2.6.4            polyclip_1.10-0          
[185] network_1.17.1            gamlss_5.3-4             
[187] ComplexHeatmap_2.9.1      mgcv_1.8-35              
[189] globals_0.14.0            bdsmatrix_1.3-4          
[191] Lmoments_1.3-1            codetools_0.2-18         
[193] FNN_1.1.3                 gtools_3.9.2             
[195] prettyunits_1.1.1         gridBase_0.4-7           
[197] RSpectra_0.16-0           gtable_0.3.0             
[199] DBI_1.1.1                 ggalluvial_0.12.3        
[201] tensor_1.5                httr_1.4.2               
[203] KernSmooth_2.23-20        stringi_1.7.3            
[205] progress_1.2.2            reshape2_1.4.4           
[207] uuid_0.1-4                annotate_1.68.0          
[209] viridis_0.6.1             xml2_1.3.2               
[211] combinat_0.0-8            bbmle_1.0.23.1           
[213] iTALK_0.1.0               IRkernel_1.1.1           
[215] BiocNeighbors_1.8.2       readr_2.0.0              
[217] geneplotter_1.68.0        scattermore_0.7          
[219] DESeq2_1.30.1             bit_4.0.4                
[221] spatstat.data_2.1-0       pkgconfig_2.0.3          
[223] gamlss.dist_5.3-2   
dbdimitrov commented 3 years ago

Hi ccruizm,

Thanks for using the tool!

I assume this issue might be related to your cluster annotations - Squidpy seems a bit picky about this. Perhaps, if you share them I can check on my side.

ccruizm commented 3 years ago

Thanks for the quick reply!

These are the cluster names I am using:

'AC-like','MES-like','OPC-like','NPC-like', 'Astrocyte','Oligodendrocyte','OPC','RG','Neuron','Mono','TAM-BDM','TAM-MG','DC',
'CD4/CD8','Reg. T','Prolif. T','NK','B cell','Plasma B','Mast','Pericyte','Endothelial'

I have run sq.pl.ligrec using the same cell annotation and didn't encounter any issue. But this was loading the data directly in Scanpy running a python kernel. Maybe there is an issue using reticulate? Let me know if you need anything else I can provide to troubleshoot this part.

Thanks!

dbdimitrov commented 3 years ago

Hi,

I think it's related to the way that call_squidpy obtains the annotations (I got the same error when I did not appropriately set the Idents in Seurat).

Please try setting the idents in Seurat to an existing column in the metadata (e.g. Idents(seurat_object) <- metadata[[column]]), or alternatively pass the appropriate name to the cluster column to squidpy /w cluster_key = "column".

I hope it works!

ccruizm commented 3 years ago

Hello!

Thanks for the suggestion. I have tried both but get the next error:

Error in UseMethod("select"): no applicable method for 'select' applied to an object of class "character"
Traceback:

1. call_squidpy(reference, op_resource = select_resource("OmniPath")[[1]], 
 .     .seed = 1004)
2. map(op_resource, function(x) x %>% select(uniprot_source = source, 
 .     unprot_target = target, source = source_genesymbol, target = target_genesymbol, 
 .     category_intercell_source, category_intercell_target)) %>% 
 .     unname()
3. unname(.)
4. map(op_resource, function(x) x %>% select(uniprot_source = source, 
 .     unprot_target = target, source = source_genesymbol, target = target_genesymbol, 
 .     category_intercell_source, category_intercell_target))
5. .f(.x[[i]], ...)
6. x %>% select(uniprot_source = source, unprot_target = target, 
 .     source = source_genesymbol, target = target_genesymbol, category_intercell_source, 
 .     category_intercell_target)
7. select(., uniprot_source = source, unprot_target = target, source = source_genesymbol, 
 .     target = target_genesymbol, category_intercell_source, category_intercell_target)

The commands I am using are:

call_squidpy(seu_obj, 
                  op_resource = select_resource('OmniPath')[[1]],
                   cluster_key = 'celltype_squidpy',
                  .seed = 1004)

or

Idents(seu_obj) <- seu_obj[['celltype_squidpy']]
call_squidpy(seu_obj, 
                  op_resource = select_resource('OmniPath')[[1]],
                  .seed = 1004)

Hopefully, we can figure out where the problem is. Thanks!

dbdimitrov commented 3 years ago

Hi Christian,

I think in this case, it's an inconsistency that I fixed recently. Squidpy used to take a list as op_resource, so you should run it as:

call_squidpy(seu_obj, op_resource = select_resource('OmniPath'), .seed = 1004)

I have changed this in one of the latest commits to the master branch, but this should also work.

Regards, Daniel

ccruizm commented 3 years ago

It works now! thanks for your help!!!

dbdimitrov commented 3 years ago

Seeing that this is a reoccurring issue, I will implement an informative error message when this happens.