Using the R package BiasedUrn to implement a permutation procedure to correct for confounders in case-control studies
In our recent paper (Epstein, et al., 2012), we proposed to adjust case-control association tests (including tests of rare variation) for confounders using a permutation approach. The approach, which can adjust for an arbitrary number of continuous and categorical covariates, can be implemented using a modified version of an open source R package called BiasedUrn authored and maintained at CRAN by Agner Fog. This page describes how to modify and install this package and also provides sample code for implementing the approach.
R is a widely-used, free and open source software environment for statistical computing and graphics. The most recent version of R can be downloaded from the Comprehensive R Archive Network (CRAN). CRAN provides precompiled binary versions of R for Windows, MacOS, and select Linux distributions that are likely sufficient for many users' needs. Users can also install R from source code; however this may require a significant amount of effort. For specific details on how to compile, install, and manage R and R-packages, refer to the manual R Installation and Administration, which is available from the CRAN documentation site.
While a precompiled version of the BiasedUrn library is available on CRAN, this precompiled version cannot be used for the sampling performed in our AJHG paper because it only allows for a maximum of 32 subjects (see our paper for more details). Consequently, to increase the sample size to values anticipated for case-control association studies, one must download the source code for BiasedUrn, make a minor change to the source code, and then recompile and install the modified executable for analysis. We describe how to perform these tasks for different operating systems below.
To obtain the BiasedUrn package source code, go to the repository for the package on CRAN and download the source file BiasedUrn_1.04.tar.gz as highlighted in Figure 1.
Figure 1. The BiasedUrn package page at CRAN. The package source link is highlighted here.Each operating system uses a different set of developer tools to build R packages from source code; however, the basic steps are the same for each operating system:
- modify the MAXCOLORS constant in the Makevars file found within the package source code
- run the
R CMD checkcommand to verify the modified package - run the
R CMD buildcommand to create an installable package - run the
R CMD INSTALLcommand to install the modified package
We provide OS-specific instructions for modifying and installing the source code below:
Once the modified version of BiasedUrn is properly installed, the procedure can be used to generate permuted case-control datasets that are adjusted for confounders. Please see our sample R code for an example that uses the procedure.
For questions or concerns with the BiasedUrn package, please contact Richard Duncan and Michael Epstein.
We appreciate any feedback you have with our site and instructions.
Epstein software | Human Genetics | School of Medicine | Emory University

