Elastic Predict

Here we explain how to construct an elastic net prediction model. These instructions assume you are analysing individual-level data (if instead you are analysing summary statistics, you should use GigaPRS or MegaPRS).

Always read the screen output, which suggests arguments and estimates memory usage.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The main argument is --elastic <outfile>.

This requires three options

--bfile/--speed <datastem> or --bgen <datafile> - to specify the genetic data files (see File Formats). Note that it is not possible to use SP or SPED formats; if you have data in these format, you should first convert to SPEED format (see Make Data).

--pheno <phenofile> - to specify phenotypes (in PLINK format). If <phenofile> contains more than one phenotype, specify which should be used with --mpheno <integer> or --pheno-name <string> (the latter requires that <phenofile> has a header row), or use --mpheno ALL to analyse all phenotypes.

--LOCO NO - to tell LDAK to focus on creating the genome-wide prediction model (instead of creating leave-one-chromosome-out models for use with LDAK-KVIK).

By default, LDAK will estimate the heritability and the power parameter alpha; to instead specify their values use --her <float> and --power <float> (note that if you use --her, you must also use --power).

If you have computed Per-Predictor Heritabilities, you can provide these using --ind-hers <indhersfile> (note that when using --ind-hers, you can not use --her or --power).

By default, LDAK will use 90%/10% cross-validation to determine suitable prior distribution parameters . You can change the fraction of test samples uing --cv-proportion <float>,  specify the test samples using --cv-samples <cvsampsfile>, or turn off cross-validation, using --skip-cv YES (LDAK will then output multiple models, each trained using 100% of samples).

You can use --keep <keepfile> and/or --remove <removefile> to restrict to a subset of samples, and --extract <extractfile> and/or --exclude <excludefile> to restrict to a subset of predictors (for more details, see Data Filtering).

You can use --covar <covarfile> or --factors <factorfile> to provide quantitative or categorical covariates (in PLINK format) that will be regressed out of the phenotype prior to estimating effect sizes (if <covarfile> contains multiple covariates, you can specify a subset using either --covar-names <string> or --covar-numbers <string>).

The estimated effect sizes is saved in <outfile>.effects. Usually, this file has five columns, providing the predictor name, its A1 and A2 alleles, the average number of A1 alleles, then its estimated effect (relative to the A1 allele). If you used --skip-cv YES, there will be effect sizes for each of the different prior parameters. This file is ready to be used for Calculating Scores (i.e., to predict the phenotypes of new samples).
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Example:

This example uses fake data generated by LDAK using the commands --make-snps and --make-phenos (for a description of these commands, see Simulate Data). Note that after constructing the prediction model, we apply it to target individuals using the command --calc-scores (described in Calculate Scores), then test the accuracy of the resulting predictions using the command --jackknife (described in Jackknife).
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

1 - Simulate genotypes and phenotypes:

The following commands generate SNP genotypes for 10,000 individuals and 20,000 SNPs, as well as a phenotype with heritability 0.5 and 500 causal SNPs

./ldak.out --make-snps fake --num-samples 10000 --num-snps 20000
./ldak.out --make-phenos fake --num-phenos 1 --bfile fake --her 0.5 --num-causals 500 --power -0.25

We will use the first 9000 samples to train the prediction model, and the remaining 1000 to test its accuracy.

head -n 9000 fake.fam > fake.train
tail -n 1000 fake.fam > fake.test
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

2 - Construct the prediction model

The following command estimates effect sizes using only the training samples.

./ldak.out --elastic elastic --pheno fake.pheno --bfile fake --LOCO NO --keep fake.train

The estimated effect sizes are saved in elastic.effects.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

3 - Compute predictions and measure their accuracy

The following command computes predictions for the test samples

./ldak.out --calc-scores prs --scorefile elastic.effects --pheno fake.pheno --bfile fake --keep fake.test

The estimated PRS are saved in prs.profile. Because we provided phenotypes, LDAK also reports that the correlation between the predicted and observed phenotypes is 0.65 (note that because this example uses randomly generated data, the correlation will be different for your analysis).

We can examine the accuracy of the PRS in more detail using the following command

./ldak.out --jackknife jack --profile prs.profile --num-blocks 200

The detailed accuracies are saved in jack.jack. For example, we see that the squared correlation is 0.43 (SD 0.02).