# Error with igraph::layout

**URL:** https://igraph.discourse.group/t/error-with-igraph-layout/228
**Category:** Usage
**Tags:** R
**Created:** [15 May 2020 19:58 UTC](https://igraph.discourse.group/t/error-with-igraph-layout/228 "2020-05-15T19:58:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Komal\_Rathi](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/komal_rathi/32/219_2.png) [@Komal\_Rathi](https://igraph.discourse.group/u/Komal_Rathi)
#### Post date: [15 May 2020 19:58 UTC](https://igraph.discourse.group/t/error-with-igraph-layout/228/1 "2020-05-15T19:58:18Z")

</div>

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
```

---

<div class="post-metadata">

### Author: ![vtraag](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/vtraag/32/38_2.png) [@vtraag](https://igraph.discourse.group/u/vtraag)
#### Post date: [15 May 2020 21:04 UTC](https://igraph.discourse.group/t/error-with-igraph-layout/228/2 "2020-05-15T21:04:43Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Komal\_Rathi](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/komal_rathi/32/219_2.png) [@Komal\_Rathi](https://igraph.discourse.group/u/Komal_Rathi)
#### Post date: [15 May 2020 21:21 UTC](https://igraph.discourse.group/t/error-with-igraph-layout/228/3 "2020-05-15T21:21:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Komal\_Rathi](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/komal_rathi/32/219_2.png) [@Komal\_Rathi](https://igraph.discourse.group/u/Komal_Rathi)
#### Post date: [15 May 2020 21:43 UTC](https://igraph.discourse.group/t/error-with-igraph-layout/228/4 "2020-05-15T21:43:50Z")

</div>

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:

> <https://github.com/cran/igraph/blob/master/R/layout.R#L82>

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.

---

<div class="post-metadata">

### Author: ![Komal\_Rathi](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/komal_rathi/32/219_2.png) [@Komal\_Rathi](https://igraph.discourse.group/u/Komal_Rathi)
#### Post date: [15 May 2020 22:54 UTC](https://igraph.discourse.group/t/error-with-igraph-layout/228/5 "2020-05-15T22:54:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![vtraag](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/vtraag/32/38_2.png) [@vtraag](https://igraph.discourse.group/u/vtraag)
#### Post date: [16 May 2020 06:09 UTC](https://igraph.discourse.group/t/error-with-igraph-layout/228/6 "2020-05-16T06:09:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![briatte](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/briatte/32/307_2.png) [@briatte](https://igraph.discourse.group/u/briatte)
#### Post date: [17 July 2020 06:40 UTC](https://igraph.discourse.group/t/error-with-igraph-layout/228/7 "2020-07-17T06:40:28Z")

</div>

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

```r
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.
