forked from aneuraz/shiny_intro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanhattan_plot.Rmd
60 lines (45 loc) · 1.37 KB
/
manhattan_plot.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
---
title: "manhattan plot"
author: "Antoine Neuraz"
date: "21/10/2016"
output: html_document
---
```{r setup, include=FALSE}
library(shiny)
library(dplyr)
library(ggplot2)
library(plotly)
library(DT)
library(shinydashboard)
knitr::opts_chunk$set(echo = FALSE)
catalog_path <- 'data/phewas-catalog.csv'
codes_path <- 'data/phewas_codes_2016-10-11.csv'
# load data from csv
catalog <- read.csv(catalog_path, stringsAsFactors = F)
codes <- read.csv(codes_path, stringsAsFactors = F)
# extract unique phewas codes from codes list
codes <- codes %>%
select(jd_code, category_string) %>%
unique()
# merge codes with their respective category (for plotting)
catalog <- catalog %>% merge(codes, by.x = 'phewas.code', by.y = 'jd_code')
# extract the list of snps from the catalog
snps <- catalog %>%
select(snp, gene_name) %>%
unique()
# select top10 genes with significant associations
top10 <- catalog %>%
filter(p.value < 0.05/1815) %>%
group_by(snp, gene_name) %>%
summarize(count = n()) %>%
arrange(desc(count)) %>%
head(10) %>%
select(snp, gene_name)
# function to draw a manhattan plot with ggplot2
# parameters: catalog = dataframe with the results from the PheWAS catalog
# choice = a named vector with the snp and the gene_name
draw_manhattan_simple <- function(catalog, choice) {
}
draw_manhattan_plotly <- function(catalog, choice) {
}
```