Created
March 12, 2014 13:39
Estimate percent familial risk explained by a list of loci from genome-wide association studies. Input file is a file with columns for annotation, risk allele frequency, and odds ratio for risk allele.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import command line arguments | |
args <- commandArgs(trailingOnly=T) | |
snp_filename <- args[1] | |
fd_fam_risk <- as.numeric(args[2]) | |
# Import SNP data | |
snps <- read.table(snp_filename, as.is=T, header=F) | |
names(snps) <- c("id", "p", "r") | |
attach(snps) | |
# Observed familial risk to first degree relatives | |
print("Familial Risk Estimate (OR):") | |
fd_fam_risk | |
# Calculate familial risk due to each locus | |
snps$lambda <- (p*r**2+(1-p))/((p*r+(1-p))**2) | |
snps | |
# Contribution of known SNPs to familial risk | |
print("Familial Risk Explained (%):") | |
sum(log(snps$lambda))/log(fd_fam_risk)*100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment