diff --git a/plot-plates.R b/plot-plates.R new file mode 100644 index 0000000..ce120f1 --- /dev/null +++ b/plot-plates.R @@ -0,0 +1,58 @@ +## Plate sanity checks + +suppressPackageStartupMessages({ + library(platetools) + library(ggplot2) + library(dplyr) + library(viridis) +}) + +wells_all <- read.csv("rnai-p_values.csv") %>% + mutate(significant = p_value < 0.05) +binwidth <- 0.025 + +plot_save <- function(prefix, dir = "plots", extensions = c("png")) { + invisible(sapply(file.path(dir, paste(prefix, extensions, sep = ".")), + ggplot2::ggsave, width = 8, height = 5, + units = "in")) +} + +plates <- wells_all$plate %>% unique %>% sort +for (plate_ in plates) { + wells_plate <- filter(wells_all, plate == plate_) + data <- platetools::plate_map(wells_plate[["n"]], wells_plate$well) + ggplot(data, + aes(Column, Row)) + + geom_tile(aes(x = Column, y = Row, fill = values), size = 2, + color = "white") + + geom_text(aes(label = values), size = 3) + + coord_fixed(ratio = 1, + xlim = c(0.5, 24.5), + ylim = c(0.5, 16.5)) + + scale_x_continuous(breaks = seq(1, 24), expand = c(0, 0)) + + scale_y_reverse(breaks = seq(1, 16), labels = LETTERS[1:16], + expand = c(0, 0)) + + scale_fill_distiller(direction = 1) + xlab("") + ylab("") + + theme_minimal() + + ggtitle(paste0("Plate ", plate_, ": number of cells")) + plot_save(paste0("plate_", plate_, "-cell_count")) +} + +## Check repeated RNAi wells. +wells_repeated <- group_by(wells_all, symbol) %>% + summarise(n_symbol = n(), coloc_mean = mean(coloc), + coloc_stddev = sd(coloc)) %>% + filter(n_symbol > 1) + +print(summary(wells_repeated)) + +wells_repeated %>% merge(wells_all) %>% arrange(-coloc_stddev) %>% + write.csv("wells-stddev-descending.csv", row.names = FALSE) + +ggplot(wells_repeated, aes(coloc_mean, coloc_stddev)) + + geom_point(aes(size = n_symbol), alpha = 0.5) +plot_save("stddev-scatter") + +ggplot(wells_repeated, aes(coloc_mean, coloc_stddev)) + + geom_text(aes(label = symbol), check_overlap = TRUE) +plot_save("stddev-words")