as.Graph {SeuratObject} | R Documentation |
Coerce to a Graph
Object
Description
Convert a matrix
(or Matrix
) to
a Graph
object
Usage
as.Graph(x, ...)
## S3 method for class 'Matrix'
as.Graph(x, ...)
## S3 method for class 'matrix'
as.Graph(x, ...)
## S3 method for class 'Neighbor'
as.Graph(x, weighted = TRUE, ...)
Arguments
x |
The matrix to convert |
... |
Ignored |
weighted |
If TRUE, fill entries in Graph matrix with value from the nn.dist slot of the Neighbor object |
Value
A Graph
object
See Also
Other graph:
Graph-class
Examples
# converting sparse matrix
mat <- Matrix::rsparsematrix(nrow = 10, ncol = 10, density = 0.1)
rownames(x = mat) <- paste0("feature_", 1:10)
colnames(x = mat) <- paste0("cell_", 1:10)
g <- as.Graph(x = mat)
# converting dense matrix
mat <- matrix(data = 1:16, nrow = 4)
rownames(x = mat) <- paste0("feature_", 1:4)
colnames(x = mat) <- paste0("cell_", 1:4)
g <- as.Graph(x = mat)
[Package SeuratObject version 5.0.2 Index]