Error with igraph::layout

Here is my code:

library(ggnetwork)
load('ggnetwork_input.RData') # this has the object 'n' of class igraph
# you can access the data here: 
https://drive.google.com/file/d/1fsrzBcw5B5TIvajXKizeD6-4Pntk4YqJ/view?usp=sharing
p <- ggnetwork(n, layout = "fruchtermanreingold", cell.jitter = 0.75)

I m getting this error

Error in igraph::layout_(model, layout, ...) : 
  all(sapply(modifiers, inherits, what = "igraph_layout_modifier")) is not TRUE
Calls: <Anonymous> ... ggnetwork -> fortify.igraph -> <Anonymous> -> stopifnot

SessionInfo:

> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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] ggnetwork_0.5.8 ggplot2_3.3.0  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6     withr_2.2.0      assertthat_0.2.1 dplyr_0.8.5     
 [5] crayon_1.3.4     grid_4.0.0       R6_2.4.1         lifecycle_0.2.0 
 [9] gtable_0.3.0     magrittr_1.5     scales_1.1.1     pillar_1.4.4    
[13] rlang_0.4.6      rstudioapi_0.11  vctrs_0.3.0      ellipsis_0.3.0  
[17] tools_4.0.0      glue_1.4.1       igraph_1.2.5     purrr_0.3.4     
[21] munsell_0.5.0    yaml_2.2.1       compiler_4.0.0   pkgconfig_2.0.3 
[25] colorspace_1.4-1 tidyselect_1.1.0 tibble_3.0.1

Iā€™m not familiar with the ggnetwork library. It seems to me that it is a problem with that package, rather than with igraph. Perhaps it would be better to ask for support with that package. If it turns out that there is a problem with igraph, the people behind ggnetwork may point us to a specific problem.

Or do you have any problem with plotting in igraph itself? In that case, please provide a minimal working example that illustrates the problem.

The problem occurs when I use ggnetwork which calls igraph::layout_ which is why I posted it here.I will post to ggnetwork and see what they say.

In the meanwhile, I will also post a reproducible example, in case this gets redirected to igraph:

library(igraph)
library(GeneNetworkBuilder)
library(ggnetwork)
data("ce.miRNA.map")
data("example.data")
data("ce.interactionmap")
data("ce.IDsMap")
sifNetwork<-buildNetwork(example.data$ce.bind, ce.interactionmap, level=2)
cifNetwork<-filterNetwork(rootgene=ce.IDsMap["DAF-16"], sifNetwork=sifNetwork, 
                          exprsData=uniqueExprsData(example.data$ce.exprData, "Max", condenseName='logFC'),
                          mergeBy="symbols",
                          miRNAlist=as.character(ce.miRNA.map[ , 1]), tolerance=1)
gR<-polishNetwork(cifNetwork)
tmpNetwork <- igraph.from.graphNEL(gR)
p <- ggnetwork(tmpNetwork, layout = "fruchtermanreingold", cell.jitter = 0.75)

I feel like the problem is definitely with igraph or something with my installation of it. I traced back to where the issue is occurring and it points to this line of the code:

If I just set the layout and cell.jitter which is what is being passed from ggnetwork to igraph::layout_ and assign them as a list to modifiers, the code corresponding to line 82 returns FALSE and which is why it is throwing an error.

> modifiers <- list(layout = "fruchtermanreingold", cell.jitter = 0.75)
> all(sapply(modifiers, inherits, what = "igraph_layout_modifier"))
[1] FALSE

Let me know if I am misunderstanding anything.

I just was able to debug the issue. The problem is occurring with igraph v1.2.5 but not with igraph v1.2.4 and same versions of ggnetwork. So the issue is with the latest version of igraph.

Thanks
Komal

1 Like

Ok, thanks, that is very helpful! We should then make sure to file a bug report at https://github.com/igraph/rigraph/issues. There will (hopefully soon) be a new release, we will have to see if the same problem persists.

1 Like

Re: using ggnetwork with an igraph object and layout function, this works:

ggnetwork::ggnetwork(n, layout = with_fr())

It seems that cell.jitter is not a valid parameter for igraph's Fruchterman-Reingold layout (anymore?). This explains the error message you get, because your code sends the parameter to igraph::layout_, which answers back that the parameter is unknown.