Last active
April 1, 2016 18:38
-
-
Save maromato/7ff576471531be61e556 to your computer and use it in GitHub Desktop.
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
pc <- c(65,51,29,75,50,1,70,47,37,36,45,44,57,66,60,71,40,39,34,21,27,17,43,19,49,88,58,55,30,18,64,74,72,63,26,22,28,52,35,23,68,41,62,24)#define the columns that you are interested in | |
t1 <- y[obj,pc]#making group1 | |
t2 <- y[obj,-pc]#making group2 | |
t <- cbind(t1,t2) | |
#define the comparison | |
c <- c(rep(1,44),rep(0,52)) | |
d <- c(rep(0,44),rep(1,52)) | |
design = cbind(Cell_A = c, Cell_B = d) | |
contrastsMatrix = makeContrasts("Cell_B-Cell_A",levels = design)# We want to compare A vs. B, A vs. C and B vs. C | |
#comparison of the levels of the genes between group 1 and 2 | |
library(limma) | |
fit = lmFit(t,design=design) | |
fit2 = contrasts.fit(fit, contrasts = contrastsMatrix) | |
out = eBayes(fit2) | |
p.value = out$p.value #to put p.values for indevisual genes into the vector, p.value | |
q.value = apply(p.value, MARGIN=2, p.adjust, method="BH") | |
ranking = apply(p.value, MARGIN=2, rank)#to put the ranking for indevisual genes in term of p.value into the vector, ranking | |
#making the table for the results | |
tmp = cbind(t, p.value, q.value, ranking) | |
#making the heatmap for top 60 differentially expressed genes | |
ob = rank(tmp[,ncol(tmp)-2])< 65 | |
tmp3 = tmp[ob,] | |
library(gplots) | |
z = tmp[,1:96] | |
heatmap.2(as.matrix(z), col=greenred(75), scale="row", key=T, keysize=1.5,density.info="none", trace="none",cexCol=0.9, cexRow=0.5) | |
z = tmp3[,1:96] | |
heatmap.2(as.matrix(z), col=greenred(75), scale="row", key=T, keysize=1.5,density.info="none", trace="none",cexCol=0.9, cexRow=0.5) | |
write.table(tmp,file="output.txt",sep="\t") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment