This function takes a tidy format. Coerces vectors to correct type. Only include covariates that have 2 or more levels. Sample identifiers are stored as rownames.

clean_covariates(md, factors, continuous, sample_identifier)

Arguments

md

A data frame with sample identifiers in a column and relevant experimental covariates.

factors

A vector of factor variables.

continuous

A vector of continuous variables.

sample_identifier

The name of the column with the sample identifiers that map to the gene counts data frame.

Value

A data frame with coerced variables.

Examples

data <- tibble::tribble(
 ~individualID, ~diagnosis, ~RIN,
 "ind5436", "control", 7.7,
 "ind234", "disease", 7.1
 )
clean_covariates(data, factors = c("individualID", "diagnosis"),
continuous = c("RIN"),
sample_identifier = c("individualID"))
#> Warning: 'as.is' should be specified by the caller; using TRUE
#>         diagnosis RIN
#> ind5436   control 7.7
#> ind234    disease 7.1