# neurostatx.cli.CompareGraphs

*module*

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

## neurostatx.cli.CompareGraphs.app

*attribute* · *module attribute*

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

Cyclopts application for the CompareGraphs command-line tool.

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

## neurostatx.cli.CompareGraphs.CompareGraphs

*function*

```python
def CompareGraphs(in_graph1: Annotated[str, Parameter(show_default=False, group='Essential Files Options')], weight: Annotated[str, Parameter(show_default=False, group='Essential Files Options')], percentile: Annotated[float, Parameter(show_default=False, group='Essential Files Options')], in_graph2: Annotated[str, Parameter(show_default=False, group='Essential Files Options')], out_folder: Annotated[str, Parameter(group='Essential Files Options')] = './comparison_results/', verbose: Annotated[bool, Parameter(-v, --verbose, group='Optional parameters')] = False, overwrite: Annotated[bool, Parameter(-f, --overwrite, group='Optional parameters')] = False, 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, background_alpha: Annotated[bool, Parameter(show_default=True, group='Network Visualization Options')] = True, 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')] = 'gray', legend_title: Annotated[str, Parameter(show_default=False, group='Network Visualization Options')] = 'Membership values')
```

Extract high-percentile nodes from one graph and color them on another.

CompareGraphs compares two undirected weighted graph networks by extracting
the Xth-percentile nodes from --in-graph1 and labelling those nodes on
--in-graph2. The percentile is set by --percentile.

> **Notes**
>
> **Graph appearance**
> 
> Graph appearance can be customized with the visualization parameters
> below. 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, ...``.

**Parameters**

- `in_graph1` (`str`) — First graph from which subjects above --percentile will be extracted and colored.
- `weight` (`str`) — Edge weight to use for the graph.
- `percentile` (`float`) — Percentile value used to extract subjects.
- `in_graph2` (`str`) — Second graph to color extracted subjects on.
- `out_folder` (`str`) (default: `'./comparison_results/'`) — Path of the folder in which the results will be written. If not specified, current folder and default name will be used. Defaults to ``./comparison_results/``.
- `verbose` (`bool`) (default: `False`) — If true, produce verbose output. Defaults to False.
- `overwrite` (`bool`) (default: `False`) — If true, force overwriting of existing output files. Defaults to False.
- `label_centroids` (`bool`) (default: `True`) — If true, centroids will be labelled. Defaults to True.
- `label_subjects` (`bool`) (default: `False`) — If true, will label subjects nodes. Defaults to False.
- `centroids_size` (`int`) (default: `500`) — Size of the centroids nodes. Defaults to 500.
- `centroid_alpha` (`float`) (default: `1`) — Alpha value representing the transparency of the centroids nodes. Defaults to 1.
- `centroid_node_color` (`str`) (default: `'white'`) — Centroids nodes color to use. Defaults to ``white``.
- `centroid_edge_color` (`str`) (default: `'black'`) — Assign a color to the edge of the centroids nodes. Defaults to ``black``.
- `subject_node_size` (`int`) (default: `5`) — Assign the size of the subjects nodes. Defaults to 5.
- `background_alpha` (`bool`) (default: `True`) — If true, will plot the background nodes with alpha = 0.2. Defaults to True.
- `subject_edge_color` (`str`) (default: `None`) — Assign a color to the edge of the subjects nodes. Defaults to None.
- `colormap` (`str`) (default: `'gray'`) — Colormap to use when coloring the edges of the network based on the membership values of each cluster. Available colormaps are those from Matplotlib (https://matplotlib.org/stable/tutorials/colors/colormaps.html). Defaults to ``gray``.
- `legend_title` (`str`) (default: `'Membership values'`) — Legend title (colormap). Defaults to ``Membership values``.

**Examples**

```bash
CompareGraphs --in-graph1 graph1.gml --in-matrix membership_mat.npy
--percentile 80 --in-graph2 graph2.gml
```

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