Interactive Graph

This is an interactive graph of a Walktrap community detection algorithm. Note that due to computational limitations, only a subset of the network is displayed. Different colours correspond to different communities within the network, with our identified telomerase community in dark maroon. Annotations for each protein can be revealed by hovering over each node.

Code snippet to generate graph using pyvis
import pyvis.network as Network
import pandas as pd
import networkx as nx

G_subset = G.subgraph(subset)

for node in G_subset.nodes:
    position = [(i, communities.index(node)) for i, communities in enumerate (walktrapG) if node in communities]
    G_subset.nodes[node]["Community"] = position[0][0]

nt = Network(notebook=True, cdn_resources='in_line')
nt.from_nx(G_subset)

colours = pd.read_csv("hexcolours.csv", header=None)

community_colour = {}
i = 0

for node in nt.nodes:
    if node['Community'] not in community_colour:
        community_colour[node['Community']] = '#' + colours.loc[i, 0]
        i += 1
        node['color'] = community_colour[node['Community']]
    else:
        node['color'] = community_colour[node['Community']]

for node in nt.nodes:
    node["title"] = links[links["#string_protein_id"] == node["label"]]["preferred_name"].iloc[0] + " " + links[links["#string_protein_id"] == node["label"]]["annotation"].iloc[0]
    node['label'] = str(links[links["#string_protein_id"] == node['id']]["preferred_name"].iloc[0])

nt.save_graph("interactive.html") #download file on sidebar and open in browser
Back to top