saeyslab / nichenetr

NicheNet: predict active ligand-target links between interacting cells
483 stars 117 forks source link

using same receiver cluster for multiple niches #197

Closed EDePasquale closed 1 year ago

EDePasquale commented 1 year ago

Hi,

I'm interested in using Differential NicheNet to explore the T cell/Kupffer cell interactions between two different conditions: clonally expanded T cells vs all Kupffer cells and non-expanded T cells vs all Kupffer cells. However, the Kupffer cells aren't different between the two different populations and serves as an interaction partner for both subsets of T cells. Here is how I set up my clusters:

M_T@meta.data$celltype_aggregate = paste(M_T@meta.data$cluster_names_new, M_T@meta.data$expanded,sep = "_")
M_T@meta.data$celltype_aggregate %>% table() %>% sort(decreasing = TRUE)

Output: CD8 Effector Memory T_no CD8 Effector Memory T_yes Kupffer 3_no CD8 TRM Activated_no 1686 439 362 287 MAIT_no CD8 Effector T_no CD8 Effector T_yes CD8 TRM Activated_yes 271 234 60 27 MAIT_yes 4

(Note the single 'Kupffer 3_no' population)

Here is how I set up my niches:

niches = list(
  "expanded_Yes_niche" = list(
    "sender" = c("CD8 Effector Memory T_yes", "CD8 TRM Activated_yes", "CD8 Effector T_yes", "MAIT_yes"),
    "receiver" = c("Kupffer 3_no")),
  "expanded_no_niche" = list(
    "sender" = c("CD8 Effector Memory T_no",  "CD8 TRM Activated_no", "CD8 Effector T_no", "MAIT_no"),
    "receiver" = c("Kupffer 3_no"))
)

I can run DE_sender = calculate_niche_de(seurat_obj = M_T %>% subset(features = lr_network$ligand %>% unique()), niches = niches, type = "sender", assay_oi = assay_oi) with no issue.

However, when I run DE_receiver = calculate_niche_de(seurat_obj = M_T %>% subset(features = lr_network$receptor %>% unique()), niches = niches, type = "receiver", assay_oi = assay_oi)I get the following error:

Error in filter(): ℹ In argument: &.... Caused by error: ! ..1 must be of size 1, not size 0. Run rlang::last_trace() to see where the error occurred.

I believe this is because the receiver population is the same between the two niches, but I don't know how to set up the niches to eliminate this problem. Duplicating the Kupffer cells so that I have an 'expanded' and 'not expanded' population may be possible, but I can also see that leading to downstream issues with replicated cell names.

What do you suggest?

Thanks, Erica


sessionInfo() R version 4.2.0 (2022-04-22) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Monterey 12.6.5

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] stats graphics grDevices utils datasets methods base

other attached packages: [1] forcats_0.5.1 stringr_1.4.0 dplyr_1.1.2 purrr_1.0.1 readr_2.1.2 tidyr_1.2.0
[7] tibble_3.2.1 ggplot2_3.4.0 tidyverse_1.3.2 sp_1.5-0 SeuratObject_4.1.0 Seurat_4.1.1
[13] nichenetr_1.1.1

loaded via a namespace (and not attached): [1] utf8_1.2.2 reticulate_1.25 tidyselect_1.2.0 htmlwidgets_1.6.2 grid_4.2.0
[6] Rtsne_0.16 pROC_1.18.2 devtools_2.4.3 munsell_0.5.0 codetools_0.2-18
[11] ica_1.0-3 interp_1.1-3 future_1.26.1 miniUI_0.1.1.1 withr_2.5.0
[16] spatstat.random_3.0-1 colorspace_2.0-3 progressr_0.10.1 knitr_1.39 rstudioapi_0.13
[21] stats4_4.2.0 ROCR_1.0-11 tensor_1.5 listenv_0.8.0 labeling_0.4.2
[26] polyclip_1.10-0 farver_2.1.1 rprojroot_2.0.3 parallelly_1.32.0 vctrs_0.6.2
[31] generics_0.1.3 xfun_0.31 ipred_0.9-14 randomForest_4.7-1.1 R6_2.5.1
[36] doParallel_1.0.17 clue_0.3-64 bitops_1.0-7 spatstat.utils_3.0-1 cachem_1.0.6
[41] assertthat_0.2.1 promises_1.2.0.1 scales_1.2.0 googlesheets4_1.0.0 nnet_7.3-17
[46] rgeos_0.5-9 gtable_0.3.0 globals_0.15.1 processx_3.7.0 goftest_1.2-3
[51] timeDate_4022.108 rlang_1.1.1 GlobalOptions_0.1.2 splines_4.2.0 lazyeval_0.2.2
[56] gargle_1.2.0 ModelMetrics_1.2.2.2 broom_1.0.0 checkmate_2.1.0 spatstat.geom_3.0-3
[61] modelr_0.1.8 BiocManager_1.30.18 reshape2_1.4.4 abind_1.4-5 backports_1.4.1
[66] httpuv_1.6.5 Hmisc_4.7-1 caret_6.0-94 DiagrammeR_1.0.9 tools_4.2.0
[71] lava_1.7.2.1 usethis_2.1.6 ellipsis_0.3.2 spatstat.core_2.4-4 RColorBrewer_1.1-3
[76] proxy_0.4-27 BiocGenerics_0.42.0 sessioninfo_1.2.2 ggridges_0.5.3 Rcpp_1.0.9
[81] plyr_1.8.7 base64enc_0.1-3 visNetwork_2.1.2 ps_1.7.1 prettyunits_1.1.1
[86] rpart_4.1.16 deldir_1.0-6 pbapply_1.5-0 GetoptLong_1.0.5 cowplot_1.1.1
[91] S4Vectors_0.34.0 zoo_1.8-10 haven_2.5.0 ggrepel_0.9.1 cluster_2.1.3
[96] fs_1.5.2 magrittr_2.0.3 RSpectra_0.16-1 data.table_1.14.2 scattermore_0.8
[101] circlize_0.4.15 reprex_2.0.1 lmtest_0.9-40 RANN_2.6.1 googledrive_2.0.0
[106] fitdistrplus_1.1-8 matrixStats_0.62.0 pkgload_1.3.0 hms_1.1.1 patchwork_1.1.1
[111] mime_0.12 xtable_1.8-4 jpeg_0.1-9 readxl_1.4.0 IRanges_2.30.0
[116] gridExtra_2.3 shape_1.4.6 compiler_4.2.0 KernSmooth_2.23-20 crayon_1.5.1
[121] htmltools_0.5.4 mgcv_1.8-40 later_1.3.0 tzdb_0.4.0 Formula_1.2-4
[126] lubridate_1.8.0 DBI_1.1.3 dbplyr_2.2.1 ComplexHeatmap_2.12.1 MASS_7.3-58
[131] Matrix_1.5-3 cli_3.6.1 parallel_4.2.0 gower_1.0.1 igraph_1.3.3
[136] pkgconfig_2.0.3 foreign_0.8-82 plotly_4.10.0 spatstat.sparse_3.0-0 recipes_1.0.6
[141] xml2_1.3.3 foreach_1.5.2 hardhat_1.3.0 prodlim_2023.03.31 rvest_1.0.2
[146] callr_3.7.1 digest_0.6.29 sctransform_0.3.3 RcppAnnoy_0.0.19 spatstat.data_3.0-0
[151] cellranger_1.1.0 leiden_0.4.2 htmlTable_2.4.1 uwot_0.1.11 curl_4.3.2
[156] shiny_1.7.2 rjson_0.2.21 lifecycle_1.0.3 nlme_3.1-158 jsonlite_1.8.0
[161] limma_3.52.2 viridisLite_0.4.0 fansi_1.0.3 pillar_1.9.0 lattice_0.20-45
[166] fastmap_1.1.0 httr_1.4.3 pkgbuild_1.3.1 survival_3.3-1 glue_1.6.2
[171] remotes_2.4.2 fdrtool_1.2.17 png_0.1-7 iterators_1.0.14 class_7.3-20
[176] stringi_1.7.8 caTools_1.18.2 latticeExtra_0.6-30 memoise_2.0.1 irlba_2.3.5
[181] e1071_1.7-11 future.apply_1.9.0

csangara commented 1 year ago

Hi Erica,

In the Differential NicheNet pipeline, it is not possible to have the same senders or receivers in different niches. This is because one of the prioritization criteria is the LFC between ligands of senders in one group vs all other groups, and likewise for receptors of receivers. Moreover, the target gene set is calculated as the upregulated genes in one receiver group compared to the others, so this will not work if your receivers are the same.

I think you could use the normal NicheNet pipeline to perform the analysis. I was also wondering (but keep in mind that I'm not a biologist) - since the T cells are the ones undergoing expansion, would it make sense to make them the receiver cells? Then the DE genes between expanded vs non-expanded T cells could be used as your gene set of interest.