This function calculates the mean expression of each feature in the Milo object stored in the assays slot. Neighbourhood expression data are stored in a new slot nhoodExpression.

calcNhoodExpression(x, assay = "logcounts", subset.row = NULL, exprs = NULL)

Arguments

x

A Milo object with nhoods slot populated, alternatively a list containing a vector of cell indices; one per neighbourhood.

assay

A character scalar that describes the assay slot to use for calculating neighbourhood expression.

subset.row

A logical, integer or character vector indicating the rows of x to use for sumamrizing over cells in neighbourhoods.

exprs

If x is a list of neighbourhoods, exprs is a matrix of genes X cells to use for calculating neighbourhood expression.

Value

A Milo object with the nhoodExpression slot populated.

Details

This function computes the mean expression of each gene, subset by subset.rows where present, across the cells contained within each neighbourhood.

Examples

require(SingleCellExperiment) m <- matrix(rnorm(100000), ncol=100) milo <- Milo(SingleCellExperiment(assays=list(logcounts=m))) milo <- buildGraph(m, k=20, d=30)
#> Constructing kNN graph with k:20
milo <- makeNhoods(milo)
#> Checking valid object
#> Warning: Rownames not set on reducedDims - setting to row indices
milo <- calcNhoodExpression(milo) dim(nhoodExpression(milo))
#> [1] 1000 7