Extract factor scores from a model in a tidy format with meta data
get_tidy_factors.Rd
Generates a tidy dataframe for factors of interest useful for plotting functions.
Arguments
- model
A MOFA2 model.
- metadata
A data frame containing the annotations of the samples included in the MOFA model.
- factor
A string character to define the factor to be extracted. Alternatively, "all" to get all factors.
- group
Boolean flag TRUE/FALSE, to specify if a grouped MOFA model is provided.
- sample_id_column
A string character that refers to the column in
metadata
where the sample identifier is located.
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"))
all_factors <- get_tidy_factors(model = model,
metadata = metadata,
factor = "all",
sample_id_column = "sample")
Factor3 <- get_tidy_factors(model = model,
metadata = metadata,
factor = "Factor3",
sample_id_column = "sample")