Extract the LD correlation matrix from an LdData object.
If only a genotype handle is available, recomputes R from genotypes on the
fly.
Examples
data(eqtlRegionExample)
X <- eqtlRegionExample$X[, 1:8]
gr <- GenomicRanges::GRanges("22",
IRanges::IRanges(seq(1L, by = 100L, length.out = 8), width = 1L))
ld <- LdData(correlation = cor(X), variants = gr,
blockMetadata = S4Vectors::DataFrame(
chrom = "22", start = 1L, end = 1000L))
getCorrelation(ld)
#> chr22:32119788:T:C chr22:32119867:T:G chr22:32119961:T:G
#> chr22:32119788:T:C 1.00000000 1.00000000 -0.3896071
#> chr22:32119867:T:G 1.00000000 1.00000000 -0.3896071
#> chr22:32119961:T:G -0.38960714 -0.38960714 1.0000000
#> chr22:32120053:T:C -0.07607973 -0.07607973 -0.1431621
#> chr22:32120593:A:G -0.07607973 -0.07607973 -0.1431621
#> chr22:32120636:T:C -0.16985384 -0.16985384 -0.2327461
#> chr22:32120932:G:A 0.64492502 0.64492502 -0.2595210
#> chr22:32120975:A:G -0.11897144 -0.11897144 -0.1416922
#> chr22:32120053:T:C chr22:32120593:A:G chr22:32120636:T:C
#> chr22:32119788:T:C -0.07607973 -0.07607973 -0.16985384
#> chr22:32119867:T:G -0.07607973 -0.07607973 -0.16985384
#> chr22:32119961:T:G -0.14316214 -0.14316214 -0.23274610
#> chr22:32120053:T:C 1.00000000 1.00000000 -0.09691283
#> chr22:32120593:A:G 1.00000000 1.00000000 -0.09691283
#> chr22:32120636:T:C -0.09691283 -0.09691283 1.00000000
#> chr22:32120932:G:A -0.01898060 -0.01898060 -0.14868888
#> chr22:32120975:A:G -0.08068061 -0.08068061 0.68622457
#> chr22:32120932:G:A chr22:32120975:A:G
#> chr22:32119788:T:C 0.6449250 -0.11897144
#> chr22:32119867:T:G 0.6449250 -0.11897144
#> chr22:32119961:T:G -0.2595210 -0.14169222
#> chr22:32120053:T:C -0.0189806 -0.08068061
#> chr22:32120593:A:G -0.0189806 -0.08068061
#> chr22:32120636:T:C -0.1486889 0.68622457
#> chr22:32120932:G:A 1.0000000 -0.12097213
#> chr22:32120975:A:G -0.1209721 1.00000000