Associate factors to covariates of interest
get_associations.Rd
Performs Analysis of Variance (ANOVA) or linear models to associate factor scores with covariates of interest provided by the user
Usage
get_associations(
model,
metadata,
sample_id_column,
test_variable,
test_type = "categorical",
categorical_type = "parametric",
group = FALSE
)
Arguments
- model
A MOFA2 model.
- metadata
A data frame containing the annotations of the samples included in the MOFA model.
- sample_id_column
A string character that refers to the column in
metadata
where the sample identifier is located.- test_variable
A string character that refers to the column in
metadata
where the covariate to be tested is located.- test_type
A string character ("categorical", "continuous").
- categorical_type
A string character ("parametric", "not_parametric"), only applies for categorical data.
- group
Boolean flag TRUE/FALSE, to specify if a grouped MOFA model is provided.
Details
Given a covariate of interest and a defined test, this function tests for associations with factor scores. For categorical tests, ANOVAs are fitted, while for continous variables, linear models. P-values are corrected using the Benjamini-Hochberg procedure.
Examples
inputs_dir <- base::system.file("extdata", package = "MOFAcellulaR")
model <- MOFA2::load_model(file.path(inputs_dir, "testmodel.hdf5"))
#> Warning: Factor(s) 1 are strongly correlated with the total number of expressed features for at least one of your omics. Such factors appear when there are differences in the total 'levels' between your samples, *sometimes* because of poor normalisation in the preprocessing steps.
metadata <- readRDS(file.path(inputs_dir, "testmetadata.rds"))
metadata$var <- stats::rnorm(nrow(metadata))
categorical_assoc <- get_associations(model = model,
metadata = metadata,
sample_id_column = "sample",
test_variable = "patient_group",
test_type = "categorical",
group = FALSE)
continuous_assoc <- get_associations(model = model,
metadata = metadata,
sample_id_column = "sample",
test_variable = "var",
test_type = "continuous",
group = FALSE)