registration_stats_anova: Spatial registration: compute ANOVA statistics

View source: R/registration_stats_anova.R

registration_stats_anovaR Documentation

Spatial registration: compute ANOVA statistics

Description

This function computes the gene ANOVA F-statistics (at least one group is different from the rest). These F-statistics can be used for spatial registration with layer_stat_cor() and related functions. Although, they are more typically used for identifying ANOVA-marker genes.

Usage

registration_stats_anova(
  sce_pseudo,
  block_cor,
  covars = NULL,
  var_registration = "registration_variable",
  var_sample_id = "registration_sample_id",
  gene_ensembl = NULL,
  gene_name = NULL,
  suffix = ""
)

Arguments

sce_pseudo

The output of registration_pseudobulk().

block_cor

A numeric(1) computed with registration_block_cor().

covars

A character() with names of sample-level covariates.

var_registration

A character(1) specifying the colData(sce_pseudo) variable of interest against which will be used for computing the relevant statistics.

var_sample_id

A character(1) specifying the colData(sce_pseudo) variable with the sample ID.

gene_ensembl

A character(1) specifying the rowData(sce_pseudo) column with the ENSEMBL gene IDs. This will be used by layer_stat_cor().

gene_name

A character(1) specifying the rowData(sce_pseudo) column with the gene names (symbols).

suffix

A character(1) specifying the suffix to use for the F-statistics column. This is particularly useful if you will run this function more than once and want to be able to merge the results.

Value

A data.frame() with the ANOVA statistical results. This is similar to fetch_data("modeling_results")$anova.

See Also

Other spatial registration and statistical modeling functions: registration_block_cor(), registration_model(), registration_pseudobulk(), registration_stats_enrichment(), registration_stats_pairwise(), registration_wrapper()

Examples

example("registration_block_cor", package = "spatialLIBD")
results_anova <- registration_stats_anova(sce_pseudo,
    block_cor, "age",
    gene_ensembl = "ensembl", gene_name = "gene_name", suffix = "example"
)
head(results_anova)

## Specifying `block_cor = NaN` then ignores the correlation structure
results_anova_nan <- registration_stats_anova(sce_pseudo,
    block_cor = NaN, "age",
    gene_ensembl = "ensembl", gene_name = "gene_name", suffix = "example"
)
head(results_anova_nan)

## Note that you can merge multiple of these data.frames if you run this
## function for different sets. For example, maybe you drop one group
## before pseudo-bulking if you know that there are many differences between
## that group and others. For example, we have dropped the white matter (WM)
## prior to computing ANOVA F-statistics.

## no covariates
results_anova_nocovar <- registration_stats_anova(sce_pseudo,
    block_cor,
    covars = NULL,
    gene_ensembl = "ensembl", gene_name = "gene_name", suffix = "nocovar"
)
head(results_anova_nocovar)

## Merge both results into a single data.frame, thanks to having different
## 'suffix' values.
results_anova_merged <- merge(results_anova, results_anova_nocovar)
head(results_anova_merged)

LieberInstitute/spatialLIBD documentation built on Dec. 19, 2024, 7:12 p.m.