get_LD_matrix: Get LD from pre-computed matrix

View source: R/get_LD_matrix.R

get_LD_matrixR Documentation

Get LD from pre-computed matrix

Description

Get LD from a pre-computed matrix of pairwise r / r2values.

Usage

get_LD_matrix(
  locus_dir = tempdir(),
  query_dat,
  LD_reference,
  query_genome = "hg19",
  target_genome = "hg19",
  fillNA = 0,
  stats = "R",
  as_sparse = TRUE,
  subset_common = TRUE,
  verbose = TRUE
)

Arguments

locus_dir

Storage directory to use.

query_dat

SNP-level summary statistics subset to query the LD panel with.

LD_reference

LD reference to use:

  • "1KGphase1" : 1000 Genomes Project Phase 1 (genome build: hg19).

  • "1KGphase3" : 1000 Genomes Project Phase 3 (genome build: hg19).

  • "UKB" : Pre-computed LD from a British European-decent subset of UK Biobank. Genome build : hg19

  • "<vcf_path>" : User-supplied path to a custom VCF file to compute LD matrix from.
    Accepted formats: .vcf / .vcf.gz / .vcf.bgz
    Genome build : defined by user with target_genome.

  • "<matrix_path>" : User-supplied path to a pre-computed LD matrix Accepted formats: .rds / .rda / .csv / .tsv / .txt
    Genome build : defined by user with target_genome.

query_genome

Genome build of the query_dat.

target_genome

Genome build of the LD panel. This is automatically assigned to the correct genome build for each LD panel except when the user supplies custom vcf/LD files.

fillNA

When pairwise LD between two SNPs is NA, replace with 0.

stats

The linkage disequilibrium measure to be calculated. Can be "R" (default) or "R.squared".

as_sparse

Convert the LD matrix to a sparse matrix.

subset_common

Subset LD_matrix and dat to only the SNPs that are common to them both.

verbose

Print messages.

See Also

Other LD: check_population_1kg(), compute_LD(), filter_LD(), get_LD(), get_LD_1KG(), get_LD_1KG_download_vcf(), get_LD_UKB(), get_LD_vcf(), get_locus_vcf_folder(), ldlinkr_ldproxy_batch(), plot_LD(), popDat_1KGphase1, popDat_1KGphase3, rds_to_npz(), saveSparse(), save_LD_matrix(), snpstats_get_MAF()

Examples

query_dat <-  echodata::BST1[seq(1, 50), ] 
locus_dir <- file.path(tempdir(),  echodata::locus_dir)
LD_reference <- tempfile(fileext = ".csv")
utils::write.csv(echodata::BST1_LD_matrix,
                 file = LD_reference,
                 row.names = TRUE)
LD_list <- get_LD_matrix(
    locus_dir = locus_dir,
    query_dat = query_dat,
    LD_reference = LD_reference)

RajLabMSSM/echoLD documentation built on May 12, 2024, 3:23 a.m.