I am making MA plots from Microarray data after normalizing with the oligo library. all of this is working fine. The MA plots are even fine, but at this point I would like to add color to points that are above and below a certain threshold. Say 1 and -1. I haven't decided yet, exactly. I am using Limma and oligo libraries, and looked into ggplot2 a little, but could not get code I found for that to work with my script. here is my script that I am using for the MA plot. I am working with affymetrix MoGene 2.0-st.cel data. Sorry if I posted this incorrectly, I am new to the forum.
library(limma)
library(oligo)
#loads celFiles
celFiles <- list.celfiles()
#sets "affyRaw" as the variable for cel file data
affyRaw <- read.celfiles(celFiles)
#normalizes data with rma function and assigns them to expression object
eset <- rma(affyRaw)
#Further normalized data.
normalized_data <- exprs(eset)
#list the analyzed file names
pData(eset)
#set up design and matrix for MA Plots
design <- model.matrix(~ 0+factor(c(1,1,1,2,2,2,3,3,3,4,4,4)))
colnames(design) <- c("group1", "group2", "group3", "group4")
fit <- lmFit(normalized_data, design)
contrast.matrix <- makeContrasts(group2-group1, group3-group1, group4-group1, levels=design)
fit2 <- contrasts.fit(fit, contrast.matrix)
fit2 <- eBayes(fit2)
results_ctrl_and_7w <- topTable(fit2, coef=1, adjust="BH", number=Inf)
results_ctrl_and_13w <- topTable(fit2, coef=2, adjust="BH", number=Inf)
results_ctrl_and_22w <- topTable(fit2, coef=3, adjust="BH", number=Inf)
write.table(results_ctrl_and_7w,"results_ctrl_and_7w.txt",sep="\t")
write.table(results_ctrl_and_13w,"results_ctrl_and_13w.txt",sep="\t")
write.table(results_ctrl_and_22w,"results_ctrl_and_22w.txt",sep="\t")
#MAplot
pdf("MAplot 7 week old Mouse Pancreas Expression.pdf")
plot(results_ctrl_and_7w$AveExpr,results_ctrl_and_7w$logFC,pch=20,xlab="Average log2(Intensity)",ylab="log2(Fold Change)",
main="Gene Expression in 7 week old Mouse Pancreas")
abline(h = c(-1, 1), col="blue")
abline(h = c(0), col="black")
dev.off()
I did not include all 3 MA plots because they should be all the same alteration.
The second thing I want to do is to write a data table for those points with their cooresponding data so I can merge that with a biomart annotation file and come up with a list of candidate genes, and use that to produce a heatmap. The heatmap I can do, but I am not quite sure how to pull the subset of data I want from the results.
Thank you far any suggestions/help.