Skip to content

Issue with netVisual_diffInteraction( ) #456

@Achiraa

Description

@Achiraa

Hello,
I am encountering an error when running netVisual_diffInteraction on a merged CellChat object consisting of two datasets (wt and lysm). Both individual objects were processed using the standard CellChat pipeline (up to aggregateNet) before merging.

> setwd("V:/Tower Lab/Achira Ultron/BT scRNA 2025/cellchat")
> 
> options(future.globals.maxSize = 2000 * 1024^2)
> 
> library(Seurat)
> library(tidyverse)
> library(ggplot2)
> library(CellChat)
> library(patchwork)
> library(presto)
> library(future)
> library(NMF)
> library(ggalluvial)
> library(cowplot)
> library(svglite)
> library(stringr)
> library(plyr)
> library(RColorBrewer)
> 
> #read all the cellchat objects
> wt <- readRDS("V:/Tower Lab/Achira Ultron/BT scRNA 2025/cellchat/cellchat_wt1.rds")
> lysm <- readRDS("V:/Tower Lab/Achira Ultron/BT scRNA 2025/cellchat/cellchat_lysm1.rds")
> levels(lysm@idents)
 [1] "Stem Progenitors Cells" "Macrophages"            "Neutrophils"            "Monocytes"              "Dendritic Cells"        "T and NK Cells"        
 [7] "Muscle Cells"           "Smooth Muscle Cells"    "Osteoclasts"            "Endothelial Cells"      "Fibroblasts Cells"     
> levels(wt@idents)
 [1] "Stem Progenitors Cells" "Macrophages"            "Neutrophils"            "Monocytes"              "Dendritic Cells"        "T and NK Cells"        
 [7] "Fibroblasts Cells"      "Muscle Cells"           "Smooth Muscle Cells"    "Osteoclasts"            "Endothelial Cells"     
> common.levels <- levels(wt@idents)
> lysm@idents <- factor(lysm@idents, levels = common.levels)
> levels(lysm@idents)
 [1] "Stem Progenitors Cells" "Macrophages"            "Neutrophils"            "Monocytes"              "Dendritic Cells"        "T and NK Cells"        
 [7] "Fibroblasts Cells"      "Muscle Cells"           "Smooth Muscle Cells"    "Osteoclasts"            "Endothelial Cells"     
> levels(wt@idents)
 [1] "Stem Progenitors Cells" "Macrophages"            "Neutrophils"            "Monocytes"              "Dendritic Cells"        "T and NK Cells"        
 [7] "Fibroblasts Cells"      "Muscle Cells"           "Smooth Muscle Cells"    "Osteoclasts"            "Endothelial Cells"     
> object.list <- list(wt = wt, lysm = lysm)
> cellchat <- mergeCellChat(object.list, add.names = names(object.list))
> View(object.list)
> cellchat <- mergeCellChat,  object.list,  add.names = names(object.list),  cell.prefix = TRUE)
> ptm = Sys.time()
> gg1 <- compareInteractions(cellchat, show.legend = F, group = c(1,2))
> gg2 <- compareInteractions(cellchat, show.legend = F, group = c(1,2), measure = "weight")
> gg1 + gg2
**> par(mfrow = c(1,2), xpd=TRUE)
> netVisual_diffInteraction(cellchat, weight.scale = T)
Error in p[[type]][[name]][is.na(p[[type]][[name]])] <- i.default.values[[type]][[name]] : 
  replacement has length zero

> netVisual_diffInteraction(cellchat, weight.scale = T, measure = "weight")
Error in p[[type]][[name]][is.na(p[[type]][[name]])] <- i.default.values[[type]][[name]] : 
  replacement has length zero**

> sessionInfo()
R version 4.5.2 (2025-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)

Matrix products: default
LAPACK version 3.12.1

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
[1] future_1.70.0 presto_1.0.0 data.table_1.18.2.1 Rcpp_1.1.1 ggalluvial_0.12.6 RColorBrewer_1.1-3 plyr_1.8.9
[8] svglite_2.2.2 cowplot_1.2.0 ComplexHeatmap_2.26.1 NMF_0.28 cluster_2.1.8.1 rngtools_1.5.2 registry_0.5-1
[15] patchwork_1.3.2 CellChat_1.6.1 Biobase_2.70.0 BiocGenerics_0.56.0 generics_0.1.4 igraph_2.2.2 lubridate_1.9.5
[22] forcats_1.0.1 stringr_1.6.0 dplyr_1.2.0 purrr_1.2.1 readr_2.2.0 tidyr_1.3.2 tibble_3.3.1
[29] ggplot2_4.0.2 tidyverse_2.0.0 Seurat_5.4.0 SeuratObject_5.3.0 sp_2.2-1

loaded via a namespace (and not attached):
[1] RcppAnnoy_0.0.23 splines_4.5.2 later_1.4.8 polyclip_1.10-7 ggnetwork_0.5.14 fastDummies_1.7.5
[7] lifecycle_1.0.5 rstatix_0.7.3 doParallel_1.0.17 globals_0.19.1 lattice_0.22-7 MASS_7.3-65
[13] backports_1.5.0 magrittr_2.0.4 plotly_4.12.0 httpuv_1.6.16 otel_0.2.0 sctransform_0.4.3
[19] spam_2.11-3 spatstat.sparse_3.1-0 reticulate_1.45.0 pbapply_1.7-4 abind_1.4-8 Rtsne_0.17
[25] circlize_0.4.17 IRanges_2.44.0 S4Vectors_0.48.0 ggrepel_0.9.7 irlba_2.3.7 listenv_0.10.1
[31] spatstat.utils_3.2-2 goftest_1.2-3 RSpectra_0.16-2 spatstat.random_3.4-4 fitdistrplus_1.2-6 parallelly_1.46.1
[37] codetools_0.2-20 tidyselect_1.2.1 shape_1.4.6.1 farver_2.1.2 matrixStats_1.5.0 stats4_4.5.2
[43] spatstat.explore_3.7-0 jsonlite_2.0.0 GetoptLong_1.1.0 BiocNeighbors_2.4.0 progressr_0.18.0 Formula_1.2-5
[49] ggridges_0.5.7 survival_3.8-3 iterators_1.0.14 systemfonts_1.3.2 foreach_1.5.2 tools_4.5.2
[55] sna_2.8 ica_1.0-3 glue_1.8.0 gridExtra_2.3 withr_3.0.2 BiocManager_1.30.27
[61] fastmap_1.2.0 digest_0.6.39 timechange_0.4.0 R6_2.6.1 mime_0.13 textshaping_1.0.5
[67] colorspace_2.1-2 scattermore_1.2 tensor_1.5.1 spatstat.data_3.1-9 FNN_1.1.4.1 httr_1.4.8
[73] htmlwidgets_1.6.4 uwot_0.2.4 pkgconfig_2.0.3 gtable_0.3.6 lmtest_0.9-40 S7_0.2.1
[79] htmltools_0.5.9 carData_3.0-6 dotCall64_1.2 clue_0.3-68 scales_1.4.0 png_0.1-8
[85] spatstat.univar_3.1-6 rstudioapi_0.18.0 tzdb_0.5.0 reshape2_1.4.5 rjson_0.2.23 coda_0.19-4.1
[91] statnet.common_4.13.0 nlme_3.1-168 zoo_1.8-15 GlobalOptions_0.1.3 KernSmooth_2.23-26 parallel_4.5.2
[97] miniUI_0.1.2 pillar_1.11.1 vctrs_0.7.1 RANN_2.6.2 promises_1.5.0 ggpubr_0.6.3
[103] car_3.1-5 xtable_1.8-8 cli_3.6.5 compiler_4.5.2 rlang_1.1.7 crayon_1.5.3
[109] future.apply_1.20.2 ggsignif_0.6.4 labeling_0.4.3 stringi_1.8.7 viridisLite_0.4.3 network_1.20.0
[115] deldir_2.0-4 gridBase_0.4-7 lazyeval_0.2.2 spatstat.geom_3.7-0 Matrix_1.7-4 RcppHNSW_0.6.0
[121] hms_1.1.4 shiny_1.13.0 ROCR_1.0-12 broom_1.0.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions