Skip to contents

Bundle per-block eigendecompositions with the variants they were computed over.

Usage

LdEigen(
  snpInfo,
  eigenList,
  ldBlocks,
  nRef,
  inSample = FALSE,
  genome = NA_character_,
  eigenvalueTruncation = 1
)

Arguments

snpInfo

A data.frame with columns SNP, CHR, BP, A1, A2 (and optionally MAF).

eigenList

A list with one entry per LD block.

ldBlocks

A GRanges of LD block intervals.

nRef

Integer, sample size of the LD reference panel.

inSample

Logical, whether the reference is the GWAS cohort.

genome

Character, genome build; recorded in seqinfo().

eigenvalueTruncation

Numeric in (0, 1]; proportion of variance retained.

Value

An LdEigen.

Examples

snpInfo <- data.frame(SNP = paste0("rs", 1:4), CHR = "chr1",
  BP = c(50L, 150L, 250L, 350L), A1 = "A", A2 = "G")
blocks <- GenomicRanges::GRanges("chr1",
  IRanges::IRanges(c(1L, 200L), c(199L, 400L)))
mkBlock <- function(idx) list(values = rep(1, length(idx)),
  vectors = diag(length(idx)), snpIdx = idx)
le <- LdEigen(snpInfo = snpInfo,
  eigenList = list(mkBlock(1:2), mkBlock(3:4)),
  ldBlocks = blocks, nRef = 100L, genome = "hg19")
length(le)
#> [1] 4
length(getEigenList(le))
#> [1] 2