add_info_to_sam_data: Add information to sample_data slot of a phyloseq-class...

View source: R/dada_phyloseq.R

add_info_to_sam_dataR Documentation

Add information to sample_data slot of a phyloseq-class object

Description

lifecycle-experimental

Warning: The value nb_seq and nb_otu may be outdated if you transform your phyloseq object, e.g. using the subset_taxa_pq() function

Usage

add_info_to_sam_data(
  physeq,
  df_info = NULL,
  add_nb_seq = TRUE,
  add_nb_otu = TRUE
)

Arguments

physeq

(required): a phyloseq-class object obtained using the phyloseq package.

df_info

: A dataframe with rownames matching for sample names of the phyloseq object

add_nb_seq

(Logical, default TRUE) Does we add a column nb_seq collecting the number of sequences per sample?

add_nb_otu

(Logical, default TRUE) Does we add a column nb_otu collecting the number of OTUs per sample?

Value

A phyloseq object with an updated sam_data slot

Author(s)

Adrien Taudière

Examples


data_fungi <- add_info_to_sam_data(data_fungi)
boxplot(data_fungi@sam_data$nb_otu ~ data_fungi@sam_data$Time)

new_df <- data.frame(
  variable_1 = runif(n = nsamples(data_fungi), min = 1, max = 20),
  variable_2 = runif(n = nsamples(data_fungi), min = 1, max = 2)
)
rownames(new_df) <- sample_names(data_fungi)
data_fungi <- add_info_to_sam_data(data_fungi, new_df)
plot(data_fungi@sam_data$nb_otu ~ data_fungi@sam_data$variable_1)

adrientaudiere/MiscMetabar documentation built on Oct. 13, 2024, 9:42 p.m.