Search code examples
rcytoscape

Cystoscape node color


I'm using RCy3 R package, I've already built a network using some gene expression data, how can I color some nodes in another way, different than the default one? I searched through the package documentation but is a bit cryptic, is there anyone that already did something like this?


Solution

  • In Python3 - this is how .....

    from py2cytoscape.data.cyrest_client import CyRestClient
    from py2cytoscape import cyrest
    
    cy = CyRestClient()
    #Remove previous Networks !!
    cy.session.delete()
    cytoscape=cyrest.cyclient()
    
    network = cy.network.create(name='Test', collection='UK Prem League')
    # Add 4 Nodes
    network.add_node("Prem League")
    network.add_node("Newcastle")
    network.add_node("Liverpool")
    network.add_node("Man City")
    df_network=network.get_node_table()
    
    def get_node_id(node_str):
        return list(df_network[df_network.name==node_str]['SUID'])[0]
    # Add an Edge
    network.add_edge(get_node_id("Newcastle"),get_node_id("Liverpool"),True)
    #Select Newcastle
    cytoscape.network.select(nodeList='Newcastle',verbose=False)
    #Select the node we want to set the color on
    cytoscape.node.set_properties(nodeList='Selected',
                                  propertyList='Fill Color',
                                  valueList='Red',
                                  verbose=True)
    
    # And that's it !!