buildSNNGraph | R Documentation |
SingleCellExperiment-friendly wrapper around the makeSNNGraph
and makeKNNGraph
functions for creating nearest-neighbor graphs.
buildSNNGraph(x, ...)
## S4 method for signature 'ANY'
buildSNNGraph(
x,
...,
d = 50,
transposed = FALSE,
subset.row = NULL,
BSPARAM = bsparam(),
BPPARAM = SerialParam()
)
## S4 method for signature 'SummarizedExperiment'
buildSNNGraph(x, ..., assay.type = "logcounts")
## S4 method for signature 'SingleCellExperiment'
buildSNNGraph(x, ..., use.dimred = NULL)
buildKNNGraph(x, ...)
## S4 method for signature 'ANY'
buildKNNGraph(
x,
...,
d = 50,
transposed = FALSE,
subset.row = NULL,
BSPARAM = bsparam(),
BPPARAM = SerialParam()
)
## S4 method for signature 'SingleCellExperiment'
buildKNNGraph(x, ..., use.dimred = NULL)
## S4 method for signature 'SingleCellExperiment'
buildKNNGraph(x, ..., use.dimred = NULL)
x |
A matrix-like object containing expression values for each gene (row) in each cell (column).
These dimensions can be transposed if Alternatively, a SummarizedExperiment or SingleCellExperiment containing such an expression matrix.
If |
... |
For the generics, additional arguments to pass to the specific methods. For the ANY methods, additional arguments to pass to For the SummarizedExperiment methods, additional arguments to pass to the corresponding ANY method. For the SingleCellExperiment methods, additional arguments to pass to the corresponding SummarizedExperiment method. |
d |
An integer scalar specifying the number of dimensions to use for a PCA on the expression matrix prior to the nearest neighbor search.
Ignored for the ANY method if |
transposed |
A logical scalar indicating whether |
subset.row |
See |
BSPARAM |
A BiocSingularParam object specifying the algorithm to use for PCA, if |
BPPARAM |
A BiocParallelParam object to use for parallel processing. |
assay.type |
A string specifying which assay values to use. |
use.dimred |
A string specifying whether existing values in |
A graph where nodes are cells and edges represent connections between nearest neighbors,
see ?makeSNNGraph
for more details.
Aaron Lun
makeSNNGraph
and makeKNNGraph
, for the underlying functions that do the work.
See cluster_walktrap
and related functions in igraph for clustering based on the produced graph.
clusterCells
, for a more succinct way of performing graph-based clustering.
library(scuttle)
sce <- mockSCE(ncells=500)
sce <- logNormCounts(sce)
g <- buildSNNGraph(sce)
clusters <- igraph::cluster_fast_greedy(g)$membership
table(clusters)
# Any clustering method from igraph can be used:
clusters <- igraph::cluster_walktrap(g)$membership
table(clusters)
# Smaller 'k' usually yields finer clusters:
g <- buildSNNGraph(sce, k=5)
clusters <- igraph::cluster_walktrap(g)$membership
table(clusters)
# Graph can be built off existing reducedDims results:
sce <- scater::runPCA(sce)
g <- buildSNNGraph(sce, use.dimred="PCA")
clusters <- igraph::cluster_fast_greedy(g)$membership
table(clusters)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.