Skip to content

Commit

Permalink
ENH: Plot multiwell plates
Browse files Browse the repository at this point in the history
  • Loading branch information
pan14001 committed Feb 7, 2017
1 parent 0916ac5 commit 7b25c4f
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions plot-plates.R
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 7b25c4f

Please sign in to comment.