Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

meierlab.networks.graph.gen_subnetwork_subgraphs#

meierlab.networks.graph.gen_subnetwork_subgraphs(G, subnetwork_list, subnetwork_label='RSN')[source]#

Generate ‘subgraphs’ according to the given ‘subnetworks’.

These subgraphs can be used to explore individual networks (e.g., resting-state networks) within a system.

Parameters:
Gnetworkx.Graph

A graph containing nodes with a subnetwork_label attribute.

subnetwork_listlist

A list of subnetworks that nodes in G belong to.

subnetwork_labelstr, optional

Node label attribute to search, by default “RSN”.

Returns:
list

A list of subgraphs: networkx.Graph with each subgraph corresponding to nodes in each network of subnetwork_list.

Examples

>>> from meierlab.networks import graph
>>> atlas = 'schaefer2018/atlas.csv'
>>> sub_file = 'sub-001.tsv'
>>> G = graph.gen_base_graph_from_atlas(atlas)
>>> g = graph.gen_graph_from_matrix(G,atlas,sub_file)
>>> rsn_list = graph.gen_subnetwork_list(g)
>>> subgraphs = graph.gen_subnetwork_subgraphs(g, rsn_list)
>>> subgraphs[0].nodes()
NodeView(('LH_Default_Temp_1', 'LH_Default_Temp_2',
'LH_Default_Temp_3', 'LH_Default_Temp_4',
'LH_Default_Temp_5', 'LH_Default_Temp_6',
'LH_Default_Temp_7', 'LH_Default_Temp_8',
'LH_Default_Temp_9', 'LH_Default_Temp_10',
'RH_Default_Temp_1', 'RH_Default_Temp_2',
'RH_Default_Temp_3', 'RH_Default_Temp_4',
'RH_Default_Temp_5', 'RH_Default_Temp_6',
'RH_Default_Temp_7', 'RH_Default_Temp_8'))