calcNhoodDistance {miloR} | R Documentation

## Calculate within neighbourhood distances

### Description

This function will calculate Euclidean distances between single-cells in a neighbourhood using the same dimensionality as was used to construct the graph. This step follows the `makeNhoods` call to limit the number of distance calculations required.

### Usage

    calcNhoodDistance(x, d, reduced.dim = NULL, use.assay = "logcounts")

### Arguments

`x` | A `Milo` object with a valid `graph` slot. If `reduced.dims` is not provided and there is no valid populated `reducedDim` slot in `x`, then this is computed first with `d + 1` principal components.
`d` | The number of dimensions to use for computing within-neighbourhood distances. This should be the same value used construct the `graph`.
`reduced.dim` | If x is an `Milo` object, a character indicating the name of the `reducedDim` slot in the `Milo` object to use as (default: 'PCA'). Otherwise this should be an N X P matrix with rows in the same order as the columns of the input Milo object `x`.
`use.assay` | A character scalar defining which `assay` slot in the `Milo` to use

### Value

A `Milo` object with the distance slots populated.

### Author(s)

Mike Morgan, Emma Dann

### Examples

    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 <- makeNhoods(milo)
    milo <- calcNhoodDistance(milo, d=30)

    milo

[Package miloR version 1.2.0 Index]