Last active
July 25, 2016 03:52
-
-
Save charles-plessy/6325a878429fef8aae6d9ed25f0054ef to your computer and use it in GitHub Desktop.
Simple R function to plot values for each well of a 384-well plate... Is there better, prettier, smarter ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plate <- data.frame( Row = rep(LETTERS[1:16], 24) | |
, Col = unlist(lapply(1:24, rep, 16))) | |
plate$Row <- factor(plate$Row, levels=rev(levels(plate$Row))) | |
set.seed(1) | |
plate[001:096, "val"] <- rpois(96,10) | |
plate[097:384, "val"] <- rpois(96, 6) | |
# Plot with ggplot2 | |
library(ggplot2) | |
png("plate.png", h = 400, w = 600) | |
ggplot(plate, aes(Col, Row, fill=val)) + geom_raster() + ggtitle("random Ct Data") | |
dev.off() | |
# Plot with HTqPCR | |
library(HTqPCR) | |
# plate needs to be sorted as follows: A1, A2, ..., P23, P24 | |
plate$position <- paste0(plate$Row, plate$Col) | |
plate$position <- sub("^(.)(.)$", "\\10\\2", plate$position, perl=T) | |
plate <- plate[order(plate$position),] | |
library(HTqPCR) | |
raw <- new( "qPCRset" | |
, exprs = matrix(plate$val) | |
, featureCategory = data.frame(rep("OK", nrow(plate))) | |
) | |
sampleNames(raw) <- "random Ct Data" | |
featureNames(raw) <- paste0(plate$Row, plate$Col) | |
featurePos(raw) <- paste0(plate$Row, plate$Col) | |
png("plate2.png", h = 400, w = 600) | |
plotCtCard(raw, well.size = 2.6) | |
dev.off() | |
# Plot with platetools | |
library(platetools) | |
png("plate3.png", h = 400, w = 600) | |
raw_map(plate$val, paste0(plate$Row, plate$Col), 384) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment