Skip to contents

Constructs Milo neighborhoods from a Seurat object for differential abundance analysis.

Usage

make_nhoods(
  seu,
  assay = "RNA",
  k = 30,
  d = 30,
  prop = 0.1,
  variable = NULL,
  samples = NULL,
  covariate = NULL,
  plot = TRUE
)

Arguments

seu

A Seurat object containing single-cell RNA-seq data.

assay

Character string specifying the assay to use from the Seurat object. Default is "RNA".

k

Integer specifying the number of nearest neighbors to compute in the k-NN graph. Default is 30.

d

Integer specifying the number of dimensions to use from the PCA reduction. Default is 30.

prop

Numeric value specifying the proportion of cells to include in each neighborhood. Default is 0.1.

variable

Character string specifying the column in metadata by which to measure differential abundance.

samples

Character string specifying the column in metadata representing samples or a primary covariate.

covariate

Character string specifying the column in metadata representing batch or a secondary covariate.

plot

Logical indicating whether to plot the neighborhood size histogram. Default is TRUE.

Value

A list containing:

milo

A Milo object with neighborhoods constructed.

design

A data frame representing the design matrix for differential testing.

Details

This function converts a Seurat object into a SingleCellExperiment object, constructs Milo neighborhoods, counts cells within neighborhoods, and prepares a design matrix for differential abundance testing.

Examples

# Example usage:
# result <- make_nhoods(seu, variable="condition", samples="sample_id", covariate="batch")