Skip to contents

When dealing with categorical variables in genetic analysis using, a common approach is to convert these into dummy variables for proper analysis (Purcell et al. 2007) . This function creates K-1 new dummy variables for a variable with K categories. One level is automatically excluded from the dummy variables which serves as the reference category for subsequent analyses. This setup implicitly sets the excluded that category as the baseline against which other categories are compared.

Usage

DummyCovar(DataDir, ResultDir = DataDir, bfile, incovar, outcovar)

Arguments

DataDir

A character string for the file path of the input PLINK binary files.

ResultDir

A character string for the file path where all output files will be stored. The default is tempdir().

bfile

Character string, specifying the prefix of the input PLINK binary files for which covariate file will be generated.

incovar

Character string, specifying the prefix of the input covariate file. First two columns will be, FID (i.e., Family ID) and IID (i.e., Sample ID) and rest of the columns are covariates.

outcovar

Character string, specifying the prefix of the Output covariate file

Value

R dataframe object with covariates

References

Purcell S, Neale B, Todd-Brown K, Thomas L, Ferreira MAR, Bender D, Maller J, Sklar P, de Bakker PIW, Daly MJ, others (2007). “PLINK: A Tool Set for Whole-Genome Association and Population-Based Linkage Analyses.” The American Journal of Human Genetics, 81(3), 559–575. doi:10.1086/519795 .

Examples

DataDir <- GXwasR:::GXwasR_data()
ResultDir <- tempdir()
bfile <- "GXwasR_example"
incovar <- "covarfile_w_pc_age.txt"
outcovar <- "dummycovarfile"
dummy_covars <- DummyCovar(
    DataDir = DataDir, ResultDir = ResultDir,
    bfile = bfile, incovar = incovar,
    outcovar = outcovar
)
#>  Covariate file: dummycovarfile.cov is in /var/folders/d6/gtwl3_017sj4pp14fbfcbqjh0000gp/T//RtmpO7c0S8