annotateNhoods: Add annotations from colData to DA testing results

View source: R/annotateNhoods.R

annotateNhoodsR Documentation

Add annotations from colData to DA testing results

Description

This function assigns a categorical label to neighbourhoods in the differential abundance results data.frame (output of testNhoods), based on the most frequent label among cells in each neighbourhood. This can be useful to stratify DA testing results by cell types or samples. Also the fraction of cells carrying that label is stored.

Usage

annotateNhoods(x, da.res, coldata_col)

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.

coldata_col

A character scalar determining which column of colData(x) stores the annotation to be added to the neighbourhoods

Details

For each neighbourhood, this calculates the most frequent value of colData(x)[coldata_col] among cells in the neighbourhood and assigns that value as annotation for the neighbourhood, adding a column in the da.res data.frame. In addition, a coldata_col_fraction column will be added, storing the fraction of cells carrying the assigned label. While in practice neighbourhoods are often homogeneous, one might choose to remove an annotation label when the fraction of cells with the label is too low (e.g. below 0.6).

Value

A data.frame of model results (as da.res input) with two new columns: (1) coldata_col storing the assigned label for each neighbourhood; (2) coldata_col_fraction storing the fraction of cells in the neighbourhood with the assigned label.

Author(s)

Emma Dann

Examples


NULL


MikeDMorgan/miloR documentation built on Aug. 7, 2022, 8:21 a.m.