Skip to contents

This function removes specific features from a data object in the MicrobiomeStat package. It can handle different feature levels and adjust accordingly. If 'original' is specified as the feature level, the function will remove features based on the original row names of 'feature.tab' and 'feature.ann'. In all other cases, the function will filter based on the specified feature level.

Usage

mStat_remove_feature(data.obj, featureIDs, feature.level = NULL)

Arguments

data.obj

A list object in a format specific to MicrobiomeStat, which can include components such as feature.tab (matrix), feature.ann (matrix), meta.dat (data.frame), tree, and feature.agg.list (list). The data.obj can be converted from other formats using several functions from the MicrobiomeStat package, including: 'mStat_convert_DGEList_to_data_obj', 'mStat_convert_DESeqDataSet_to_data_obj', 'mStat_convert_phyloseq_to_data_obj', 'mStat_convert_SummarizedExperiment_to_data_obj', 'mStat_import_qiime2_as_data_obj', 'mStat_import_mothur_as_data_obj', 'mStat_import_dada2_as_data_obj', and 'mStat_import_biom_as_data_obj'. Alternatively, users can construct their own data.obj. Note that not all components of data.obj may be required for all functions in the MicrobiomeStat package.

featureIDs

A character vector of feature IDs to be removed. The function will issue a warning if numeric IDs are provided.

feature.level

An optional character string that specifies the feature level to remove features from. This can be 'original' for removing based on the original row names or any other feature level that corresponds to a column in 'feature.ann'. If no level is specified and multiple levels contain the provided feature IDs, the function will stop and ask for a specific level.

Value

A list that is the modified version of the input data object. It includes the subsetted metadata, feature table, feature names, full feature name list, and abundance list, with the specified features removed. If 'original' was specified as the feature level, the returned object will also have adjusted 'feature.tab' and 'feature.ann'.

Details

The function first checks if the specified feature level is 'original'. If so, it removes the specified features from the 'feature.tab' and 'feature.ann' based on the original row names. If the feature level is specified and is not 'original', it removes the specified features based on this level. After removal, it recalculates 'feature.agg.list' if it exists in the data object.

See also

Author

Jun Chen, Chen Yang

Examples

if (FALSE) { # \dontrun{
# Load the necessary libraries

data(peerj32.obj)

# Use the remove_feature function
# Here we take the first 3 features as an example
featureIDs <- rownames(peerj32.obj$feature.tab)[1:3]
peerj32.obj <- mStat_remove_feature(peerj32.obj, featureIDs, feature.level = "original")
} # }