# HEGP.example.R

# Author: Richard Mott, UCL Genetics Institute.

# (C) 2019 Richard Mott

# The function CFW.example() will download public data from Nicod et al 2016 Nature Genetics

# That paper analyses outbred CFW mice for many traits, see http://outbredmice.org.

# The function will by default download genotype dosages just for chromosome 11

# and the phenotypes for Platelets (after correction for covariates).

# These data are chosen because there is a QTL for Platelets on chr11

# (see http://mtweb.cs.ucl.ac.uk/qtls/Haem.PLT_chr.11.97045910.pdf)

# It will save these data in a Rdata object D that is organised appropriately for

# encryption and analysis by other functions in this file.

# It then simulates an approprately sized encryyption matrix and

# performs association mapping using both original and encrypted data.

# It also computes diagnostic plots and statistics exploring the

# degree of randomness in the encrypted data (evaluated as the correlation

# between the orioginal and encrypted dosages), and the concordance betgween the

# logP values of the association statistics

# A pdf file of diagnostic plots called "chr11.PLT.pdf"

# Text output should be:

# > source("HEGP.examples.R")

# > CFW.example(mixed.model=TRUE)

# estimated heritability 0.02534315

# Built kinship dim 1329 1329

# estimated heritability 0.025049

# gwas logP mean diff 0.003140902 max diff 0.02634605 cor 0.9999849

# Min. 1st Qu. Median Mean 3rd Qu. Max.

# 7.400e-08 1.103e-03 2.158e-03 3.141e-03 3.865e-03 2.635e-02

# correlation of plaintext and ciphertext genotypes

# Min. 1st Qu. Median Mean 3rd Qu. Max.

# 1.330e-06 7.942e-03 1.676e-02 2.061e-02 2.989e-02 8.331e-02

# correlation of plaintext and ciphertext phenotypes

# [,1]

# [1,] 0.01833442

# [1] 1