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, subset.nhoods = NULL)

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

subset.nhoods

A character, numeric or logical vector that will subset the annotation to the specific nhoods. If a character vector these should correspond to row names of nhoodCounts. If a logical vector then these should have the same length as nrow of nhoodCounts. If numeric, then these are assumed to correspond to indices of nhoodCounts - if the maximal index is greater than nrow(nhoodCounts(x)) an error will be produced. This is necessary if testNhoods was run using subset.nhoods=....

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 Oct. 19, 2024, 8:39 p.m.