# neurostatx.cli.VisualizeGraphNetwork

*module*

[View source](https://github.com/gagnonanthony/NeuroStatX/blob/main/neurostatx/cli/VisualizeGraphNetwork.py#L1-L1)

## neurostatx.cli.VisualizeGraphNetwork.app

*attribute* · *module attribute*

```python
app = App(default_parameter=Parameter(negative=()))
```

Cyclopts application for the VisualizeGraphNetwork command-line tool.

[View source](https://github.com/gagnonanthony/NeuroStatX/blob/main/neurostatx/cli/VisualizeGraphNetwork.py#L18-L18)

## neurostatx.cli.VisualizeGraphNetwork.VisualizeGraphNetwork

*function*

```python
def VisualizeGraphNetwork(in_graph: Annotated[str, Parameter(show_default=False, group='Essential Files Options')], out_folder: Annotated[str, Parameter(show_default=True, group='Essential Files Options')] = './visualize_network/', verbose: Annotated[bool, Parameter(-v, --verbose, group='Optional parameters')] = False, overwrite: Annotated[bool, Parameter(-f, --overwrite, group='Optional parameters')] = False, save_parameters: Annotated[bool, Parameter(-s, --save_parameters, group='Optional parameters')] = False, label_name: Annotated[List[str], Parameter(show_default=False, group='Label Options')] = None, cohort: Annotated[int, Parameter(show_default=False, group='Essential Files Options')] = None, background_alpha: Annotated[bool, Parameter(show_default=True, group='Label Options')] = True, weight: Annotated[str, Parameter(show_default=False, group='Network Visualization Options')] = 'membership', label_centroids: Annotated[bool, Parameter(show_default=True, group='Network Visualization Options')] = True, label_subjects: Annotated[bool, Parameter(show_default=True, group='Network Visualization Options')] = False, centroids_size: Annotated[int, Parameter(show_default=True, group='Network Visualization Options')] = 500, centroid_alpha: Annotated[float, Parameter(show_default=True, group='Network Visualization Options')] = 1, centroid_node_color: Annotated[str, Parameter(show_default=True, group='Network Visualization Options')] = 'white', centroid_edge_color: Annotated[str, Parameter(show_default=True, group='Network Visualization Options')] = 'black', subject_node_size: Annotated[int, Parameter(show_default=True, group='Network Visualization Options')] = 5, subject_node_alpha: Annotated[float, Parameter(show_default=True, group='Network Visualization Options')] = 0.1, subject_node_color: Annotated[str, Parameter(show_default=True, group='Network Visualization Options')] = 'darkgrey', subject_edge_color: Annotated[str, Parameter(show_default=True, group='Network Visualization Options')] = None, colormap: Annotated[str, Parameter(show_default=True, group='Network Visualization Options')] = 'plasma', title: Annotated[str, Parameter(show_default=False, group='Network Visualization Options')] = 'Network Graph of the clustering membership values.', legend_title: Annotated[str, Parameter(show_default=False, group='Network Visualization Options')] = 'Membership values')
```

Visualize a graph network generated from clustering results.

VisualizeGraphNetwork uses NetworkX to draw the graph and can label
specific nodes based on a condition (for example a diagnosis). Appearance
can be customized with the visualization parameters. It is meant to work
with
[ComputeGraphNetwork][neurostatx.cli.ComputeGraphNetwork.ComputeGraphNetwork]
because it requires precomputed node positions in the graph file.

> **Notes**
>
> **Labelling nodes**
> 
> Specific nodes can be labelled from a binary node attribute via
> --label-name. Multiple labels can be provided with repeated --label-name
> flags; the script writes one graph per label name.
> 
> **Cohort selection**
> 
> When the graph contains data from multiple cohorts, --cohort fetches the
> specified cohort and filters --label-name. The graph must contain a cohort
> attribute; add it with
> [AddNodesAttributes][neurostatx.cli.AddNodesAttributes.AddNodesAttributes]
> if needed.
> 
> **Graph appearance**
> 
> Using subjects labelling will crowd the network if it contains a high
> number of nodes. Centroids are labelled by default ``c1, c2, ...`` and
> subjects ``s1, s2, ...``. The script also exports a
> ``graph_network_file.gexf`` file that can be customized further in other
> tools such as Gephi [1].

> **References**
>
> [1] [Gephi](https://gephi.org/)

**Parameters**

- `in_graph` (`str`) — Input graph network to visualize (.gml format).
- `out_folder` (`str`) (default: `'./visualize_network/'`) — Output folder for the graph network visualization. Defaults to ``./visualize_network/``.
- `verbose` (`bool`) (default: `False`) — Verbose mode. Defaults to False.
- `overwrite` (`bool`) (default: `False`) — Overwrite existing files. Defaults to False.
- `save_parameters` (`bool`) (default: `False`) — Save parameters to a .txt file. Defaults to False.
- `label_name` (`List[str]`) (default: `None`) — List of label names to subsequently use for labelling. Defaults to None.
- `cohort` (`int`) (default: `None`) — Cohort identifier. If your graph contains data from multiple cohorts, you can specify the cohort you want for visualization. Defaults to None.
- `background_alpha` (`bool`) (default: `True`) — Use background alpha for the graph. Defaults to True.
- `weight` (`str`) (default: `'membership'`) — Weight to use for the graph network. Defaults to ``membership``.
- `label_centroids` (`bool`) (default: `True`) — Label centroids. Defaults to True.
- `label_subjects` (`bool`) (default: `False`) — Label subjects. Defaults to False.
- `centroids_size` (`int`) (default: `500`) — Size of the centroids. Defaults to 500.
- `centroid_alpha` (`float`) (default: `1`) — Alpha of the centroids. Defaults to 1.
- `centroid_node_color` (`str`) (default: `'white'`) — Color of the centroids. Defaults to ``white``.
- `centroid_edge_color` (`str`) (default: `'black'`) — Edge color of the centroids. Defaults to ``black``.
- `subject_node_size` (`int`) (default: `5`) — Size of the subjects. Defaults to 5.
- `subject_node_alpha` (`float`) (default: `0.1`) — Alpha of the subjects. Defaults to 0.1.
- `subject_node_color` (`str`) (default: `'darkgrey'`) — Color of the subjects. Defaults to ``darkgrey``.
- `subject_edge_color` (`str`) (default: `None`) — Edge color of the subjects. Defaults to None.
- `colormap` (`str`) (default: `'plasma'`) — Colormap to use for the graph network. Defaults to ``plasma``.
- `title` (`str`) (default: `'Network Graph of the clustering membership values.'`) — Title of the graph network. Defaults to ``Network Graph of the clustering membership values.``.
- `legend_title` (`str`) (default: `'Membership values'`) — Legend title of the graph network. Defaults to ``Membership values``.

**Examples**

```bash
VisualizeGraphNetwork --in-graph graph_network.gml
--out-folder output/ --label-name diagnosis
--weight membership -v -f -s
```

[View source](https://github.com/gagnonanthony/NeuroStatX/blob/main/neurostatx/cli/VisualizeGraphNetwork.py#L22-L373)
