cytoscape / py4cytoscape

Python library for calling Cytoscape Automation via CyREST
https://Py4Cytoscape.readthedocs.io
Other
69 stars 15 forks source link

Issue with mapping node/edge names to SUIDs #41

Closed AlexanderPico closed 3 years ago

AlexanderPico commented 3 years ago

This issue in RCy3 came up (https://github.com/cytoscape/RCy3/issues/115) and was resoved by refactoring edge_name_to_edge_suid and node_name_to_node_suid. The py4cy code is already different from how RCy3 worked, so this may or may not be an issue for py4cy: https://github.com/cytoscape/py4cytoscape/blob/master/py4cytoscape/py4cytoscape_utils.py#L326

But I'll detail a couple test cases that exposed the issued in RCy3 so we can see...

AlexanderPico commented 3 years ago

Test 1: Accurate ordering of name-suid mapping.

Read in the two attached files: edges_for_Cytoscape_test.txt nodes_for_Cytoscape_test.txt

Translate this to py4cy:

for (i in 1:10){
    createNetworkFromDataFrames(nodes, edges, "test1", "test1 collection")
    edgeTable <- getTableColumns("edge", c("name", "shared name"))
    if(!identical(edgeTable[,1], edgeTable[,2])) {
      stop(paste('Network', i, "data is currupt."))
      } else {
        print (paste("Network", i, "passes test 1."))
      }
  }

It doesn't always fail, so it's repeated 10 times...

AlexanderPico commented 3 years ago

Test 2A: Simple multigraph

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

View Edge Table in Cytoscape. Success: the type column will have E1 and E2 values. Fail: one value will be missing from the type column.

AlexanderPico commented 3 years ago

Test 2B: Large multigraph

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

Sort the type column in the Edge Table in Cytoscape. Success: the type column will be full of letters, a-z. Fail: one or more value will be missing from the type column, e.g., a bunch of blanks before 'a'.

bdemchak commented 3 years ago

@AlexanderPico This appears to be fixed in 0.0.9. I'm closing this issue. If you find problems, please feel free to re-open.