Skip to content

Latest commit

 

History

History
97 lines (70 loc) · 3.91 KB

convertnicecx.rst

File metadata and controls

97 lines (70 loc) · 3.91 KB

Converting NiceCXNetwork objects to other formats

Note

Using the newer data model :py~ndex2.cx2.CX2Network is encouraged since all networks on NDEx can be retrieved in newer CX2 format via the NDEx REST Service

Below are converters that facilitate conversion of ~ndex2.nice_cx_network.NiceCXNetwork object to other types

ndex2.nice_cx_network.DefaultNetworkXFactory

This networkx converter is still callable, but has been deprecated

ndex2.nice_cx_network.LegacyNetworkXVersionTwoPlusFactory

Base class for Networkx converters above

ndex2.nice_cx_network.NetworkXFactory

For conversion to Pandas see :py~ndex2.nice_cx_network.NiceCXNetwork.to_pandas_dataframe

CX2Network

The :py~ndex2.cx2.NoStyleCXToCX2NetworkFactory class provides a straightforward way to convert an existing :py~ndex2.nice_cx_network.NiceCXNetwork object into a :py~ndex2.cx2.CX2Network. It intentionally omits the style of the original network. It is useful in scenarios where only the network's structure and data are needed without the style information.

from ndex2.nice_cx_network import NiceCXNetwork
from ndex2.cx2 import NoStyleCXToCX2NetworkFactory

# Create a NiceCXNetwork object
nice_cx_network = NiceCXNetwork()

# Your code to populate nice_cx_network...

# Creating an instance of NoStyleCXToCX2NetworkFactory
factory = NoStyleCXToCX2NetworkFactory()

# Converting NiceCXNetwork to CX2Network without style
cx2_network = factory.get_cx2network(nice_cx_network)

# The resulting cx2_network is now a CX2Network object ready for further use

Note

The conversion preserves the network's data, data attributes and structure.

Warning

Be aware that the visual style from the :py~ndex2.nice_cx_network.NiceCXNetwork will not be preserved in the :py~ndex2.cx2.CX2Network. This includes any node or edge styles, layouts, or color schemes.

Why Convert to CX2Network?

  • Performance: Efficient conversion to CX2 format for improved performance in data processing.
  • Compatibility: Ensures compatibility with tools and libraries designed for CX2 format.

    It allows to generate hierarchy in HCX format which is compatible with Cytoscape Web.

  • New Features: Leverage new features and functionalities available in the CX2 format.

Note

CX version 2 is commonly referred to as CX2. In the Cytoscape ecosystem, CX2 files typically carry the .cx2 file extension. This distinguishes them from CX version 1 networks, which usually use the .cx suffix.