Using NiceCXNetwork.to_networkx(mode='default') to convert to networkx and then ndex2.create_nice_cx_from_networkx has problems if a node or edge attribute has commas in its value. In this case that attribute will be set to list_of_string while other attributes will be set to a string. This is because data type is decided for each attribute value.
CX format allows the data type to differ for node/edge attributes, but networkx does not. Couple ways to address this:
When converting to networkx, walk across all attributes and verify they are of the same type before converting, if not use a type that accommodates all data or raise an error or at least a warning about this.
When converting to networkx, add a new network attribute to denote the type of data for each node/edge attribute and store it in networkx.graph attribute that can be used when converting the data back to NiceCXNetwork Could also store the data type as an attribute on the node/edge too
Using
NiceCXNetwork.to_networkx(mode='default')
to convert to networkx and thenndex2.create_nice_cx_from_networkx
has problems if a node or edge attribute has commas in its value. In this case that attribute will be set tolist_of_string
while other attributes will be set to astring
. This is because data type is decided for each attribute value.CX format allows the data type to differ for node/edge attributes, but networkx does not. Couple ways to address this:
When converting to networkx, walk across all attributes and verify they are of the same type before converting, if not use a type that accommodates all data or raise an error or at least a warning about this.
When converting to networkx, add a new network attribute to denote the type of data for each node/edge attribute and store it in
networkx.graph
attribute that can be used when converting the data back toNiceCXNetwork
Could also store the data type as an attribute on the node/edge too