scirpy.util.graph.igraph_from_sparse_matrix
- scirpy.util.graph.igraph_from_sparse_matrix(matrix, *, matrix_type='distance', max_value=None, simplify=True)
Get an igraph object from an adjacency or distance matrix.
- Parameters
- matrix :
spmatrix
A sparse matrix that represents the connectivity or distance matrix for the graph. Zero-entries mean “no edge between the two nodes”.
- matrix_type : {‘connectivity’, ‘distance’}
Literal
[‘connectivity’, ‘distance’] (default:'distance'
) Whether the
sparse_matrix
represents connectivities (higher value = smaller distance) or distances (higher value = higher distance). Distance matrices will be converted into connectivities. A connectivity matrix is also known as weighted adjacency matrix.- max_value :
float
|None
Optional
[float
] (default:None
) When converting distances to connectivities, this will be considered the maximum distance. This defaults to
numpy.max(sparse_matrix)
.- simplify :
bool
(default:True
) Make an undirected graph and remove circular edges (i.e. edges from a node to itself).
- matrix :
- Return type
Graph
- Returns
igraph object