buildGraph | R Documentation |
This function is borrowed from the old buildKNNGraph function in scran. Instead of returning an igraph object it populates the graph and distance slots in a Milo object. If the input is a SingleCellExperiment object or a matrix then it will return a de novo Milo object with the same slots filled.
buildGraph(
x,
k = 10,
d = 50,
transposed = FALSE,
get.distance = FALSE,
reduced.dim = "PCA",
BNPARAM = KmknnParam(),
BSPARAM = bsparam(),
BPPARAM = SerialParam()
)
x |
A matrix, |
k |
An integer scalar that specifies the number of nearest-neighbours to consider for the graph building. |
d |
The number of dimensions to use if the input is a matrix of cells X reduced dimensions. If this is provided, transposed should also be set=TRUE. |
transposed |
Logical if the input x is transposed with rows as cells. |
get.distance |
A logical scalar whether to compute distances during graph construction. |
reduced.dim |
A character scalar that refers to a specific entry in
the |
BNPARAM |
refer to |
BSPARAM |
refer to |
BPPARAM |
refer to |
This function computes a k-nearest neighbour graph. Each graph vertex is a
single-cell connected by the edges between its neighbours. Whilst a
kNN-graph is strictly directed, we remove directionality by forcing all
edge weights to 1; this behaviour can be overriden by providing
directed=TRUE
.
If you wish to use an
alternative graph structure, such as a shared-NN graph I recommend you
construct this separately and add to the relevant slot in the
Milo
object.
A Milo
object with the graph and distance slots populated.
Mike Morgan, with KNN code written by Aaron Lun & Jonathan Griffiths.
library(SingleCellExperiment)
ux <- matrix(rpois(12000, 5), ncol=200)
vx <- log2(ux + 1)
pca <- prcomp(t(vx))
sce <- SingleCellExperiment(assays=list(counts=ux, logcounts=vx),
reducedDims=SimpleList(PCA=pca$x))
milo <- Milo(sce)
milo <- buildGraph(milo, d=30, transposed=TRUE)
milo
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.