Skip to content

Commit 82635eb

Browse files
bschilderclaude
andcommitted
Add pkgdown site config with echoverse dark theme and improve vignette
- Create _pkgdown.yml with dark theme, organized reference groups - Rewrite vignette with runnable examples using bundled echodata - Fix VignetteIndexEntry to use correct package name - Add filter_LD, sparse matrix, and plot_LD runnable sections - Keep remote-only examples (1KG, UKB) as eval=FALSE Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0346415 commit 82635eb

2 files changed

Lines changed: 214 additions & 44 deletions

File tree

_pkgdown.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
url: https://rajlabmssm.github.io/echoLD/
2+
3+
template:
4+
bootstrap: 5
5+
bslib:
6+
bg: "#1a2744"
7+
fg: "#e8f4f4"
8+
primary: "#4ecdc4"
9+
secondary: "#3a8d8c"
10+
success: "#2ee8d6"
11+
info: "#5bc0be"
12+
code-bg: "#d6e4ee"
13+
code-color: "#1a2744"
14+
border-color: "#2a4060"
15+
link-color: "#4ecdc4"
16+
link-hover-color: "#2ee8d6"
17+
font-size-base: "1rem"
18+
includes:
19+
in_header: |
20+
<style>
21+
.navbar { background-color: #162038 !important; border-bottom: 2px solid #4ecdc4; }
22+
.navbar-brand, .nav-link { color: #e8f4f4 !important; }
23+
.nav-link:hover { color: #2ee8d6 !important; }
24+
.nav-link.active { color: #2ee8d6 !important; border-bottom: 2px solid #2ee8d6; }
25+
pre { background-color: #d6e4ee !important; color: #1a2744 !important; border: none !important; border-radius: 12px; margin: 0; padding: 0.8em 1em; }
26+
code { color: #1a6b68 !important; border: none !important; }
27+
pre code { color: #1a2744 !important; border: none !important; background: transparent !important; }
28+
pre code span { border: none !important; background: transparent !important; }
29+
.table { color: #e8f4f4 !important; }
30+
.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(78, 205, 196, 0.05) !important; color: #e8f4f4 !important; }
31+
.table-striped > tbody > tr:nth-of-type(even) > * { background-color: transparent !important; color: #e8f4f4 !important; }
32+
.table > thead { border-bottom: 2px solid #4ecdc4; }
33+
h1, h2, h3, h4, h5, h6 { color: #4ecdc4 !important; }
34+
a { color: #5bc0be; } a:hover { color: #2ee8d6; }
35+
.card { background-color: #1e3050; border-color: #2a4060; }
36+
.footer { background-color: #162038 !important; border-top: 1px solid #2a4060; }
37+
.page-header { border-bottom: 2px solid #3a8d8c; }
38+
.sourceCode { background-color: #d6e4ee !important; border: 1px solid #3a8d8c; border-radius: 12px !important; overflow: hidden; }
39+
.sourceCode code span, .sourceCode code a { border: none !important; outline: none !important; box-shadow: none !important; background: transparent !important; }
40+
</style>
41+
42+
navbar:
43+
structure:
44+
left: [intro, reference, articles, news]
45+
right: [search, github]
46+
components:
47+
github:
48+
icon: fa-github
49+
href: https://github.com/RajLabMSSM/echoLD
50+
51+
articles:
52+
- title: Getting Started
53+
contents:
54+
- echoLD
55+
56+
reference:
57+
- title: LD Retrieval
58+
desc: Retrieve LD matrices from reference panels or custom sources.
59+
contents:
60+
- get_LD
61+
- get_LD_matrix
62+
- get_LD_vcf
63+
64+
- title: LD Blocks
65+
desc: Identify and work with LD blocks.
66+
contents:
67+
- get_LD_blocks
68+
- get_lead_r2
69+
70+
- title: LD Filtering and Conversion
71+
desc: Filter, convert, and transform LD matrices.
72+
contents:
73+
- filter_LD
74+
- r2_to_r
75+
- subset_common_snps
76+
77+
- title: Sparse Matrix I/O
78+
desc: Read, write, and convert sparse LD matrices.
79+
contents:
80+
- readSparse
81+
- saveSparse
82+
- to_sparse
83+
84+
- title: Visualization
85+
desc: Plot LD matrices as heatmaps.
86+
contents:
87+
- plot_LD
88+
89+
- title: VCF Utilities
90+
desc: VCF sample selection and format conversion.
91+
contents:
92+
- select_vcf_samples
93+
- vcf_to_plink
94+
95+
- title: Allele Frequencies
96+
desc: Minor allele frequency retrieval.
97+
contents:
98+
- get_MAF_UKB

vignettes/echoLD.Rmd

Lines changed: 116 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,160 @@
11
---
2-
title: "Getting Started"
3-
author: "<h4>Authors: <i>`r auths <- eval(parse(text = gsub('person','c',read.dcf('../DESCRIPTION', fields = 'Authors@R'))));paste(auths[names(auths)=='given'],auths[names(auths)=='family'], collapse = ', ')`</i></h4>"
2+
title: "Getting Started"
3+
author: "<h4>Authors: <i>`r auths <- eval(parse(text = gsub('person','c',read.dcf('../DESCRIPTION', fields = 'Authors@R'))));paste(auths[names(auths)=='given'],auths[names(auths)=='family'], collapse = ', ')`</i></h4>"
44
date: "<h4>Vignette updated: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h4>"
55
output:
66
BiocStyle::html_document
77
vignette: >
8-
%\VignetteIndexEntry{templateR}
8+
%\VignetteIndexEntry{echoLD}
99
%\usepackage[utf8]{inputenc}
1010
%\VignetteEngine{knitr::rmarkdown}
1111
---
1212

13-
```{r setup}
13+
```{r setup, include = FALSE}
14+
knitr::opts_chunk$set(
15+
collapse = TRUE,
16+
comment = "#>"
17+
)
18+
```
19+
20+
# Introduction
21+
22+
`echoLD` is an [echoverse](https://github.com/RajLabMSSM/echoverse) module
23+
for retrieving and processing linkage disequilibrium (LD) matrices.
24+
It supports multiple LD reference panels:
25+
26+
- **1000 Genomes** Phase 1 and Phase 3 (computed on-the-fly from VCF)
27+
- **UK Biobank** (pre-computed LD matrices)
28+
- **Custom VCF** files supplied by the user
29+
- **Pre-computed LD matrices** in `.rds`, `.csv`, or `.tsv` format
30+
31+
# Setup
32+
33+
```{r load}
1434
library(echoLD)
35+
```
36+
37+
The examples below use bundled data from the `echodata` package:
38+
a subset of summary statistics from the *BST1* locus and a
39+
pre-computed LD matrix.
1540

16-
query_dat <- echodata::BST1[seq(1,100),]
41+
```{r example_data}
42+
query_dat <- echodata::BST1[seq_len(50), ]
1743
locus_dir <- file.path(tempdir(), echodata::locus_dir)
44+
LD_matrix <- echodata::BST1_LD_matrix
1845
```
1946

47+
# Pre-computed LD matrix
48+
49+
If you already have an LD matrix on disk, `get_LD_matrix()` reads it in
50+
and aligns it with your summary statistics.
2051

21-
# 1000 Genomes: Phase 1 or 3
52+
```{r get_LD_matrix}
53+
## Write the bundled LD matrix to a temp CSV to demonstrate the workflow
54+
LD_path <- tempfile(fileext = ".csv")
55+
utils::write.csv(LD_matrix, file = LD_path, row.names = TRUE)
2256
23-
```{r, eval=FALSE}
24-
LD_1kgp3 <- echoLD::get_LD(locus_dir = locus_dir,
25-
query_dat = query_dat,
26-
LD_reference = "1KGphase3") # 1KGphase1
57+
LD_list <- echoLD::get_LD_matrix(
58+
locus_dir = locus_dir,
59+
query_dat = query_dat,
60+
LD_reference = LD_path
61+
)
2762
```
2863

29-
## Plot
64+
# Custom VCF
65+
66+
You can compute LD on-the-fly from any VCF file.
67+
The `echodata` package ships a small 1000 Genomes Phase 3 VCF
68+
for the BST1 locus.
3069

31-
```{r, eval=FALSE}
32-
echoLD::plot_LD(LD_matrix = LD_1kgp3$LD,
33-
query_dat = LD_1kgp3$DT,
34-
span = 20)
70+
```{r get_LD_vcf, eval = requireNamespace("VariantAnnotation", quietly = TRUE) && requireNamespace("snpStats", quietly = TRUE)}
71+
LD_reference <- system.file("extdata", "BST1.1KGphase3.vcf.bgz",
72+
package = "echodata")
73+
LD_vcf <- echoLD::get_LD_vcf(
74+
locus_dir = locus_dir,
75+
query_dat = query_dat,
76+
LD_reference = LD_reference
77+
)
3578
```
3679

80+
# 1000 Genomes (remote)
81+
82+
Querying the full 1000 Genomes VCF requires downloading chromosome-level
83+
VCF files from a remote server. This requires an internet connection
84+
and can take several minutes.
3785

38-
# UK Biobank
86+
```{r get_LD_1kg, eval = FALSE}
87+
LD_1kgp3 <- echoLD::get_LD(
88+
locus_dir = locus_dir,
89+
query_dat = query_dat,
90+
LD_reference = "1KGphase3"
91+
)
92+
```
3993

40-
*WARNING*: Takes substantially longer than 1000 Genomes methods.
94+
# UK Biobank (remote)
4195

42-
```{r, eval=FALSE}
43-
LD_ukb <- echoLD::get_LD(locus_dir = locus_dir,
44-
query_dat = query_dat,
45-
LD_reference = "UKB",
46-
download_method = "axel",
47-
nThread = 10)
96+
Pre-computed LD from a British European-descent subset of UK Biobank.
97+
**Note:** This takes substantially longer than the 1000 Genomes methods.
98+
99+
```{r get_LD_ukb, eval = FALSE}
100+
LD_ukb <- echoLD::get_LD(
101+
locus_dir = locus_dir,
102+
query_dat = query_dat,
103+
LD_reference = "UKB",
104+
download_method = "axel",
105+
nThread = 10
106+
)
48107
```
49108

50-
## Plot
109+
# Filtering LD
110+
111+
Use `filter_LD()` to remove SNPs below a minimum r2 threshold.
51112

52-
```{r, eval=FALSE}
53-
echoLD::plot_LD(LD_matrix = LD_ukb$LD,
54-
query_dat = LD_ukb$DT,
55-
span = 20)
113+
```{r filter_LD}
114+
LD_list_full <- list(LD = LD_matrix, DT = echodata::BST1)
115+
LD_list_filt <- echoLD::filter_LD(LD_list = LD_list_full, min_r2 = 0.2)
116+
dim(LD_list_filt$LD)
56117
```
57118

119+
# Sparse matrix utilities
58120

59-
# Custom VCF
121+
`echoLD` provides helpers for working with sparse LD matrices,
122+
which reduce file size substantially.
60123

61-
```{r, eval=FALSE}
62-
LD_reference <- system.file("extdata","BST1.1KGphase3.vcf.bgz",
63-
package = "echodata")
64-
samples <- c("HG00097","HG00099","HG00100","HG00101","HG00102")
65-
LD_custom <- echoLD::get_LD(locus_dir = locus_dir,
66-
query_dat = query_dat,
67-
LD_reference = LD_reference)
124+
```{r sparse}
125+
## Convert a dense matrix to sparse format
126+
sparse_mat <- echoLD::to_sparse(X = LD_matrix)
127+
class(sparse_mat)
128+
129+
## Save to disk
130+
sparse_path <- echoLD::saveSparse(LD_matrix = LD_matrix)
131+
file.info(sparse_path)$size
132+
133+
## Read it back
134+
sparse_read <- echoLD::readSparse(LD_path = sparse_path)
135+
dim(sparse_read)
68136
```
69137

70-
## Plot
138+
# Plotting LD
139+
140+
Plot a heatmap of pairwise LD around the lead SNP.
71141

72-
```{r, eval=FALSE}
73-
echoLD::plot_LD(LD_matrix = LD_custom$LD,
74-
query_dat = LD_custom$DT,
75-
span = 20)
142+
```{r plot_LD, fig.width = 7, fig.height = 6}
143+
echoLD::plot_LD(
144+
LD_matrix = LD_matrix,
145+
query_dat = echodata::BST1,
146+
span = 10
147+
)
76148
```
77149

78-
# Session Info
150+
# Session Info
79151

80-
<details>
152+
<details>
81153

82154
```{r Session Info}
83155
utils::sessionInfo()
84156
```
85157

86-
</details>
158+
</details>
87159

88160
<br>

0 commit comments

Comments
 (0)