Skip to content

Commit 64a0db4

Browse files
author
Vincent Cahais
committed
v1.0
1 parent c810db0 commit 64a0db4

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

examples/dmrplot.Rmd

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: "dmrplot"
3+
runtime: shiny
4+
output: flexdashboard::flex_dashboard
5+
params:
6+
meth: "waterpipe_Funnorm_2022-01-18.rda"
7+
dmrs: "report_SmokingStatus/Cigarette_2022-03-24.dmrs.csv"
8+
---
9+
10+
```{r echo = FALSE, message = FALSE}
11+
#library(data.table)
12+
library(tidyverse)
13+
library(GenomicRanges)
14+
library(ggplot2)
15+
library(reshape2)
16+
library(RColorBrewer)
17+
```
18+
19+
20+
```{r echo = FALSE}
21+
load(params$meth)
22+
dmrs<-read_tsv(params$dmrs) %>% mutate(ID=paste0(seqnames, ":", start, "-", end))
23+
```
24+
25+
Column {.sidebar}
26+
--------------------------------------------------
27+
28+
<h4>Parameters</h4>
29+
30+
```{r echo = FALSE}
31+
selectInput("group", "group", choices = colnames(sampleSheet), selected = 3, multiple = FALSE)
32+
selectInput("dmr", "dmr", choices = dmrs$ID, selected = 1, multiple = FALSE)
33+
```
34+
35+
Column
36+
--------------------------------------------------
37+
38+
```{r echo = FALSE, message = FALSE}
39+
renderPlot({
40+
41+
#foo<-table[ grepl(input$gene,table$overlapping.genes), ]
42+
cpgs<-dmrs %>% filter(ID==input$dmr) %>% pull(overlapping.sites) %>% strsplit(",") %>% unlist()
43+
colnames(betas)<-sampleSheet$samples
44+
foo<-betas[cpgs,] %>% data.frame() %>% rownames_to_column("cpg") %>%
45+
gather("samples","betas",1:ncol(betas)+1) %>%
46+
merge(sampleSheet,by="samples") %>%
47+
group_by_at(c(input$group,"cpg")) %>%
48+
filter(!is.na(betas)) %>%
49+
summarise(sd=sd(betas),betas=mean(betas), .groups = "drop")
50+
51+
ggplot(foo, aes(x=cpg, y=betas, ymin=(betas-sd/2), ymax=(betas+sd/2) , group=get(input$group), fill=get(input$group) ) ) +
52+
geom_line() +
53+
geom_point() +
54+
geom_ribbon(alpha=0.5) +
55+
theme(axis.text.x=element_text(angle=50,hjust=1, size=10)) +
56+
labs(fill=input$group) +
57+
ggtitle(input$dmr)
58+
})
59+
```

0 commit comments

Comments
 (0)