Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Cahais committed Mar 28, 2022
1 parent c810db0 commit 64a0db4
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions examples/dmrplot.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: "dmrplot"
runtime: shiny
output: flexdashboard::flex_dashboard
params:
meth: "waterpipe_Funnorm_2022-01-18.rda"
dmrs: "report_SmokingStatus/Cigarette_2022-03-24.dmrs.csv"
---

```{r echo = FALSE, message = FALSE}
#library(data.table)
library(tidyverse)
library(GenomicRanges)
library(ggplot2)
library(reshape2)
library(RColorBrewer)
```


```{r echo = FALSE}
load(params$meth)
dmrs<-read_tsv(params$dmrs) %>% mutate(ID=paste0(seqnames, ":", start, "-", end))
```

Column {.sidebar}
--------------------------------------------------

<h4>Parameters</h4>

```{r echo = FALSE}
selectInput("group", "group", choices = colnames(sampleSheet), selected = 3, multiple = FALSE)
selectInput("dmr", "dmr", choices = dmrs$ID, selected = 1, multiple = FALSE)
```

Column
--------------------------------------------------

```{r echo = FALSE, message = FALSE}
renderPlot({
#foo<-table[ grepl(input$gene,table$overlapping.genes), ]
cpgs<-dmrs %>% filter(ID==input$dmr) %>% pull(overlapping.sites) %>% strsplit(",") %>% unlist()
colnames(betas)<-sampleSheet$samples
foo<-betas[cpgs,] %>% data.frame() %>% rownames_to_column("cpg") %>%
gather("samples","betas",1:ncol(betas)+1) %>%
merge(sampleSheet,by="samples") %>%
group_by_at(c(input$group,"cpg")) %>%
filter(!is.na(betas)) %>%
summarise(sd=sd(betas),betas=mean(betas), .groups = "drop")
ggplot(foo, aes(x=cpg, y=betas, ymin=(betas-sd/2), ymax=(betas+sd/2) , group=get(input$group), fill=get(input$group) ) ) +
geom_line() +
geom_point() +
geom_ribbon(alpha=0.5) +
theme(axis.text.x=element_text(angle=50,hjust=1, size=10)) +
labs(fill=input$group) +
ggtitle(input$dmr)
})
```

0 comments on commit 64a0db4

Please sign in to comment.