saeyslab / nichenetr

NicheNet: predict active ligand-target links between interacting cells
452 stars 113 forks source link

Issue in predict_ligand_activities function #226

Closed Pedramto89 closed 2 months ago

Pedramto89 commented 9 months ago

I followed this workflow so far: `organism <- "human" lr_network <- readRDS(url("https://zenodo.org/record/7074291/files/lr_network_human_21122021.rds")) ligand_target_matrix <- readRDS(url("https://zenodo.org/record/7074291/files/ligand_target_matrix_nsga2r_final.rds"))

fibroblast_clusters <- c('1', '2', '3') malignant_clusters <- c('1', '2', '3') fibroblast_cells <- obj@assays$SCT@counts[, obj@meta.data$fibroblast_clusters %in% fibroblast_clusters] malignant_cells <- obj@assays$SCT@counts[, obj@meta.data$malignant_clusters %in% malignant_clusters] geneset_oi <- rownames(malignant_cells)[rowSums(malignant_cells != 0) > 0] ligands <- lr_network %>% dplyr::pull(from) %>% unique() expressed_ligands <- intersect(ligands, rownames(fibroblast_cells)) receptors <- lr_network %>% dplyr::pull(to) %>% unique() expressed_receptors <- intersect(receptors, rownames(malignant_cells)) lr_network_expressed <- lr_network %>% filter(from %in% expressed_ligands & to %in% expressed_receptors) potential_ligands <- lr_network_expressed %>% dplyr::pull(from) %>% unique()

ligand_activities <- predict_ligand_activities( geneset = geneset_oi, background_expressed_genes = geneset_oi, # You can use the same gene set for background ligand_target_matrix = ligand_target_matrix, potential_ligands = potential_ligands )`

But I got this error: `> ligand_activities <- predict_ligand_activities(

What do you think about the problem?

sessionInfo() R version 4.3.0 (2023-04-21) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.5.2

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.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

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

time zone: America/Edmonton tzcode source: internal

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

other attached packages: [1] lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 purrr_1.0.2
[5] readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 tidyverse_2.0.0
[9] nichenetr_2.0.1 SCENIC_1.3.1 SingleCellExperiment_1.23.0 SummarizedExperiment_1.31.1 [13] Biobase_2.61.0 GenomicRanges_1.53.1 GenomeInfoDb_1.37.4 IRanges_2.35.2
[17] S4Vectors_0.39.1 BiocGenerics_0.47.0 MatrixGenerics_1.13.1 matrixStats_1.0.0
[21] pheatmap_1.0.12 randomForest_4.7-1.1 caret_6.0-94 lattice_0.21-8
[25] ggplot2_3.4.3 dplyr_1.1.3 Seurat_4.3.0.1 SeuratObject_4.1.3
[29] sp_2.0-0 Matrix_1.6-1 Giotto_1.1.2

loaded via a namespace (and not attached): [1] fs_1.6.3 spatstat.sparse_3.0-2 bitops_1.0-7 devtools_2.4.5
[5] httr_1.4.7 RColorBrewer_1.1-3 doParallel_1.0.17 backports_1.4.1
[9] profvis_0.3.8 tools_4.3.0 sctransform_0.3.5 utf8_1.2.3
[13] R6_2.5.1 lazyeval_0.2.2 uwot_0.1.16 GetoptLong_1.0.5
[17] urlchecker_1.0.1 withr_2.5.0 prettyunits_1.1.1 gridExtra_2.3
[21] fdrtool_1.2.17 progressr_0.14.0 cli_3.6.1 Cairo_1.6-1
[25] spatstat.explore_3.2-3 labeling_0.4.3 spatstat.data_3.0-1 proxy_0.4-27
[29] ggridges_0.5.4 pbapply_1.7-2 foreign_0.8-85 dbscan_1.1-11
[33] R.utils_2.12.2 parallelly_1.36.0 sessioninfo_1.2.2 limma_3.57.7
[37] RSQLite_2.3.1 rstudioapi_0.15.0 visNetwork_2.1.2 generics_0.1.3
[41] shape_1.4.6 ica_1.0-3 spatstat.random_3.1-6 zip_2.3.0
[45] fansi_1.0.4 abind_1.4-5 R.methodsS3_1.8.2 lifecycle_1.0.3
[49] yaml_2.3.7 recipes_1.0.8 SparseArray_1.1.12 Rtsne_0.16
[53] blob_1.2.4 grid_4.3.0 promises_1.2.1 crayon_1.5.2
[57] miniUI_0.1.1.1 cowplot_1.1.1 annotate_1.79.0 KEGGREST_1.41.0
[61] magick_2.7.5 pillar_1.9.0 knitr_1.44 ComplexHeatmap_2.17.0
[65] rjson_0.2.21 future.apply_1.11.0 codetools_0.2-19 leiden_0.4.3
[69] glue_1.6.2 data.table_1.14.8 remotes_2.4.2.1 vctrs_0.6.3
[73] png_0.1-8 gtable_0.3.4 cachem_1.0.8 gower_1.0.1
[77] xfun_0.40 openxlsx_4.2.5.2 S4Arrays_1.1.6 mime_0.12
[81] prodlim_2023.08.28 Rfast_2.0.8 survival_3.5-7 timeDate_4022.108
[85] iterators_1.0.14 hardhat_1.3.0 lava_1.7.2.1 DiagrammeR_1.0.10
[89] statmod_1.5.0 ellipsis_0.3.2 fitdistrplus_1.1-11 ROCR_1.0-11
[93] ipred_0.9-14 nlme_3.1-163 usethis_2.2.2 bit64_4.0.5
[97] RcppAnnoy_0.0.21 rprojroot_2.0.3 irlba_2.3.5.1 KernSmooth_2.23-22
[101] rpart_4.1.19 Hmisc_5.1-1 DBI_1.1.3 colorspace_2.1-0
[105] nnet_7.3-19 tidyselect_1.2.0 processx_3.8.2 bit_4.0.5
[109] compiler_4.3.0 curl_5.0.2 AUCell_1.22.0 graph_1.79.1
[113] htmlTable_2.4.1 desc_1.4.2 DelayedArray_0.27.10 plotly_4.10.2
[117] shadowtext_0.1.2 caTools_1.18.2 checkmate_2.2.0 scales_1.2.1
[121] lmtest_0.9-40 callr_3.7.3 digest_0.6.33 goftest_1.2-3
[125] spatstat.utils_3.0-3 rmarkdown_2.24 XVector_0.41.1 base64enc_0.1-3
[129] htmltools_0.5.6 pkgconfig_2.0.3 sparseMatrixStats_1.13.4 fastmap_1.1.1
[133] rlang_1.1.1 GlobalOptions_0.1.2 htmlwidgets_1.6.2 DelayedMatrixStats_1.23.4 [137] shiny_1.7.5 farver_2.1.1 zoo_1.8-12 jsonlite_1.8.7
[141] R.oo_1.25.0 ModelMetrics_1.2.2.2 RCurl_1.98-1.12 magrittr_2.0.3
[145] Formula_1.2-5 GenomeInfoDbData_1.2.10 patchwork_1.1.3 munsell_0.5.0
[149] Rcpp_1.0.11 ggnewscale_0.4.9 reticulate_1.32.0 RcppZiggurat_0.1.6
[153] stringi_1.7.12 pROC_1.18.4 zlibbioc_1.47.0 MASS_7.3-60
[157] plyr_1.8.8 pkgbuild_1.4.2 parallel_4.3.0 listenv_0.9.0
[161] ggrepel_0.9.3 deldir_1.0-9 Biostrings_2.69.2 splines_4.3.0
[165] tensor_1.5 hms_1.1.3 circlize_0.4.15 ps_1.7.5
[169] igraph_1.5.1 spatstat.geom_3.2-5 reshape2_1.4.4 pkgload_1.3.2.1
[173] XML_3.99-0.14 evaluate_0.21 BiocManager_1.30.22 tzdb_0.4.0
[177] tweenr_2.0.2 foreach_1.5.2 httpuv_1.6.11 RANN_2.6.1
[181] polyclip_1.10-4 future_1.33.0 clue_0.3-64 scattermore_1.2
[185] ggforce_0.4.1 xtable_1.8-4 e1071_1.7-13 later_1.3.1
[189] viridisLite_0.4.2 class_7.3-22 AnnotationDbi_1.63.2 memoise_2.0.1
[193] cluster_2.1.4 timechange_0.2.0 globals_0.16.2 GSEABase_1.63.0

csangara commented 9 months ago

You cannot set the gene set of interest as the same as the background. NicheNet looks for the enrichment of the gene set of interest within the background, so setting these two as the same does not make sense.