Learn R Programming

MEAL (version 1.2.3)

preparePhenotype: Process a table of phenotypes

Description

Given a data.frame containing phenotypic variables, select the desired columns and transform them to the desired types.

Usage

preparePhenotype(phenotypes, variable_names, variable_types = rep(NA, length(variable_names)))

Arguments

phenotypes
Data.frame with the phenotypic features
variable_names
Vector with the names or the positions of the desired variables.
variable_types
Vector with the types of the variables.

Value

Data.frame with the columns selected and with the types desired.

Details

preparePhenotype supports five types of variables. Categorical and continuous correspond to factor and numerical types in R. The other three are genomic models as defined in SNPassoc: dominant, recessive and additive. In order to use these types, only two alleles can be present and genotypes should be specified in the form a/b.

If transformation of variables is not needed, the variable_types can be passed as a vector of NA.

Examples

Run this code
pheno <- data.frame(a = sample(letters[1:2], 5, replace = TRUE), b = runif(5), 
c = sample(c("a/a","a/b", "b/b"), 5, replace = TRUE))
pheno <- preparePhenotype(pheno, variable_names = c("a", "c"), 
variable_types = c("categorical", "dominant"))
pheno

Run the code above in your browser using DataLab