prepare_data: Prepare themetadata object from data for topic modeling...

Description Usage Arguments Value See Also Examples

View source: R/prepare_data.R

Description

Creates a themetadata class by preprocessing data from an OTU table, taxonomic information, sample metadata, and a formula reflecting the preposed relationship between sample metadata and the topics over samples distribution.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
prepare_data(
  otu_table,
  rows_are_taxa,
  tax_table,
  metadata,
  formula,
  refs,
  cn_normalize = TRUE,
  drop = TRUE,
  seed = sample.int(.Machine$integer.max, 1),
  verbose = FALSE
)

Arguments

otu_table

(required) Matrix or dataframe containing taxa abundances (counts, non-negative integers) across samples. Rows and columns must be uniquely named.

rows_are_taxa

(required) Logical flag indicating whether otu_table rows correspond to taxa (TRUE) or samples (FALSE).

tax_table

Matrix or dataframe containing taxonomic information with row or column names corresponding to the otu_table.

metadata

Matrix or dataframe containing sample information with row or column names corresponding to the otu_table.

formula

Formula for covariates of interest found in metadata. Interactions, transformations, splines, and polynomial expansions are permitted.

refs

Character vector of length equal to the number of factors or binary covariates in formula, indicating the reference level.

cn_normalize

Logical flag for performing 16S rRNA copy number normalization. Defaults to TRUE.

drop

Logical flag to drop empty rows and columns. Defaults to TRUE.

seed

Seed for random number generation. This seed will be passed to each function that uses this prepared data unless otherwise overridden. Defaults to a random integer between 1 and the maximum integer supported by R.

verbose

Logical flag to print progress information. Defaults to FALSE.

Value

An object of class themetadata containing

otu_table

Matrix of taxa abundances, correctly overlapping with tax_table and metadata. Will be copy number normalized, lacking empty rows and columns by default.

tax_table

Matrix, correctly overlapping with otu_table

metadata

Dataframe, correctly overlapping with otu_table and formula. All character covariates are converted to factors.

formula

Unaltered, given by the user

splineinfo

List containing the covariate, nonlinear function name, and basis function expansion of all applicable covariates based on the formula.

modelframe

Dataframe of metadata of only applicable covariates with factors expanded as dummy variables

See Also

s

Examples

1
2
3
4
5
6
formula <- ~DIAGNOSIS
refs <- 'Not IBD'

dat <- prepare_data(otu_table=GEVERS$OTU,rows_are_taxa=FALSE,tax_table=GEVERS$TAX,
                    metadata=GEVERS$META,formula=formula,refs=refs,
                    cn_normalize=TRUE,drop=TRUE)

EESI/themetagenomics documentation built on May 10, 2020, 1:40 a.m.