cytoscape / RCy3

New version of RCy3, redesigned and collaboratively maintained by Cytoscape developer community
MIT License
49 stars 20 forks source link

Edge attributes in multigraphs #41

Closed jonaszierer closed 5 years ago

jonaszierer commented 5 years ago

When creating a multigraph (i.e. a graph with multiple edges between the same pair of vertices) edge attributes are not transferred correctly to Cytoscape. Specifically, all edges between one pair of nodes will have the same edge attributes. for instance:

require(igraph)
require(RCy3)
graph <- graph_from_data_frame(data.frame(v1 = rep("A", 2),
                                          v1 = rep("B", 2),
                                          type = c("E1", "E2")))
createNetworkFromIgraph(graph, "graph")

Both edges will have type = E2 in cytoscape. When you i.e. try to colour edges by type all of them will have the same colour.

AlexanderPico commented 5 years ago

Fixed in 2.2.6. Will be updated at bioconductor within 48 hours. Available now via github:

install.packages("devtools")
library(devtools)
install_github('cytoscape/RCy3', build_vignettes=TRUE)
library(RCy3)
jonaszierer commented 5 years ago

Thanks for the quick fix! There still seems to be a problem in large networks. If there are too many multi-edges (haven't quite found out how many) some edge attributes are lost. Try this:

require(igraph)
require(RCy3)
set.seed(1)
nn <- 100
t  <- 4
graph         <- erdos.renyi.game(n = nn, p = 0.1)
E(graph)$type <- sample(letters, length(E(graph)), replace = T)
graph         <- add_edges(graph, sample(1:nn, size = nn*t*2, replace = T), attr = list(type = sample(letters, nn*t, replace = T)))
createNetworkFromIgraph(graph, "graph")
AlexanderPico commented 5 years ago

Thank you both for the additional tests. I can reproduce this.

AlexanderPico commented 5 years ago

Fixed in upcoming 2.4.0. Available now via github:

install.packages("devtools")
library(devtools)
install_github('cytoscape/RCy3', build_vignettes=TRUE)
library(RCy3)
AlexanderPico commented 3 years ago

Updated solution tested with examples above. See https://github.com/cytoscape/RCy3/issues/115