Open bdemchak opened 3 years ago
deleteDuplicateEdges is not working. Probably because the change of .edgeNameToEdgeSUID in RCy3.util.R.
Added internal function first. Still working on this function.
Fixed.
Still not working.
@yihangx Still open or fixed?
This is still open. In py4cytoscape, it uses list comprehension there: https://github.com/cytoscape/py4cytoscape/blob/ad4ac43919d34c955d88ce07d5fc540a693b6700/py4cytoscape/network_selection.py#L788-L791 In R, there is no list comprehension, and I need to find an alternative way to do this.
List comprehensions can be complex, but they still map to a simpler construct. For example:
all_edges = [build_sorted_edge_equivalents(x) for x in parse_edges(all_edges)]
maps to
all_edges = []
for x in parse_edges(all_edges):
all_edges.append(build_sorted_edge_equivalents(x))
Likewise:
all_edges = [(x, None) for x in all_edges]
maps to
all_edges = []
for x in all_edges:
all_edges.append((x, None))
Note that in this case, all_edges ends up as a list of tuples:
[(node1,node2), (node1,node3), (node2,node3)] ... for example.
A more complicated example:
dup_edge_suids = [get_edge_suids(unique_edge[0]) + get_edge_suids(unique_edge[1]) for unique_edge in edge_counter if edge_counter[unique_edge] > 1]
maps to:
dup_edge_suids = []
for unique_edge in edge_counter:
if edge_counter[unique_edge] > 1:
dup_edge_suids.append(unique_edge[1])
Comprehensions in Python are pretty convenient and concise. I don't know whether R has a similar construct.
py4cytoscape now has an extra parameter on delete_duplicate_edges ... it allows edge direction to be ignored.
The overall flow of the function was maintained, but important changes were made to allow different definitions of edge equivalence, and performance was improved considerably. (On my PC, executing the old structure on 3000 edges took about 11 minutes.)
I recommend that the same changes be made to the RCy3 version.