saezlab / liana

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

liana_tensor_c2c error: 'dict' object has no attribute 'columns' #104

Closed RMOsborn012 closed 1 year ago

RMOsborn012 commented 1 year ago

I am running the Context Factorisation with tensor-cell2cell tutorial on my own data and have run everything exactly as the tutorial says with success. However, I recently decided to use all of the default methods in the original liana tutorial (method = c("natmi", "connectome", "logfc", "sca", "cellphonedb"), # use the same methods as default Liana ) in place of the sca-only method in the tutorial for the liana_bysample function (method = "sca", # we use SingleCellSignalR's score alone).

# Run LIANA by sample
sce <- liana_bysample(sce = sce,
                      sample_col = "orig.ident",
                      idents_col = "seurat_annotations",
                      method = c("natmi", "connectome", "logfc", "sca", "cellphonedb"), # use the same methods as default Liana 
                      inplace=TRUE, # saves inplace to sce
                      return_all = FALSE # whether to return non-expressed interactions 
)

# tensor decomposition
sce <- liana_tensor_c2c(sce = sce,
                        score_col = 'LRscore',
                        rank = NULL,  # set to None to estimate for you data!
                        how='outer',  #  defines how the tensor is built
                        conda_env = NULL, # used to pass an existing conda env with cell2cell
                        use_available = FALSE # detect & load cell2cell if available
)

The documentation allows for multiple methods by default, however, when implementing the liana_tensor_c2c function, I am now getting the following error:

Setting up Conda Environment with Basilisk
Building the tensor using LRscore...
Error: AttributeError: 'dict' object has no attribute 'columns'

How can I fix this?

sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6.3

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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] grid      stats4    stats     graphics  grDevices utils     datasets  methods  
[9] base     

other attached packages:
 [1] SCpubr_1.1.2.9000           gprofiler2_0.2.1           
 [3] webshot2_0.1.0              gt_0.9.0                   
 [5] decoupleR_2.2.2             ggrepel_0.9.3              
 [7] nichenetr_1.1.1             reticulate_1.28            
 [9] SingleCellExperiment_1.20.0 SummarizedExperiment_1.28.0
[11] GenomicRanges_1.50.2        GenomeInfoDb_1.34.9        
[13] MatrixGenerics_1.10.0       matrixStats_0.63.0         
[15] liana_0.1.12                magrittr_2.0.3             
[17] rstatix_0.7.2               ggpubr_0.6.0               
[19] cowplot_1.1.1               ComplexHeatmap_2.14.0      
[21] xlsx_0.6.5                  UpSetR_1.4.0               
[23] ComplexUpset_1.3.3          formattable_0.2.1          
[25] SeuratObject_4.1.3          Seurat_4.3.0               
[27] RColorBrewer_1.1-3          doRNG_1.8.6                
[29] foreach_1.5.2               lubridate_1.9.2            
[31] forcats_1.0.0               stringr_1.5.0              
[33] dplyr_1.1.1                 purrr_1.0.1                
[35] readr_2.1.4                 tidyr_1.3.0                
[37] tibble_3.2.1                tidyverse_2.0.0            
[39] mixtools_2.0.0              plotly_4.10.1              
[41] ggplot2_3.4.2               NMF_0.26                   
[43] cluster_2.1.4               rngtools_1.5.2             
[45] registry_0.5-1              DT_0.27                    
[47] data.table_1.14.8           GSEABase_1.58.0            
[49] graph_1.74.0                annotate_1.74.0            
[51] XML_3.99-0.14               AnnotationDbi_1.58.0       
[53] IRanges_2.32.0              S4Vectors_0.36.2           
[55] Biobase_2.58.0              BiocGenerics_0.44.0        
[57] AUCell_1.18.1              

loaded via a namespace (and not attached):
  [1] KEGGREST_1.36.3           circlize_0.4.15           locfit_1.5-9.7           
  [4] remotes_2.4.2             rJava_1.0-6               lattice_0.21-8           
  [7] spatstat.utils_3.0-2      vctrs_0.6.1               utf8_1.2.3               
 [10] blob_1.2.4                R.oo_1.25.0               withr_2.5.0              
 [13] foreign_0.8-84            ggnetwork_0.5.12          readxl_1.4.2             
 [16] lifecycle_1.0.3           emmeans_1.8.5             munsell_0.5.0            
 [19] cellranger_1.1.0          ScaledMatrix_1.6.0        ggalluvial_0.12.5        
 [22] codetools_0.2-19          caret_6.0-94              lmtest_0.9-40            
 [25] limma_3.54.2              DO.db_2.9                 magick_2.7.4             
 [28] parallelly_1.35.0         fs_1.6.1                  fastmatch_1.1-3          
 [31] basilisk_1.11.2           metapod_1.6.0             Rtsne_0.16               
 [34] stringi_1.7.12            sctransform_0.3.5         polyclip_1.10-4          
 [37] yulab.utils_0.0.6         goftest_1.2-3             patchwork_1.1.2          
 [40] ggraph_2.1.0              ape_5.7-1                 pkgconfig_2.0.3          
 [43] pheatmap_1.0.12           prettyunits_1.1.1         sparseMatrixStats_1.10.0 
 [46] ggridges_0.5.4            timechange_0.2.0          estimability_1.4.1       
 [49] httr_1.4.5                igraph_1.4.2              treeio_1.20.2            
 [52] progress_1.2.2            GetoptLong_1.0.5          terra_1.7-23             
 [55] beachmat_2.14.0           graphlayouts_0.8.4        basilisk.utils_1.11.2    
 [58] ggfun_0.0.9               htmltools_0.5.5           miniUI_0.1.1.1           
 [61] viridisLite_0.4.1         usethis_2.1.6             yaml_2.3.7               
 [64] prodlim_2023.03.31        pillar_1.9.0              jquerylib_0.1.4          
 [67] later_1.3.0               fitdistrplus_1.1-8        glue_1.6.2               
 [70] DBI_1.1.3                 BiocParallel_1.32.5       plyr_1.8.8               
 [73] gtable_0.3.3              GOSemSim_2.22.0           rsvd_1.0.5               
 [76] caTools_1.18.2            GlobalOptions_0.1.2       fastmap_1.1.1            
 [79] broom_1.0.4               checkmate_2.1.0           promises_1.2.0.1         
 [82] FNN_1.1.3.2               ggforce_0.4.1             hms_1.1.3                
 [85] png_0.1-8                 clue_0.3-64               ggtree_3.4.4             
 [88] spatstat.explore_3.1-0    lazyeval_0.2.2            Formula_1.2-5            
 [91] profvis_0.3.7             crayon_1.5.2              gridBase_0.4-7           
 [94] svglite_2.1.1             boot_1.3-28.1             clusterProfiler_4.4.4    
 [97] tidyselect_1.2.0          xfun_0.38                 ks_1.14.0                
[100] BiocSingular_1.14.0       kernlab_0.9-32            splines_4.2.2            
[103] survival_3.5-5            rappdirs_0.3.3            bit64_4.0.5              
[106] segmented_1.6-3           lambda.r_1.2.4            monocle3_1.3.1           
[109] futile.logger_1.4.3       ggsignif_0.6.4            R.methodsS3_1.8.2        
[112] fdrtool_1.2.17            htmlTable_2.4.1           xtable_1.8-4             
[115] cachem_1.0.7              DelayedArray_0.24.0       ipred_0.9-14             
[118] abind_1.4-5               mime_0.12                 systemfonts_1.0.4        
[121] irGSEA_1.1.3              rjson_0.2.21              aplot_0.1.10             
[124] processx_3.8.0            Nebulosa_1.6.0            spatstat.sparse_3.0-1    
[127] tools_4.2.2               cli_3.6.1                 logger_0.2.2             
[130] proxy_0.4-27              randomForest_4.7-1.1      future.apply_1.10.0      
[133] dittoSeq_1.8.1            Matrix_1.5-4              ggplotify_0.1.0          
[136] DelayedMatrixStats_1.20.0 ggbeeswarm_0.7.1          assertthat_0.2.1         
[139] qvalue_2.28.0             fgsea_1.22.0              sna_2.7-1                
[142] ica_1.0-3                 pbapply_1.7-0             ggrastr_1.0.1            
[145] scuttle_1.8.4             R.utils_2.12.2            tweenr_2.0.2             
[148] zlibbioc_1.44.0           zip_2.2.2                 devtools_2.4.5           
[151] qusage_2.30.0             shadowtext_0.1.2          tzdb_0.3.0               
[154] ps_1.7.4                  DiagrammeR_1.0.9          fansi_1.0.4              
[157] xlsxjars_0.6.1            tidygraph_1.2.3           tensor_1.5               
[160] ROCR_1.0-11               KernSmooth_2.23-20        backports_1.4.1          
[163] XVector_0.38.0            farver_2.1.1              bit_4.0.5                
[166] RANN_2.6.1                CellChat_1.6.1            openxlsx_4.2.5.2         
[169] shiny_1.7.4               scattermore_0.8           DOSE_3.22.1              
[172] scatterpie_0.1.8          hardhat_1.3.0             sass_0.4.5               
[175] RcppAnnoy_0.0.20          futile.options_1.0.1      downloader_0.4           
[178] pROC_1.18.0               viridis_0.6.2             rstudioapi_0.14          
[181] minqa_1.2.5               iterators_1.0.14          spatstat.geom_3.1-0      
[184] nlme_3.1-162              shape_1.4.6               beeswarm_0.4.0           
[187] network_1.18.1            bslib_0.4.2               listenv_0.9.0            
[190] reshape2_1.4.4            generics_0.1.3            colorspace_2.1-0         
[193] base64enc_0.1-3           pkgbuild_1.4.0            ModelMetrics_1.2.2.2     
[196] e1071_1.7-13              spatstat.data_3.0-1       sp_1.6-0                 
[199] dqrng_0.3.0               GenomeInfoDbData_1.2.9    Biostrings_2.64.1        
[202] timeDate_4022.108         progressr_0.13.0          chromote_0.1.1           
[205] evaluate_0.20             memoise_2.0.1             coda_0.19-4              
[208] knitr_1.42                fftw_1.0-7                doParallel_1.0.17        
[211] vipor_0.4.5               httpuv_1.6.9              class_7.3-21             
[214] irlba_2.3.5.1             Rcpp_1.0.10               BiocManager_1.30.20      
[217] formatR_1.14              pkgload_1.3.2             jsonlite_1.8.4           
[220] Hmisc_5.0-1               RSpectra_0.16-1           dir.expiry_1.6.0         
[223] digest_0.6.31             OmnipathR_3.7.2           rprojroot_2.0.3          
[226] here_1.0.1                bitops_1.0-7              RSQLite_2.3.1            
[229] rmarkdown_2.21            globals_0.16.2            VennDiagram_1.7.3        
[232] compiler_4.2.2            nnet_7.3-18               statmod_1.5.0            
[235] scran_1.26.2              zoo_1.8-11                carData_3.0-5            
[238] pracma_2.4.2              gridGraphics_0.5-1        rlang_1.1.0              
[241] urlchecker_1.0.1          nloptr_2.0.3              uwot_0.1.14              
[244] sessioninfo_1.2.2         lava_1.7.2.1              rvest_1.0.3              
[247] visNetwork_2.1.2          recipes_1.0.5             future_1.32.0            
[250] mvtnorm_1.1-3             htmlwidgets_1.6.2         websocket_1.4.1          
[253] labeling_0.4.2            callr_3.7.3               leiden_0.4.3             
[256] Cairo_1.6-0               curl_5.0.0                scater_1.26.1            
[259] parallel_4.2.2            BiocNeighbors_1.16.0      edgeR_3.40.2             
[262] filelock_1.0.2            scales_1.2.1              desc_1.4.2               
[265] enrichplot_1.16.2         lme4_1.1-32               deldir_1.0-6             
[268] gridExtra_2.3             bluster_1.8.0             RCurl_1.98-1.12          
[271] car_3.1-2                 GO.db_3.15.0              MASS_7.3-58.3            
[274] ellipsis_0.3.2            tidytree_0.4.2            spatstat.random_3.1-4    
[277] xml2_1.3.3                gower_1.0.1               rpart_4.1.19             
[280] R6_2.5.1                  mclust_6.0.0              statnet.common_4.8.0     
dbdimitrov commented 1 year ago

Hi @RMOsborn012,

Your error occurs because in that case, the LRscore column no longer exists, if I recall correctly it should be called sca.LRscore instead (method names are appended to score names).

I believe I see where you are also coming from with this, and we recently wrote detailed tutorials on LIANA x Tensor here: https://ccc-protocols.readthedocs.io/en/latest/notebooks/ccc_R/QuickStart.html https://ccc-protocols.readthedocs.io/en/latest/notebooks/ccc_R/02-Infer-Communication-Scores.html

These are still work in progress, but in them we already use magnitude rank aggregation (available in the latest liana version), in case this is what you were interested in.

Hope this helps!

Daniel

dbdimitrov commented 1 year ago

PS. This is controlled via the aggregate_how parameter of liana_bysample.

RMOsborn012 commented 1 year ago

@dbdimitrov Thank you so much, this worked out perfectly.

dbdimitrov commented 1 year ago

Perfect!