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 (
Literal
['connectivity'
,'distance'
] (default:'distance'
)) – Whether thesparse_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 (
Optional
[float
] (default:None
)) – When converting distances to connectivities, this will be considered the maximum distance. This defaults tonumpy.max(sparse_matrix)
.simplify (
bool
(default:True
)) – Make an undirected graph and remove circular edges (i.e. edges from a node to itself).
- Return type:
Graph
- Returns:
igraph object