VisualizeGraphNetwork
VisualizeGraphNetwork(in_graph, out_folder=’./visualize_network/’, verbose=False, overwrite=False, save_parameters=False, label_name=None, cohort=None, background_alpha=True, weight=‘membership’, label_centroids=True, label_subjects=False, centroids_size=500, centroid_alpha=1, centroid_node_color=‘white’, centroid_edge_color=‘black’, subject_node_size=5, subject_node_alpha=0.1, subject_node_color=‘darkgrey’, subject_edge_color=None, colormap=‘plasma’, title=‘Network Graph of the clustering membership values.’, legend_title=‘Membership values’)
Visualizing Graph Network
VisualizeGraphNetwork is a command line tool to visualize the graph network generated from the clustering results. The script uses the NetworkX library to visualize the graph network. The script also provides options to label specific nodes based on a condition (e.g. a diagnosis, etc.). It is also possible to customize the graph appearance using the Network Visualization Options. The script is made to work hand in hand with the script ComputeGraphNetwork since it requires the precomputation of the nodes’ position within the graph file.
Labelling Graph Network Nodes
It is possible to label specific nodes based on a condition (e.g. a diagnosis, etc.). To do so, use the –label-name to indicate with binary node attribute to use for labelling. It is also possible to provide multiple label name by using –label-name x –label-name y. The script will output multiple graphs for each label name.
Cohort Selection
In some case, the graph network file can contain data from multiple cohort at the same time. It might be useful to single out a specific cohort to visualize some data. Using –cohort, the script will fetch data from the specified cohort and filter the –label-name. In order for the script to run successfully, your graph network needs to contain the cohort attributes. If it does not, please add it using the AddNodesAttributes script.
Graph Network Customization
To customize the graph appearance, please see the Network Visualization Options below. It should be noted that using subjects_labelling will crowd the network if it contains a high number of nodes. Also, centroids are labelled by default ‘c1, c2, …’ and subjects ‘s1, s2, …’. The script also exports a graph_network_file.gexf. This file can be used to further customize the network using other APIs such as GEPHI (see [1]).
References
[1] GEPHI (https://gephi.org/)
Example Usage
Parameters
in_graph : Input graph network to visualize (.gml format).
out_folder : Output folder for the graph network visualization.
verbose : Verbose mode.
overwrite : Overwrite existing files.
save_parameters : Save parameters to a .txt file.
label_name : List of label names to subsequently use for labelling.
cohort: int, optional : Cohort identifier. If your graph contains data from multiple cohort, you can specify the cohort you want for visulization.
background_alpha : Use background alpha for the graph.
weight : Weight to use for the graph network.
label_centroids : Label centroids.
label_subjects : Label subjects.
centroids_size : Size of the centroids.
centroid_alpha : Alpha of the centroids.
centroid_node_color : Color of the centroids.
centroid_edge_color : Edge color of the centroids.
subject_node_size : Size of the subjects.
subject_node_alpha : Alpha of the subjects.
subject_node_color : Color of the subjects.
subject_edge_color : Edge color of the subjects.
colormap : Colormap to use for the graph network.
title : Title of the graph network.
legend_title : Legend title of the graph network.