Setup

See the setup process for the PLINK2 executable and reference file in the Clumping vignette.

library(genepi.utils)

# the gwas data
gwas <- GWAS(dat=system.file("extdata", "example2_gwas_sumstats.tsv", package="genepi.utils"), map="ns_map", fill_rsid="b37_dbsnp156")
gwas <- as.data.table(gwas)

# check path to reference
which_1000G_reference("GRCh37")

# check path to plink2 executable
which_plink2()

LD matrix

Generate the LD matrix. If we provide a GWAS data.table with the alleles then it will be harmonised with the LD matrix.

# produce LD matrix 
obj <- ld_matrix(gwas,
                 method    = "r2",
                 plink2    = genepi.utils::which_plink2(),
                 plink_ref = genepi.utils::which_1000G_reference(build="GRCh37"))

Harmonise data against LD matrix alleles

The previous command has harmonised the gwas input data.table to the LD alleles. The return value is a list with elements dat and ld_mat.

# harmonised data 
print(obj['dat'])

# the LD matrix
print(obj['ld_mat'])