view deseq2_03_MA_plot.Rmd @ 2:706ecfe0bac3 draft

initial 2.2.0
author mingchen0919
date Fri, 09 Mar 2018 08:53:17 -0500
parents
children
line wrap: on
line source

---
title: 'DESeq2 Analysis'
output: html_document
---

```{r setup, include=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(
  echo = as.logical(opt$X_e), 
  error = TRUE
)
```


## MA-plot

```{r warning=FALSE, message=FALSE}
df = data.frame(ID = rownames(res),
                mean = res$baseMean,
                lfc = res$log2FoldChange,
                padj = res$padj,
                stringsAsFactors = FALSE)
cols = vector(mode='character', length = nrow(res))
cols[(res$padj < opt$X_I) & !is.na(res$padj)] = paste0('< ', opt$X_I)
cols[(res$padj >= opt$X_I) & !is.na(res$padj)] = paste0('>= ', opt$X_I)
cols[cols == ''] = 'NA'
df$col = cols
p = ggplot(data = df) +
  geom_point(mapping = aes(x = log(mean), y = lfc, col = cols, key = ID)) +
  scale_x_continuous(name = 'Log(mean)') +
  scale_y_continuous(name = 'Log fold change') +
  scale_color_discrete(name = 'Adjusted P')+
  theme_classic()
ggplotly(p)
```