PRS: Polygenic risk score

Description Usage Arguments Value Examples

View source: R/PRS.R

Description

A Function to calculate polygenic risk score (PRS). PRS is calculated by summing risk alleles, which are weighted by the effect size of the risk alleles (i.e. beta coefficient for continuous traits or log(OR) for binary traits).

Usage

1
PRS(genotype, beta)

Arguments

genotype

[data.frame/matrix] The genotype data is a data frame or matrix with rows corresponding to individuals and columns to SNPs. SNP genotypes are encoded as the number of minor allele (0, 1, 2).

beta

[vector] The effect size of each SNP. If beta is missing, assuming that all SNPs have the same effect size.

Value

PRS return a vector of polygenic risk scores.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
input.dir <- system.file("extdata", package="pv")
output.dir <- system.file("extdata", package="pv")
path2plink <- '/path/to/plink'
## Not run: 
lr.result <- plink.lr(input.dir = input.dir,
output.dir = output.dir,
genotype = "train",
phenotype = "train.phenotypes.txt",
covar.number = c(2, 3),
plink.path = path2plink,
verbose = TRUE)

beta <- lr.result[which(lr.result$TEST == "ADD"), ]$BETA
beta[is.na(beta)] <- 0
genotype.path <- file.path(input.dir, "train.raw")
genotype.path <- gsub('\\\\', '/', genotype.path)
genotype <- data.table::fread(genotype.path, data.table = FALSE)[, -c(1,2,3,4,5,6)]
prs <- PRS(genotype, beta)

## End(Not run)

abnerzyx/pv documentation built on Feb. 27, 2022, 12:06 a.m.