MyNixOS website logo
Description

Match Cases to Controls Based on Genotype Principal Components.

Matches cases to controls based on genotype principal components (PC). In order to produce better results, matches are based on the weighted distance of PCs where the weights are equal to the % variance explained by that PC. A weighted Mahalanobis distance metric (Kidd et al. (1987) <DOI:10.1016/0031-3203(87)90066-5>) is used to determine matches.

PCAmatchR

CRANversion CRAN RStudio mirrordownloads license

Overview

PCAmatchR optimally matches a set of population-based controls to cases. PCAmatchR converts user-provided principal components (PC) into a Mahalanobis distance metric for selecting a set of well-matched controls for each case.

PCAmatchR takes as input user defined PCs and eigenvalues and directly outputs optimal case and control matches.

Important Note

The optmatch code is not contained in this package. In order to use PCAmatchR, users must manually install and load the optmatch package (>=0.9-1) separately and accept its license. Manual loading is necessary due to software license issues. If the optmatch package is not loaded, the PCAmatchR main function, match_maker(), will fail and display an error message. For more information about the optmatch package, please see the reference below.

Installation

To install the release version from CRAN:

install.packages("PCAmatchR")

To install the development version from GitHub:

devtools::install_github("machiela-lab/PCAmatchR")

Available functions

FunctionDescription
match_makerMain function. Weighted matching of controls to cases using PCA results.plot_makerEasily make a plot of matches from match_maker output.

Available sample data sets

Data setDescription
PCs_1000GFirst 20 principal components of 2504 individuals from Phase 3 of 1000 Genomes Project.
eigenvalues_1000GA sample data set containing the first 20 eigenvalues.
eigenvalues_all_1000GA sample data set containing all of the eigenvalues.

Usage

library(PCAmatchR)
library(optmatch)

##### Input match_maker sample data

 # Create PC data frame
 pcs<- as.data.frame(PCs_1000G[,c(1,5:24)])

 # Create eigenvalues vector
 eigen_vals<- c(eigenvalues_1000G)$eigen_values
 
 # Create full eigenvalues vector
 all_eigen_vals<- c(eigenvalues_all_1000G)$eigen_values

 # Create Covarite data frame
 cov_data<- PCs_1000G[,c(1:4)]

 # Generate a case status variable
 cov_data$case <- ifelse(cov_data$pop=="ESN", c(1), c(0))


###################
# Run match_maker #
###################

# 1 to 1 matching
test <- match_maker(PC = pcs,
                    eigen_value = eigen_vals,
                    data = cov_data,
                    ids = c("sample"),
                    case_control = c("case"),
                    num_controls = 1,
                    eigen_sum = sum(all_eigen_vals))
test$matches
test$weights


# 1 to 2 matching
test <- match_maker(PC = pcs,
                    eigen_value = eigen_vals,
                    data = cov_data,
                    ids = c("sample"),
                    case_control = c("case"),
                    num_controls = 2,
                    eigen_sum = sum(all_eigen_vals))
test$matches
test$weights


# 1 to 1 matching with exact "gender" matching
test <- match_maker(PC = pcs,
                    eigen_value = eigen_vals,
                    data = cov_data,
                    ids = c("sample"),
                    case_control = c("case"),
                    num_controls = 1,
                    eigen_sum = sum(all_eigen_vals),
                    exact_match=c("gender"))
test$matches
test$weights

Reference

Hansen BB, Klopfer SO. Optimal full matching and related designs via network flows. Journal of computational and Graphical Statistics. 2006 Sep 1;15(3):609-27.

Metadata

Version

0.3.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows