groupNhoods: Group neighbourhoods

View source: R/groupNhoods.R

groupNhoodsR Documentation

Group neighbourhoods

Description

This function groups overlapping and concordantly DA neighbourhoods, using the louvain community detection algorithm.

Usage

groupNhoods(
  x,
  da.res,
  da.fdr = 0.1,
  overlap = 1,
  max.lfc.delta = NULL,
  merge.discord = FALSE,
  subset.nhoods = NULL,
  compute.new = FALSE,
  na.function = "na.pass"
)

Arguments

x

A Milo object containing single-cell gene expression and neighbourhoods.

da.res

A data.frame containing DA results, as expected from running testNhoods.

da.fdr

A numeric scalar that determines at what FDR neighbourhoods are declared DA for the purposes of aggregating across concorantly DA neighbourhoods.

overlap

A scalar integer that determines the number of cells that must overlap between adjacent neighbourhoods for merging.

max.lfc.delta

A scalar that determines the absolute difference in log fold change below which neighbourhoods should not be considered adjacent. Default=NULL

merge.discord

A logical scalar that overrides the default behaviour and allows adjacent neighbourhoods to be merged if they have discordant log fold change signs. Using this argument is generally discouraged, but may be useful for constructing an empirical null group of cells, regardless of DA sign.

subset.nhoods

A logical, integer or character vector indicating which neighbourhoods to subset before grouping. All other neighbourhoods will be assigned NA

compute.new

A logical scalar indicating whether to force computing a new neighbourhood adjacency matrix if already present.

na.function

A valid NA action function to apply, should be one of na.fail, na.omit, na.exclude, na.pass (default='na.pass').

Details

Louvain clustering is applied to the neighbourhood graph. This graph is first modified based on two criteria: 1) neighbourhoods share at least overlap number of cells, and 2) the DA log fold change sign is concordant. This behaviour can be modulated by setting overlap to be more or less stringent. Additionally, a threshold on the log fold-changes can be set, such that max.lfc.delta is required to retain edges between adjacent neighbourhoods. Note: adjacent neighbourhoods will never be merged with opposite signs.

Value

A data.frame of model results (as da.res input) with a new column storing the assigned group label for each neighbourhood (NhoodGroup column)

Author(s)

Emma Dann & Mike Morgan


MikeDMorgan/miloR documentation built on Feb. 29, 2024, 6:20 p.m.