-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
97 lines (80 loc) · 4.05 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# locusplotr <img src='man/figures/logo.png' align="right" height="139" />
<!-- badges: start -->
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://github.com/mglev1n/locusplotr/actions)
[](https://github.com/mglev1n/locusplotr/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of `locusplotr` is to allow users to integrate genome-wide association study results with linkage disequilibrium data to create regional association plots surrounding a genomic locus of interest. The `gg_locusplot` function allows the user to provide GWAS summary statistics for a region of interest and a reference/sentinel/lead variant within that region, and will return a ggplot object with a regional association plot. In the background, this package uses a helper function named `ld_extract_locuszoom` to query the University of Michigan LocusZoom API (<https://portaldev.sph.umich.edu/>) to obtain linkage disequilibrium data for a genetic variant and genomic region of interest (allowing the user to specify genome build and genetic ancestry).
## Installation
You can install `locusplotr` from [GitHub](https://github.com/):
``` r
# install.packages("devtools")
devtools::install_github("mglev1n/locusplotr")
```
## Usage
Start with a dataframe containing genome wide association study summary statistics at a locus of interest
```{r df_example}
library(locusplotr)
fto_locus_df
```
Use the `gg_locusplot` function to create a regional association plot. This calls the `ld_extract_locuszoom` function in the background to fetch linkage disequilibrium data from the University of Michigan LocusZoom API (<https://portaldev.sph.umich.edu/>).
```{r message=FALSE, warning=FALSE, dpi = 300, out.width = '80%', fig.align="center"}
library(tidyverse)
fto_locus_df %>%
gg_locusplot(
lead_snp = "rs62033413",
rsid = rsid,
chrom = chromosome,
pos = position,
ref = effect_allele,
alt = other_allele,
p_value = p_value
)
```
Use the `plot_genes` argument to include a plot of genes within the region beneath the main regional association plot.
```{r message=FALSE, warning=FALSE, dpi = 300, out.width = '80%', fig.align="center"}
gg_locusplot(
df = fto_locus_df,
lead_snp = "rs62033413",
rsid = rsid,
chrom = chromosome,
pos = position,
ref = effect_allele,
alt = other_allele,
p_value = p_value,
plot_genes = TRUE
)
```
Use the `plot_recombination` argument to include a secondary axis containing recombination rates on regional association plot.
```{r message=FALSE, warning=FALSE, dpi = 300, out.width = '80%', fig.align="center"}
gg_locusplot(
df = fto_locus_df,
lead_snp = "rs62033413",
rsid = rsid,
chrom = chromosome,
pos = position,
ref = effect_allele,
alt = other_allele,
p_value = p_value,
plot_genes = TRUE,
plot_recombination = TRUE
)
```
Additional arguments allow the user to specify the genome build (GRCh37, GRCH38), population (Eg. ALL, AMR, AFR, EUR, EAS, etc.), plot title/subtitle, and directory to save the regional association plot as a .pdf.
<br><br>
The `ld_extract_locuszoom` function, called in the background by `gg_locusplot`, can also be used to retrieve linkage disequilibrium data for a genetic variant and genomic region of interest. The user may again specify genome build, population, and the specific linkage disequilibrium metric (Eg. r, rsquare, cov)
```{r message=FALSE, warning=FALSE}
ld_extract_locuszoom(chrom = 16, pos = 53830055, ref = "C", alt = "G", start = 53830055 - 5e5, stop = 53830055 + 5e5, genome_build = "GRCh37", population = "ALL", metric = "rsquare")
```