tsg_ind: Transform data from wide to long, without aggregating...

Description Usage Arguments Value See Also Examples

View source: R/tsg_ind.R

Description

Transform data from wide to long, without aggregating individual samples.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
tsg_ind(
  df,
  n = 50,
  ar_mean = FALSE,
  geo_mean = FALSE,
  otu_ord = NULL,
  tax_df = otu_good_taxonomy,
  tax_level = NULL,
  sample_col = "Sample_name"
)

Arguments

df

Dataframe containing metadata and taxon (Phylum, Otu, etc) abundance data in wide format.

n

Number of OTUs to return, 50 by default.

ar_mean

Boolean to indicate whether the arithmetic mean should be appended to the data.

geo_mean

Boolean to indicate whether the geometric mean should be appended to the data.

otu_ord

Character or factor vector of unique OTU identifiers. These are often ordered OTUs resulting from taxon_sort_gather and are used to ensure consistency in OTU ordering and factor levels across dataframes.

tax_df

Taxonomy table. Passed to join_tax. Defaults to otu_good_taxonomy.

tax_level

Taxonomic level(s) to join from tax_df. Defaults to NULL, in which case no join occurs.

sample_col

Single element character vector specifying the column in df which contains Sample names. Defaults to Sample_name.

Value

An unaggregated dataframe that has been reshaped into long form.

See Also

taxon_sort_gather

Examples

1
2
3
4
5
6
mock_gg <- dplyr::filter(otu_df, Experiment == "Zymo_Mock") %>%
    tsg_ind(n = 20, ar_mean = T, geo_mean = T)

filt_df_ind <- dplyr::filter(otu_df, Experiment %in% c("A", "B"),
    Treatment_group == "TG1", Organ == "Feces", Day == 11) %>%
    tsg_ind(otu_ord = levels(filt_df$OTU))

cb-42/cbmbtools documentation built on Jan. 9, 2021, 1:38 a.m.