phy_substitute_metadata: Substitute a phyloseq metadata with a new data.frame

View source: R/phy_substitute_metadata.R

phy_substitute_metadataR Documentation

Substitute a phyloseq metadata with a new data.frame

Description

Substitute metadata in phyloseq objects. the two data frames must have row names matching sample names. The sample order doesn't matter, because the functions will reorder the new metatadata rows, to match the sample order in the phyloseq object.

Usage

phy_substitute_metadata(physeq, new_metadata)

Arguments

physeq

A phyloseq object contaning or not containing 'sample_data'

new_metadata

a data.frame object, with rownames containing 'sample_names' of the 'physeq' object

Value

a phyloseq object with the new metadata stored under the "sam_data" slot

Examples

data("GlobalPatterns")
exMeta <- microbiome::meta(GlobalPatterns)
newMeta <- exMeta %>% mutate(newVar = runif(n = nrow(exMeta), min =  0, max = 20))

GlobalPatterns <- phy_substitute_metadata(physeq = GlobalPatterns, new_metadata = newMeta)


g-antonello/gautils2 documentation built on Nov. 28, 2022, 9:39 a.m.