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_graph_from_matrix#
- meierlab.networks.graph.gen_graph_from_matrix(G, atlas, matrix_file, atlas_delim=',', matrix_delim='\t', to_fz=True)[source]#
Generate a (weighted, undirected) graph from a matrix file.
- Parameters:
- atlasstr or file path
Atlas parcellation used to generate the main graph.
- matrix_filestr or file path
A text file containing edge weight information (e.g., a correlation matrix).
- atlas_delimstr, optional
Delimiter used to read the atlas, by default “,”
- matrix_delimstr, optional
Delimiter used to read the matrix_file, by default “t”
- to_fzbool, optional
Fisher-Z transform the correlations, default True.
- Returns:
networkx.GraphA graph with additional edge weight attributes.
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) >>> edge_weights = [d[edge_attr] for (_,_,d) in g.edges(data=True)] >>> edge_weights[0:10] [1.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2]