igraph / rigraph

igraph R package
https://r.igraph.org
551 stars 200 forks source link

igraph 1.3.5 version error #690

Closed dbswls0322 closed 1 year ago

dbswls0322 commented 1 year ago

Hello, I'm an user of "igraph"

I wanna ask you guys one thing.

I need to run "Cellchat" package. In this process, "igraph" ver1.3.5 is necessary.

But in many cases, there are someone who can't install "igraph" ver1.3.5 in R. https://github.com/sqjin/CellChat/issues/547#issue-1581351747

As i said, without this package we can't do anything.

In conclusion, There are 2 options. First, I want you to solve the installing issue in ver 1.3.5 Second, If you can't solve above problem, then please make ver 1.4.1 be available in Cellchat package

So I beg you, please solve this problem asap.

########################################################################

This is my code when installing package.

devtools::install_version("igraph", version = "1.3.5")

Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/00LOCK-igraph/00new/igraph/libs/igraph.so': dlopen(/Library/Frameworks/R.framework/Versions/4.2/Resources/library/00LOCK-igraph/00new/igraph/libs/igraph.so, 6): Library not loaded: @rpath/libxml2.2.dylib Referenced from: /Library/Frameworks/R.framework/Versions/4.2/Resources/library/00LOCK-igraph/00new/igraph/libs/igraph.so Reason: image not found Error: loading failed Execution halted ERROR: loading failed

removing ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/igraph’

And this is result of that code.

Also I'll attach my error from cellchat when i use "igraph" ver 1.4.1

Whenever I run code below, netVisual_aggregate(Cellchat, signaling = pathway.show, layout = "chord")

then i got this error message Error in i_set_edge_attr(x, attr(value, "name"), index = value, value = attr(value, : Length of new attribute value must be 1 or 8, the number of target edges, not 6

https://github.com/sqjin/CellChat/issues/547#issue-1581351747 If you check this link, you can see that many people suffer due to this problem.

########################################################################

R version 4.2.1 (2022-06-23) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Big Sur 11.5.2

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: character(0)

other attached packages: [1] CellChat_1.5.0

krlmlr commented 1 year ago

Thanks. Is this linked to https://github.com/sqjin/CellChat/issues/547?

We believe that the code in the CellChat package has a subtle problem that is uncovered with recent changes in igraph 1.4.1. This issue should be fixed in the CellChat package.

To help, we need a fully reproducible example. What code do I need to run, on my machine, to see the problem you are seeing with the CellChat package and igraph 1.4.1? See https://reprex.tidyverse.org/articles/reprex-dos-and-donts.html and https://reprex.tidyverse.org/ for advice on creating a good reproducible example.

dbswls0322 commented 1 year ago

Thank you for reply.

Here is my code.

mat <- Cellchat@net$weight par(mfrow = c(2,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]) }

and this is my error

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

Actually I just followed the tutorial served by cellchat's github. So every process is same with cellchat's tutorial. And It was available about 6months ago.

https://htmlpreview.github.io/?https://github.com/sqjin/CellChat/blob/master/tutorial/CellChat-vignette.html

Also I can run this code. 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")

But except for this code, nothing can be ran.

I hope it'll be helpful for you guys. If you need more information, please let me know.

Regardless.

krlmlr commented 1 year ago

Thanks. When I run your code on my machine, I get:

mat <- Cellchat@net$weight
#> Error in eval(expr, envir, enclos): object 'Cellchat' not found
par(mfrow = c(2, 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 nrow(mat): object 'mat' not found

Created on 2023-03-02 with reprex v2.0.2

What packages and what datasets do I need? Please take a look at https://reprex.tidyverse.org/articles/reprex-dos-and-donts.html.

dbswls0322 commented 1 year ago

Oh, I'll send you the code how to make cellchat object.

If you follow this direction, you can run that code.

library(CellChat) library(patchwork) options(stringsAsFactors = FALSE)

load(url("https://ndownloader.figshare.com/files/25950872")) load("/"your directory"/data_humanSkin_CellChat.rda")

data.input = data_humanSkin$data # normalized data matrix meta = data_humanSkin$meta # a dataframe with rownames containing cell mata data cell.use = rownames(meta)[meta$condition == "LS"] # extract the cell names from disease data

data.input = data.input[, cell.use] meta = meta[cell.use, ]

unique(meta$labels) # check the cell labels

> [1] Inflam. FIB FBN1+ FIB APOE+ FIB COL11A1+ FIB cDC2

> [6] LC Inflam. DC cDC1 CD40LG+ TC Inflam. TC

> [11] TC NKT

> 12 Levels: APOE+ FIB FBN1+ FIB COL11A1+ FIB Inflam. FIB cDC1 cDC2 ... NKT

cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels")

cellchat <- addMeta(cellchat, meta = meta) cellchat <- setIdent(cellchat, ident.use = "labels") # set "labels" as default cell identity levels(cellchat@idents) # show factor levels of the cell labels groupSize <- as.numeric(table(cellchat@idents)) # number of cells in each cell group

CellChatDB <- CellChatDB.human cellchat@DB <- CellChatDB cellchat <- subsetData(cellchat) future::plan("multisession", workers = 4)

cellchat <- identifyOverExpressedGenes(cellchat) cellchat <- identifyOverExpressedInteractions(cellchat) cellchat <- projectData(cellchat, PPI.human) cellchat <- computeCommunProb(cellchat) cellchat <- filterCommunication(cellchat, min.cells = 10) cellchat <- computeCommunProbPathway(cellchat) cellchat <- aggregateNet(cellchat)

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")

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]) }

It's exact my code.

If there is any problem, you can tell me anytime:)

krlmlr commented 1 year ago

Thanks. What is "your directory" or data_humanSkin_CellChat.rda in the code? It's unlikely that I have it.

krlmlr commented 1 year ago

I managed to download the file from figshare and can use it. Running your code now, it takes a bit.

dbswls0322 commented 1 year ago

Oh, that code is for loading data to your R session

If you run code below load(url("https://ndownloader.figshare.com/files/25950872"))

You'll get data_humanSkin_CellChat.rda file. Then you can load that file to your R environment.

If it's not working, just double click that file at your finder or download folder

dbswls0322 commented 1 year ago

That's good!

krlmlr commented 1 year ago

The script takes minutes to run, and it succeeded on my machine the first time I ran it. Is there a random component?

The "multisession" part doesn't exactly help with reproducibility, either.

Can you please attach your cellchat object to this issue, saved with saveRDS() ?

krlmlr commented 1 year ago

I ran a second time, without failure.

Can you please try updating the CellChat package on your machine, if needed?

dbswls0322 commented 1 year ago

Thanks god.

You're genius.

Now it's going on.

You're my saver.

I'll share this solution with the other users.

Have a nice day!!

krlmlr commented 1 year ago

For reference, this is what I'm seeing on my machine, with your .rds file.

I like it how easy it is for me, with the reprex package, to create a code that you can also double-check.

suppressMessages(library(CellChat, warn.conflicts = FALSE))
library(patchwork, warn.conflicts = FALSE)
options(stringsAsFactors = FALSE)

# set.seed(20230302)
#
# path <- tempfile(fileext = ".rda")
# curl::curl_download("https://ndownloader.figshare.com/files/25950872", path)
# load(path)
#
# data.input = data_humanSkin$data # normalized data matrix
# meta = data_humanSkin$meta # a dataframe with rownames containing cell mata data
# cell.use = rownames(meta)[meta$condition == "LS"] # extract the cell names from disease data
#
# data.input = data.input[, cell.use]
# meta = meta[cell.use, ]
#
# unique(meta$labels) # check the cell labels
# #> [1] Inflam. FIB FBN1+ FIB APOE+ FIB COL11A1+ FIB cDC2
# #> [6] LC Inflam. DC cDC1 CD40LG+ TC Inflam. TC
# #> [11] TC NKT
# #> 12 Levels: APOE+ FIB FBN1+ FIB COL11A1+ FIB Inflam. FIB cDC1 cDC2 ... NKT
#
# cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels")
#
# cellchat <- addMeta(cellchat, meta = meta)
# cellchat <- setIdent(cellchat, ident.use = "labels") # set "labels" as default cell identity
# levels(cellchat@idents) # show factor levels of the cell labels
# groupSize <- as.numeric(table(cellchat@idents)) # number of cells in each cell group
#
# CellChatDB <- CellChatDB.human
# cellchat@DB <- CellChatDB
# cellchat <- subsetData(cellchat)
# future::plan("multisession", workers = 4)
#
# cellchat <- identifyOverExpressedGenes(cellchat)
# cellchat <- identifyOverExpressedInteractions(cellchat)
# cellchat <- projectData(cellchat, PPI.human)
# cellchat <- computeCommunProb(cellchat)
# cellchat <- filterCommunication(cellchat, min.cells = 10)
# cellchat <- computeCommunProbPathway(cellchat)
# cellchat <- aggregateNet(cellchat)

cellchat <- readRDS("~/Downloads/Cellchat.rds")

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")


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])
}

Created on 2023-03-02 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.2.2 (2022-10-31) #> os macOS Ventura 13.1 #> system aarch64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Zurich #> date 2023-03-02 #> pandoc 2.19.2 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> abind 1.4-5 2016-07-21 [1] CRAN (R 4.2.0) #> backports 1.4.1 2021-12-13 [1] CRAN (R 4.2.0) #> Biobase * 2.58.0 2022-11-07 [1] Bioconductor #> BiocGenerics * 0.42.0 2022-04-26 [1] Bioconductor #> BiocManager 1.30.19 2022-10-25 [1] CRAN (R 4.2.0) #> BiocNeighbors 1.16.0 2022-11-07 [1] Bioconductor #> BiocParallel 1.32.5 2022-12-25 [1] Bioconductor #> broom 1.0.3 2023-01-25 [1] CRAN (R 4.2.0) #> car 3.1-1 2022-10-19 [1] CRAN (R 4.2.0) #> carData 3.0-5 2022-01-06 [1] CRAN (R 4.2.0) #> CellChat * 1.6.1 2023-03-01 [1] Github (sqjin/CellChat@c7cd04a) #> circlize 0.4.15 2022-05-10 [1] CRAN (R 4.2.0) #> cli 3.6.0 2023-01-09 [1] CRAN (R 4.2.0) #> clue 0.3-64 2023-01-31 [1] CRAN (R 4.2.0) #> cluster 2.1.4 2022-08-22 [2] CRAN (R 4.2.2) #> coda 0.19-4 2020-09-30 [1] CRAN (R 4.2.0) #> codetools 0.2-19 2023-02-01 [1] CRAN (R 4.2.0) #> colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.2.0) #> ComplexHeatmap 2.14.0 2022-11-07 [1] Bioconductor #> cowplot 1.1.1 2020-12-30 [1] CRAN (R 4.2.0) #> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.2.0) #> curl 5.0.0 2023-01-12 [1] CRAN (R 4.2.0) #> DBI 1.1.3 2022-06-18 [1] CRAN (R 4.2.0) #> digest 0.6.31 2022-12-11 [1] CRAN (R 4.2.0) #> doParallel 1.0.17 2022-02-07 [1] CRAN (R 4.2.0) #> dplyr * 1.1.0 2023-01-29 [1] CRAN (R 4.2.0) #> evaluate 0.20 2023-01-17 [1] CRAN (R 4.2.0) #> fansi 1.0.4 2023-01-22 [1] CRAN (R 4.2.0) #> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.0) #> FNN 1.1.3.1 2022-05-23 [1] CRAN (R 4.2.0) #> foreach 1.5.2 2022-02-02 [1] CRAN (R 4.2.0) #> fs 1.6.1 2023-02-06 [1] CRAN (R 4.2.0) #> future 1.31.0 2023-02-01 [1] CRAN (R 4.2.0) #> future.apply 1.10.0 2022-11-05 [1] CRAN (R 4.2.0) #> generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.0) #> GetoptLong 1.0.5 2020-12-15 [1] CRAN (R 4.2.0) #> ggalluvial 0.12.5 2023-02-22 [1] CRAN (R 4.2.0) #> ggnetwork 0.5.10 2021-07-06 [1] CRAN (R 4.2.0) #> ggplot2 * 3.4.1 2023-02-10 [1] CRAN (R 4.2.0) #> ggpubr 0.6.0 2023-02-10 [1] CRAN (R 4.2.0) #> ggrepel 0.9.3 2023-02-03 [1] CRAN (R 4.2.0) #> ggsignif 0.6.4 2022-10-13 [1] CRAN (R 4.2.0) #> GlobalOptions 0.1.2 2020-06-10 [1] CRAN (R 4.2.0) #> globals 0.16.2 2022-11-21 [1] CRAN (R 4.2.0) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0) #> gridBase 0.4-7 2014-02-24 [1] CRAN (R 4.2.0) #> gtable 0.3.1 2022-09-01 [1] CRAN (R 4.2.0) #> highr 0.10 2022-12-22 [1] CRAN (R 4.2.0) #> htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.2.0) #> httr 1.4.4 2022-08-17 [1] CRAN (R 4.2.0) #> igraph * 1.4.1 2023-02-24 [1] CRAN (R 4.2.0) #> IRanges 2.32.0 2022-11-07 [1] Bioconductor #> irlba 2.3.5.1 2022-10-03 [1] CRAN (R 4.2.0) #> iterators 1.0.14 2022-02-05 [1] CRAN (R 4.2.0) #> jsonlite 1.8.4 2022-12-06 [1] CRAN (R 4.2.0) #> knitr 1.42 2023-01-25 [1] CRAN (R 4.2.0) #> lattice 0.20-45 2021-09-22 [2] CRAN (R 4.2.2) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.0) #> listenv 0.9.0 2022-12-16 [1] CRAN (R 4.2.0) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0) #> Matrix 1.5-3 2022-11-11 [1] CRAN (R 4.2.0) #> matrixStats 0.63.0 2022-11-18 [1] CRAN (R 4.2.0) #> mime 0.12 2021-09-28 [1] CRAN (R 4.2.0) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.0) #> network 1.18.0 2022-10-06 [1] CRAN (R 4.2.0) #> NMF 0.25 2022-11-18 [1] CRAN (R 4.2.0) #> parallelly 1.34.0 2023-01-13 [1] CRAN (R 4.2.0) #> patchwork * 1.1.2 2022-08-19 [1] CRAN (R 4.2.0) #> pbapply 1.7-0 2023-01-13 [1] CRAN (R 4.2.0) #> pillar 1.8.1 2022-08-19 [1] CRAN (R 4.2.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.0) #> plyr 1.8.8 2022-11-11 [1] CRAN (R 4.2.0) #> png 0.1-8 2022-11-29 [1] CRAN (R 4.2.0) #> purrr 1.0.1 2023-01-10 [1] CRAN (R 4.2.0) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.2.0) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.2.0) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.2.0) #> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.2.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0) #> RColorBrewer 1.1-3 2022-04-03 [1] CRAN (R 4.2.0) #> Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.2.0) #> registry 0.5-1 2019-03-05 [1] CRAN (R 4.2.0) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.0) #> reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.2.0) #> reticulate 1.28 2023-01-27 [1] CRAN (R 4.2.0) #> rjson 0.2.21 2022-01-09 [1] CRAN (R 4.2.0) #> rlang 1.0.6 2022-09-24 [1] CRAN (R 4.2.0) #> rmarkdown 2.20 2023-01-19 [1] CRAN (R 4.2.0) #> rngtools 1.5.2 2021-09-20 [1] CRAN (R 4.2.0) #> RSpectra 0.16-1 2022-04-24 [1] CRAN (R 4.2.0) #> rstatix 0.7.2 2023-02-01 [1] CRAN (R 4.2.0) #> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.0) #> S4Vectors 0.36.1 2022-12-07 [1] Bioconductor #> scales 1.2.1 2022-08-20 [1] CRAN (R 4.2.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0) #> shape 1.4.6 2021-05-19 [1] CRAN (R 4.2.0) #> sna 2.7-1 2023-01-24 [1] CRAN (R 4.2.0) #> statnet.common 4.7.0 2022-09-08 [1] CRAN (R 4.2.0) #> stringi 1.7.12 2023-01-11 [1] CRAN (R 4.2.0) #> stringr 1.5.0 2022-12-02 [1] CRAN (R 4.2.0) #> styler 1.9.0 2023-01-15 [1] CRAN (R 4.2.0) #> svglite 2.1.0 2022-02-03 [1] CRAN (R 4.2.0) #> systemfonts 1.0.4 2022-02-11 [1] CRAN (R 4.2.0) #> tibble 3.1.8 2022-07-22 [1] CRAN (R 4.2.0) #> tidyr 1.3.0 2023-01-24 [1] CRAN (R 4.2.0) #> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.2.0) #> utf8 1.2.3 2023-01-31 [1] CRAN (R 4.2.0) #> vctrs 0.5.2 2023-01-23 [1] CRAN (R 4.2.0) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0) #> xfun 0.37 2023-01-31 [1] CRAN (R 4.2.0) #> xml2 1.3.3 2021-11-30 [1] CRAN (R 4.2.0) #> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.2.0) #> #> [1] /Users/kirill/Library/R/arm64/4.2/library #> [2] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library #> #> ────────────────────────────────────────────────────────────────────────────── ```
dbswls0322 commented 1 year ago

Thank you for helping me a lot.

I really appreciated your help and kindness.

God bless you.