OK. Thanks Manu, but this is not the point. I got my diff expressed genes, and I know to build the heatmap. The problem is that I have my R and S samples distributed in different channels and what I want to see is my heatmap of R and S, maybe I was no clear at this point, not see how A,B and C (arrays) are clustering
Hi, I have an Agilent Dye Swap experiment, two colors, where I have my samples Resistant and Sensible
Distributed like this (this is my targets.txt file)
SampleNumber FileName Cy3 Cy5
1 A.txt S R
2 B.txt R S
3 C.txt S R
4 D.txt R S
5 E.txt S R
6 F.txt R S
7 B1.txt R S
8 C1.txt S R
9 D1.txt R S
10 E1.txt S R
11 F1.txt R S
I analyzed the data using the nex code
library(limma)
targets <- readTargets("targets_all.txt")
RG <- read.maimages(targets,source="agilent.median")
RG <- backgroundCorrect(RG, method="normexp", offset=16)
MA <- normalizeWithinArrays(RG, method="loess")
MA.avg <- avereps(MA, ID=MA$genes$ProbeName)
design <- modelMatrix(targets, ref="S")
fit2 <- eBayes(fit)
output <- topTable(fit2, adjust="fdr", coef="R", number=nrow(fit2), genelist=MA.avg$genes)
genes_diff_expr.005<- subset(output,output$adj.P.Val < 0.05)
pdf("heatmap_diff_exprs_R_S.pdf")
heatmap.2(MA$M[rownames(MA$M) %in% genes_diff_expr.005$ProbeName,], trace="none", col=greenred(10),cexRow=0.2,labRow=NA,cexCol=0.7)
dev.off()
Now, I want to see how my samples cluster for this signature. I've been doing so many heatmaps in years, mainly using Affymetrix or Agilent one color experiments, but I don't know how to use to plot all the samples distributed in the two channels (R). Using MA$M, I got the log2ratios, the point is that the name of my columns are as in targets A,B,C and so on, and I want R or S, but distributed in two channels I don't know how to specify which is sensible or resistant
any ideas?
Thanks in advance
1 answer
Draw a boxplot to ensure that "MA" is normalized
Make your rownames as gene_ID or probe ID of the data "MA"
############################ calculating top differentially expressed genes PS: you can choose the number in percentage,
#depends what fraction of genes you want to consider in R, please have this libraries if you don't have
## analysis starts from here
library(genefilter)
percentage<-c(0.990)
sds<-rowSds(MA)
sel<-(sds>quantile(sds,percentage))
set<-MA[sel, ]
distmeth<-c("euclidian")
D<-dist(t(set), method=distmeth)
treemeth<-c("average")
hc<-hclust(D, method=treemeth)
############### clustering
plot(hc)
######## for heatmap
library(gplots)
library(RColorBrewer)
hr <- hclust(as.dist(1-cor(t(set), method="pearson")), method="centroid");
hc <- hclust(as.dist(1-cor(set, method="spearman")), method="centroid")
# Cuts the tree and creates color vector for clusters.
mycl <- cutree(hr,k=4, h=max(hr$height)/1.5);
mycolhc <- rainbow(length(unique(mycl)), start=0.1, end=0.9); mycolhc <- mycolhc[as.vector(mycl)] ; myheatcol <- bluered(75)
heatmap.2(as.matrix(set), Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc), col=myheatcol, scale="row", density.info="none", trace="none", RowSideColors=mycolhc,cexRow=1.5, cexCol=1.5, keysize=1,margins=c(12,10))
How did you solve your problem? Thanks!
Log in to answer this question.