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

netvisual_circle error #547

Open Ketomihine opened 1 year ago

Ketomihine commented 1 year ago

Thank you for developing such a powerful tool for us !!!

Hello, I encountered the following error when running the sample data of the software.

This is my code: groupSize <- as.numeric(table(cellchat@idents)) par(mfrow = c(1,2), xpd=TRUE) netVisual_circle(cellchat@net$count, vertex.weight = groupSize, weight.scale = T, label.edge= F, title.name = "Number of interactions") netVisual_circle(cellchat@net$weight, vertex.weight = groupSize, weight.scale = T, label.edge= F, title.name = "Interaction weights/strength")

Error in i_set_edge_attr(x, attr(value, "name"), index = value, value = attr(value, : Length of new attribute value must be 1 or 115, the number of target edges, not 107

mat <- cellchat@net$weight par(mfrow = c(3,4), xpd=TRUE) for (i in 1:nrow(mat)) { mat2 <- matrix(0, nrow = nrow(mat), ncol = ncol(mat), dimnames = dimnames(mat)) mat2[i, ] <- mat[i, ] netVisual_circle(mat2, vertex.weight = groupSize, weight.scale = T, edge.weight.max = max(mat), title.name = rownames(mat)[i]) }

Error in i_set_edge_attr(x, attr(value, "name"), index = value, value = attr(value, : Length of new attribute value must be 1 or 9, the number of target edges, not 2

This is my sessioninfo() :

R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale: [1] LC_COLLATE=Chinese (Simplified)_China.utf8 LC_CTYPE=Chinese (Simplified)_China.utf8
[3] LC_MONETARY=Chinese (Simplified)_China.utf8 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.utf8

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

other attached packages: [1] patchwork_1.1.2 CellChat_1.6.1 Biobase_2.58.0 BiocGenerics_0.44.0 ggplot2_3.4.1
[6] igraph_1.4.0 dplyr_1.1.0

loaded via a namespace (and not attached): [1] colorspace_2.1-0 ggsignif_0.6.4 rjson_0.2.21 ellipsis_0.3.2
[5] rprojroot_2.0.3 circlize_0.4.16 GlobalOptions_0.1.2 BiocNeighbors_1.16.0 [9] fs_1.6.1 clue_0.3-64 rstudioapi_0.14 farver_2.1.1
[13] ggpubr_0.6.0 listenv_0.9.0 remotes_2.4.2 ggrepel_0.9.3
[17] RSpectra_0.16-1 fansi_1.0.4 codetools_0.2-18 doParallel_1.0.17
[21] cachem_1.0.6 knitr_1.42 pkgload_1.3.2 jsonlite_1.8.4
[25] broom_1.0.3 gridBase_0.4-7 cluster_2.1.4 png_0.1-8
[29] shiny_1.7.4 BiocManager_1.30.19 compiler_4.2.2 backports_1.4.1
[33] Matrix_1.5-1 fastmap_1.1.0 cli_3.6.0 later_1.3.0
[37] htmltools_0.5.4 prettyunits_1.1.1 tools_4.2.2 coda_0.19-4
[41] gtable_0.3.1 glue_1.6.2 reshape2_1.4.4 Rcpp_1.0.10
[45] carData_3.0-5 statnet.common_4.8.0 NMF_0.25 vctrs_0.5.2
[49] svglite_2.1.1 iterators_1.0.14 ggalluvial_0.12.4 xfun_0.37
[53] stringr_1.5.0 network_1.18.1 globals_0.16.2 ps_1.7.2
[57] irlba_2.3.5.1 mime_0.12 miniUI_0.1.1.1 lifecycle_1.0.3
[61] rngtools_1.5.2 devtools_2.4.5 rstatix_0.7.2 future_1.31.0
[65] scales_1.2.1 promises_1.2.0.1 parallel_4.2.2 RColorBrewer_1.1-3
[69] ComplexHeatmap_2.15.1 yaml_2.3.7 curl_5.0.0 pbapply_1.7-0
[73] memoise_2.0.1 reticulate_1.28 ggnetwork_0.5.10 stringi_1.7.12
[77] S4Vectors_0.36.1 desc_1.4.2 foreach_1.5.2 pkgbuild_1.4.0
[81] BiocParallel_1.32.5 shape_1.4.6 systemfonts_1.0.4 rlang_1.0.6
[85] pkgconfig_2.0.3 matrixStats_0.63.0 evaluate_0.20 lattice_0.20-45
[89] purrr_1.0.1 labeling_0.4.2 htmlwidgets_1.6.1 cowplot_1.1.1
[93] processx_3.8.0 tidyselect_1.2.0 parallelly_1.34.0 plyr_1.8.8
[97] magrittr_2.0.3 R6_2.5.1 IRanges_2.32.0 generics_0.1.3
[101] profvis_0.3.7 sna_2.7-1 pillar_1.8.1 withr_2.5.0
[105] abind_1.4-5 tibble_3.1.8 future.apply_1.10.0 car_3.1-1
[109] crayon_1.5.2 utf8_1.2.3 rmarkdown_2.20 urlchecker_1.0.1
[113] GetoptLong_1.0.5 usethis_2.1.6 grid_4.2.2 FNN_1.1.3.1
[117] callr_3.7.3 forcats_1.0.0 digest_0.6.31 xtable_1.8-4
[121] tidyr_1.3.0 httpuv_1.6.8 stats4_4.2.2 munsell_0.5.0
[125] registry_0.5-1 sessioninfo_1.2.2

Thanks!!!

Ithinky commented 1 year ago

I have the same question with you and I'm also waiting for a good solution.

mingble commented 1 year ago

same errors during the process...

Fengyonghao commented 1 year ago

I have the same question and I'm also looking for a good solution.

zhongOliver commented 1 year ago

The package igaph 1.4.0 is not compatible with cellchat. When I changed igraph 1.4.0 to 1.3.5, the problem was solved.

Ithinky commented 1 year ago

@zhongOliver Thank you for your answer. I think you mean R package igraph ,but my igraph is 1.3.5, and I still encounter the error.

QiangShiPKU commented 1 year ago

The package igaph 1.4.0 is not compatible with cellchat. When I changed igraph 1.4.0 to 1.3.5, the problem was solved.

I have the same error using R igraph 1.4.0. And changing to 1.3.5 succeeds. Many thanks.

sqjin commented 1 year ago

@Ketomihine @Ithinky @mingble I just updated my igraph via devtools::install_github("igraph/rigraph"). It is interesting that there is no issue when running the example data in the tutorial.

szhorvat commented 1 year ago

Error in i_set_edge_attr(x, attr(value, "name"), index = value, value = attr(value, : Length of new attribute value must be 1 or 9, the number of target edges, not 2

igraph developer here. This error is issued only by igraph 1.4, as this version is stricter in its checks when setting edge or vertex attributes. Now you must supply the same number of values as the number of edges or vertices (or just a single value to use for all edges/vertices). Previous versions would use recycling to fill out missing values.

In other words, while downgrading to 1.3.5 will make the error message go away, this error message likely does indicate a real problem with how igraph is being used. Proceed with caution.

The change is noted in the NEWS file:

https://cran.r-project.org/web/packages/igraph/news/news.html

Fengyonghao commented 1 year ago

@QiangShiPKU @Ithinky @sqjin degrade igraph form 1.4.0 to 1.3.5 succeeds too. Thanks very much.

mingble commented 1 year ago

Error in i_set_edge_attr(x, attr(value, "name"), index = value, value = attr(value, : Length of new attribute value must be 1 or 9, the number of target edges, not 2

igraph developer here. This error is issued only by igraph 1.4, as this version is stricter in its checks when setting edge or vertex attributes. Now you must supply the same number of value as the number of edges or vertices (or just a single value to use for all edges/vertices). Previous versions would use recycling to fill out missing values.

In other words, while downgrading to 1.3.5 will make the error message go away, this error message likely does indicate a real problem with how igraph is being used. Proceed with caution.

The change is noted in the NEWS file:

https://cran.r-project.org/web/packages/igraph/news/news.html

I failed with installing igraph 1.3.5 version from source because of failed compilation. Can we use 1.4.0 version to make the plots correctly?

HuXuantao commented 1 year ago

Error in i_set_edge_attr(x, attr(value, "name"), index = value, value = attr(value, : Length of new attribute value must be 1 or 9, the number of target edges, not 2

igraph developer here. This error is issued only by igraph 1.4, as this version is stricter in its checks when setting edge or vertex attributes. Now you must supply the same number of value as the number of edges or vertices (or just a single value to use for all edges/vertices). Previous versions would use recycling to fill out missing values. In other words, while downgrading to 1.3.5 will make the error message go away, this error message likely does indicate a real problem with how igraph is being used. Proceed with caution. The change is noted in the NEWS file: https://cran.r-project.org/web/packages/igraph/news/news.html

I failed with installing igraph 1.3.5 version from source because of failed compilation. Can we use 1.4.0 version to make the plots correctly?

The same to me. I have tried installing igraph 1.3.5 in r 4.1.3 with RTOOLS40 but failed. It doesn't work, drives me crazy

VBRay commented 1 year ago

I used the remotes::install_version function to install igraph 1.3.5 and it succeeded. Luckily, there is no error when running the netvisual_circle function.

dbswls0322 commented 1 year ago

Hi guys, I also got struggle due to this problem.

But now I found a solution thanks to contributor of "igraph".

If you update CellChat package version 1.6.1, then you can solve this problem regardless of igraph's version.

I hope it'll be helpful for your work.

jinyanyouyu1994 commented 1 year ago

I used the remotes::install_version function to install igraph 1.3.5 and it succeeded. Luckily, there is no error when running the netvisual_circle function.

My cellchat version is 1.6.1, but I also have the same problem. I reinstalled igraph (1.3.5) and still did not solve this problem, but I found that after I uploaded another merged cellchat object, there was no corresponding problem. So maybe there's something wrong with my cell chat object