sqjin / CellChat

R toolkit for inference, visualization and analysis of cell-cell communication from single-cell data
GNU General Public License v3.0
632 stars 144 forks source link

Error when CTLchat<- subsetData(CTLchat) #96

Closed EAC-T closed 3 years ago

EAC-T commented 3 years ago

Hi I'm following the tutorial, I have a seurat object and I'm getting this error when trying to subsetData

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

If I skip this step, and I do: CTLchat<- identifyOverExpressedGenes(CTLchat) I get this: Error in data.use[, cell.use1, drop = FALSE] : subscript out of bounds

Any idea? Thank you a lot

EAC-T commented 3 years ago

My session info

sessionInfo() R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale: [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252 [4] LC_NUMERIC=C LC_TIME=English_Canada.1252

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

other attached packages: [1] dplyr_1.0.2 reticulate_1.18 ggalluvial_0.12.2 ggplot2_3.3.2 Seurat_3.2.2
[6] CellChat_0.0.2 Biobase_2.50.0 BiocGenerics_0.36.0

loaded via a namespace (and not attached): [1] backports_1.2.0 circlize_0.4.11 systemfonts_0.3.2 NMF_0.22.0 plyr_1.8.6
[6] igraph_1.2.6 lazyeval_0.2.2 splines_4.0.3 listenv_0.8.0 usethis_1.6.3
[11] gridBase_0.4-7 digest_0.6.27 foreach_1.5.1 htmltools_0.5.0 fansi_0.4.1
[16] magrittr_1.5 memoise_1.1.0 rle_0.9.2 tensor_1.5 cluster_2.1.0
[21] doParallel_1.0.16 ROCR_1.0-11 remotes_2.2.0 sna_2.6 ComplexHeatmap_2.7.1 [26] globals_0.13.1 matrixStats_0.57.0 svglite_1.2.3.2 prettyunits_1.1.1 colorspace_1.4-1
[31] ggrepel_0.8.2 xfun_0.19 callr_3.5.1 crayon_1.3.4 jsonlite_1.7.1
[36] spatstat.data_1.5-2 spatstat_1.64-1 survival_3.2-7 zoo_1.8-8 iterators_1.0.13
[41] glue_1.4.2 polyclip_1.10-0 registry_0.5-1 gtable_0.3.0 leiden_0.3.5
[46] GetoptLong_1.0.4 pkgbuild_1.1.0 future.apply_1.6.0 shape_1.4.5 abind_1.4-5
[51] scales_1.1.1 rngtools_1.5 miniUI_0.1.1.1 Rcpp_1.0.5 viridisLite_0.3.0
[56] xtable_1.8-4 clue_0.3-57 rsvd_1.0.3 stats4_4.0.3 htmlwidgets_1.5.2
[61] httr_1.4.2 FNN_1.1.3 RColorBrewer_1.1-2 ellipsis_0.3.1 ica_1.0-2
[66] pkgconfig_2.0.3 uwot_0.1.8 deldir_0.2-2 tidyselect_1.1.0 rlang_0.4.8
[71] reshape2_1.4.4 later_1.1.0.1 munsell_0.5.0 tools_4.0.3 cli_2.1.0
[76] generics_0.1.0 statnet.common_4.4.1 devtools_2.3.2 ggridges_0.5.2 stringr_1.4.0
[81] fastmap_1.0.1 goftest_1.2-2 processx_3.4.4 fs_1.5.0 fitdistrplus_1.1-1
[86] purrr_0.3.4 RANN_2.6.1 nlme_3.1-149 pbapply_1.4-3 future_1.20.1
[91] mime_0.9 compiler_4.0.3 rstudioapi_0.13 plotly_4.9.2.1 curl_4.3
[96] png_0.1-7 testthat_3.0.0 spatstat.utils_1.17-0 tibble_3.0.4 stringi_1.5.3
[101] ps_1.4.0 desc_1.2.0 RSpectra_0.16-0 gdtools_0.2.2 lattice_0.20-41
[106] Matrix_1.2-18 vctrs_0.3.4 pillar_1.4.6 lifecycle_0.2.0 lmtest_0.9-38
[111] GlobalOptions_0.1.2 RcppAnnoy_0.0.16 data.table_1.13.2 cowplot_1.1.0 irlba_2.3.3
[116] httpuv_1.5.4 patchwork_1.1.0 R6_2.5.0 promises_1.1.1 network_1.16.1
[121] gridExtra_2.3 KernSmooth_2.23-17 IRanges_2.24.0 parallelly_1.21.0 sessioninfo_1.1.1
[126] codetools_0.2-16 MASS_7.3-53 assertthat_0.2.1 pkgload_1.1.0 pkgmaker_0.32.2
[131] rprojroot_1.3-2 rjson_0.2.20 withr_2.3.0 sctransform_0.3.1 S4Vectors_0.28.0
[136] mgcv_1.8-33 rpart_4.1-15 grid_4.0.3 tidyr_1.1.2 coda_0.19-4
[141] Cairo_1.5-12.2 Rtsne_0.15 shiny_1.5.0 tinytex_0.28

EAC-T commented 3 years ago

Fixed it by changing the name of the object! Thank you anyway

cswoboda commented 3 years ago

Hello, I'm sorry to reopen this but I have the exact same issue. You said changing the name fixed the issue? It's not really clear to me how the variable name would mess with anything, but I've tried a few names and it's not worked thus far.

danmoore1987 commented 3 years ago

I am also getting the same issue as well when creating Cellchat object from Seurat. Albeit slightly different on the next step.

cellchat <- createCellChat(object = seurat_obj, group.by = "cluster_ID")
groupSize <- as.numeric(table(cellchat@idents)) # number of cells in each cell group
CellChatDB <- CellChatDB.human # use CellChatDB.mouse if running on mouse data
cellchat <- subsetData(cellchat)

Error in UseMethod("select") : no applicable method for 'select' applied to an object of class "NULL" In addition: Warning message: select_() is deprecated as of dplyr 0.7.0. Please use select() instead.

cellchat <- identifyOverExpressedGenes(cellchat)

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'rowSums': subscript out of bounds

image

sessionInfo() R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042)

Matrix products: default

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

other attached packages: [1] patchwork_1.0.1 CellChat_0.5.5 Biobase_2.48.0 BiocGenerics_0.34.0 [5] ggplot2_3.3.2 igraph_1.2.6 dplyr_1.0.2 SeuratObject_4.0.0 [9] Seurat_4.0.0

loaded via a namespace (and not attached): [1] circlize_0.4.13.1001 systemfonts_0.3.2 NMF_0.23.0
[4] plyr_1.8.6 lazyeval_0.2.2 splines_4.0.3
[7] listenv_0.8.0 scattermore_0.7 gridBase_0.4-7
[10] digest_0.6.25 foreach_1.5.1 htmltools_0.5.1.1
[13] ggalluvial_0.12.3 magrittr_2.0.1 rle_0.9.2
[16] tensor_1.5 cluster_2.1.0 doParallel_1.0.16
[19] ROCR_1.0-11 sna_2.6 ComplexHeatmap_2.7.6.1009 [22] globals_0.14.0 matrixStats_0.57.0 gg.gap_1.3
[25] svglite_1.2.3.2 colorspace_1.4-1 rappdirs_0.3.1
[28] ggrepel_0.8.2 crayon_1.3.4 jsonlite_1.7.1
[31] spatstat_1.64-1 spatstat.data_1.4-3 survival_3.2-7
[34] zoo_1.8-8 iterators_1.0.13 glue_1.4.2
[37] polyclip_1.10-0 registry_0.5-1 gtable_0.3.0
[40] leiden_0.3.3 GetoptLong_1.0.4 future.apply_1.6.0
[43] shape_1.4.5 abind_1.4-5 scales_1.1.1
[46] rngtools_1.5 miniUI_0.1.1.1 Rcpp_1.0.5
[49] viridisLite_0.3.0 xtable_1.8-4 clue_0.3-58
[52] reticulate_1.16 stats4_4.0.3 htmlwidgets_1.5.2
[55] httr_1.4.2 FNN_1.1.3 RColorBrewer_1.1-2
[58] ellipsis_0.3.1 ica_1.0-2 pkgconfig_2.0.3
[61] farver_2.0.3 uwot_0.1.10 deldir_0.1-29
[64] tidyselect_1.1.0 labeling_0.3 rlang_0.4.8
[67] reshape2_1.4.4 later_1.1.0.1 munsell_0.5.0
[70] tools_4.0.3 generics_0.1.0 statnet.common_4.4.1
[73] ggridges_0.5.2 stringr_1.4.0 fastmap_1.0.1
[76] goftest_1.2-2 fitdistrplus_1.1-1 purrr_0.3.4
[79] RANN_2.6.1 pbapply_1.4-3 future_1.21.0
[82] nlme_3.1-149 mime_0.9 compiler_4.0.3
[85] rstudioapi_0.13 plotly_4.9.2.1 png_0.1-7
[88] spatstat.utils_1.17-0 tibble_3.0.4 stringi_1.5.3
[91] RSpectra_0.16-0 forcats_0.5.0 gdtools_0.2.2
[94] lattice_0.20-41 Matrix_1.2-18 vctrs_0.3.4
[97] pillar_1.4.6 lifecycle_0.2.0 lmtest_0.9-38
[100] GlobalOptions_0.1.2 RcppAnnoy_0.0.18 data.table_1.13.4
[103] cowplot_1.1.0 irlba_2.3.3 httpuv_1.5.4
[106] R6_2.4.1 promises_1.1.1 network_1.16.1
[109] KernSmooth_2.23-17 gridExtra_2.3 IRanges_2.22.2
[112] parallelly_1.22.0 codetools_0.2-16 MASS_7.3-53
[115] assertthat_0.2.1 pkgmaker_0.32.2 rjson_0.2.20
[118] withr_2.3.0 sctransform_0.3.2 S4Vectors_0.26.1
[121] mgcv_1.8-33 grid_4.0.3 rpart_4.1-15
[124] tidyr_1.1.2 coda_0.19-4 Cairo_1.5-12.2
[127] Rtsne_0.15 shiny_1.5.0

Thank you in advance for your help!

sqjin commented 3 years ago

@danmoore1987 You should set the database you are using via # set the used database in the object cellchat@DB <- CellChatDB.use

wfma commented 3 years ago

for others who may have the same problem, i did the following and it resolved the problem!

#### CellChat ####
# transform seurat obj to cellchat obj#
cellchat <- createCellChat(object = stanford, # this is my seurat obj
                           group.by = "manually_annotated_labels")

# set the database#
CellChatDB <- CellChatDB.human # use CellChatDB.mouse if running on mouse data
showDatabaseCategory(CellChatDB)

# subset the expression data of signaling genes for saving computation cost
cellchat@DB <- CellChatDB
cellchat <- subsetData(cellchat) # This step is necessary even if using the whole database
cellchat <- identifyOverExpressedGenes(cellchat)
Varix commented 3 years ago

confirmed @wfma and @sqjin solution fixed it for me also, running Ubuntu 20 LTS & R 4.0.3

Minazukiz commented 11 months ago

cellchat@DB <- CellChatDB cellchat <- subsetData(cellchat) # This step is necessary even if using the whole database cellchat <- identifyOverExpressedGenes(cellchat)

Thankyou,it works Ubuntu 22