From aed11759d14ebf893dae11282a1c7cdc863c6ac4 Mon Sep 17 00:00:00 2001 From: Pariksheet Nanda Date: Tue, 7 Feb 2017 13:54:39 -0500 Subject: [PATCH] ENH: Control comparison plots (work in progress) - Need to create p-value column using control references instead of cells. - Need to display on plot in "fold change" e.g. relative to LacZ. --- plots.R | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/plots.R b/plots.R index bcda9ba..2e613f7 100644 --- a/plots.R +++ b/plots.R @@ -3,13 +3,12 @@ suppressPackageStartupMessages({ library(ggplot2) library(dplyr) + library(readr) }) -wells_all <- read.csv("rnai-p_values.csv") %>% +wells_all <- read_csv("rnai-p_values.csv") %>% mutate(significant = p_value < 0.05) binwidth <- 0.025 -## Bring RNAi to the front of the level list. -wells_all$type <- relevel(wells_all$type, "RNAi") theme_set(theme_bw()) @@ -20,7 +19,7 @@ plot_save <- function(prefix, dir = "plots", units = "in")) } -ggplot(filter(wells_all, type == "RNAi"), +ggplot(filter(wells_all, is.na(control)), aes(coloc, fill = significant)) + geom_histogram(binwidth = binwidth) + scale_fill_manual(values = c("grey", "blue")) + @@ -30,15 +29,33 @@ plot_save("rnai-hist-signif") ggplot(filter(wells_all, !is.na(control), - plate == "160415_015529-V"), - aes(coloc, fill = significant)) + + plate == "504"), + aes(coloc, fill = symbol)) + geom_histogram(binwidth = binwidth) + facet_wrap(~ control) + - scale_fill_manual(values = c("grey", "blue")) + - ggtitle(paste("Histogram of control wells with", - "significant overlap (p-value < 5%)")) + + ggtitle(paste("Histogram of control wells in plate 504")) + xlab("% colocalization") +ggplot(filter(wells_all, !is.na(control)) %>% + group_by(well) %>% mutate(ymin = min(coloc), ymax = max(coloc), + plate = factor(plate)), + aes(well, coloc, color = plate)) + + geom_errorbar(aes(ymin = ymin, ymax = ymax), color = "gray") + + geom_jitter(aes(shape = plate)) + + scale_color_brewer(palette = "Set1") + + ggtitle(paste("Scatter plot of control well colocalization across plates")) + + xlab("well") + ylab("% colocalization") + +ggplot(filter(wells_all, !is.na(control)) %>% + group_by(well) %>% mutate(ymin = min(p_value), ymax = max(p_value), + plate = factor(plate)), + aes(well, p_value, color = plate)) + + geom_errorbar(aes(ymin = ymin, ymax = ymax, color = control)) + + geom_jitter(aes(shape = plate, size = n)) + + scale_color_brewer(palette = "Set1") + + ggtitle(paste("Scatter plot of control well p-values across plates")) + + xlab("well") + ylab("p-value") + ggplot(wells_all, aes(coloc, color = type)) + geom_freqpoly(binwidth = binwidth) + scale_y_log10() +