cytoscape / RCy3

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

RBGL shortest path always giving path length NA and path_details NA #202

Closed mharoun20 closed 1 year ago

mharoun20 commented 1 year ago

I tried to implement the RBGL code from the paper:

library(RBGL) # install from Bioconductor

Convert a sample Cytoscape network to a graph object

openSession() g <- createGraphFromNetwork()

Identify start and finish nodes (styling is optional)

start <- "YNL216W" finish <- "YER040W" setNodeBorderWidthBypass(c(start,finish), 20) setNodeBorderColorBypass(start,"#00CC33") setNodeBorderColorBypass(finish,"#CC00CC")

Use RBGL to perform shortest path calculation

shortest <- sp.between(g, start, finish) shortest$'YNL216W:YER040W'$length

But I always get length and path details of NAs and path length of 1. I tried it on multiple networks include the sample networks at cystoscope. I am using RStudio Version 1.4.1106 with R version 4.2.2 on Windows 10. Any idea why this is happening?

AlexanderPico commented 1 year ago

When I tried running this notebook, I ran into a duplicate edge error in the step:

g <- createGraphFromNetwork()
Error in igraph::igraph.to.graphNEL(ig) : 
  multiple edges are not supported in graphNEL graphs

Somehow, a duplicate edge was inserted into the sample network since the vignette was written. I've inserted a couple lines to simply delete it just after openSession():

selectEdges("YPL248C (pp) YML051W","name")
deleteSelectedEdges()

After that, the rest of the notebook ran fine and produced the expected result. Does this address your issue?

szhorvat commented 1 year ago

Somehow, a duplicate edge was inserted into the sample network since the vignette was written.

Perhaps it was always there, but it wasn't detected. igraph only added a check for multi-edges in version 1.4.0. Conversions of multigraphs to graphNEL before that version should be considered invalid. See https://github.com/igraph/rigraph/issues/575

Generally, graphNEL appears to support only simple graphs, but this issue is not discussed in detail in its documentation. There is a passing reference mentioning that multi-edges won't be handled properly, and there is no statement on self-loops at all. See also https://github.com/Bioconductor/graph/issues/17 where I asked about this and waiting to receive a response.