rigraph icon indicating copy to clipboard operation
rigraph copied to clipboard

Error trying to plot a network from a 'Spiec-Easi' result

Open mianfermar opened this issue 8 years ago • 2 comments

Hi there!

I am very very new at igraph package and just a little more than a rookie in R, so maybe my questions are a bit trivial. I apologize for that.

I am triying to run a script that combines the package 'Spiec-Easi' with 'igraph' to perform a network analysis and its plot.

I have encountered some problems with my data format, but most of them has been overcome. However, I am now facing one that I cannot solve by myself. I copy my whole script and I attach the data in .csv file format just in case you want to have a look at it:

library(devtools)
library(SpiecEasi)
library(igraph)
library(phyloseq)

tabla <- read.csv("tabla_prueba.txt")

rownames(tabla) <- tabla[,1]
tabla <- tabla[,-1]
tabla <- t(tabla)

se.tabla <- spiec.easi(tabla, method='mb', lambda.min.ratio=1e-2, nlambda=20, icov.select.params=list(rep.num=20))

se.tabla <- unlist(se.tabla)

ig.tabla <- adj2igraph(se.tabla$refit)

plot_network(ig.tabla, tabla)

Everything seems to work properly until the very last command, when I get the following:

Error in `$<-.data.frame`(`*tmp*`, "id", value = c(1L, 0L)) : 
  replacement has 2 rows, data has 0

Although it seems to be a very common issue, I have not found any viable solution on Internet.

Can anyone help with this problem?

Thanks a lot! tabla_prueba.txt

mianfermar avatar Jun 09 '17 11:06 mianfermar

plot_network is not an igraph function, so this does not seem to be an igraph issue.

gaborcsardi avatar Jun 09 '17 12:06 gaborcsardi

Hi there, I have been having the same issue.

I can actually plot the network just fine the first time, but trying to do it again at any point produces the same error described by @mianfermar .

spiec.graph=adj2igraph(spiec.out$refit, vertex.attr=list(name=taxa_names(phyloseq.obj))) plot_network(spiec.graph, phyloseq.obj, type='taxa', color="Rank3", label=NULL)

`Error in vcount(g): Not a graph object Traceback:

  1. plot_network(colskin.se.out2, colskin_20, type = "taxa", color = "Rank3", . label = NULL)
  2. vcount(g)
  3. stop("Not a graph object")`

Has there been any resolution to this issue? @mianfermar , did you ever come across any fixes? Sorry, I realize this is likely not a direct igraph issue.

hollylutz avatar Jan 16 '18 19:01 hollylutz

Not a direct igraph issue so closing.

ntamas avatar Nov 02 '22 10:11 ntamas