Skip to contents

Checks data object structure and consistency, adjusting components if needed.

Usage

mStat_validate_data(data.obj)

Arguments

data.obj

A MicrobiomeStat data object, which is a list containing at minimum the following components:

  • feature.tab: A matrix of feature abundances (taxa/genes as rows, samples as columns)

  • meta.dat: A data frame of sample metadata (samples as rows)

Optional components include:

  • feature.ann: A matrix/data frame of feature annotations (e.g., taxonomy)

  • tree: A phylogenetic tree object (class "phylo")

  • feature.agg.list: Pre-aggregated feature tables by taxonomy

Data objects can be created using converters like mStat_convert_phyloseq_to_data_obj or importers like mStat_import_qiime2_as_data_obj.

Value

The validated (and possibly adjusted) data object.

Details

The function checks if 'meta.dat' is a data frame and converts it to one if it isn't. The function then checks two rules: whether the row names of 'feature.tab' match the row names of 'feature.ann', and whether the column names of 'feature.tab' match the row names of 'meta.dat'. If either of these checks fail, the function adjusts the relevant parts of the data object to meet these rules.

Examples

if (FALSE) { # \dontrun{
# Assume 'data.obj' is your data object
data(peerj32.obj)
mStat_validate_data(peerj32.obj)
mStat_validate_data(mStat_normalize_data(peerj32.obj, "TSS")$data.obj.norm)
} # }