Generation of Heatmaps from Microarray Data (KEGG2heatmap or GO2heatmap)

From Bridges Lab Protocols
Jump to: navigation, search

From Bioconductor mailing list (Saurin D. Jani" <saurin_jani@yahoo.com>)

# Input: expression matrix, chip environments
# output: heatmaps of all the pathways for all the genes in expression matrix

#About Pathway to HEATMAP

# Variable explanation:

# esetSub2 = expression matirx
# esetSub2X = exprs(esetSub2)
# chiptype = annotation found from GeneChip, here 'hgu95a'
# envPath2Probes = Environment
# e.g.
# envGeneNames <- hgu95aGENENAME;
# envPath2Probes <- hgu95aPATH2PROBE;


# Generate Pathway Heatmap
? All_DE_Pathway <- aafPathway(featureNames(esetSub2), chiptype);
? unique(sapply(All_DE_Pathway, length));
? pathlist <- do.call("c", All_DE_Pathway);
? pathL <- length(pathlist);
? pathmatrix <- sapply(pathlist, attributes);
? pathnamesX <- unique(t(pathmatrix));
? kegg <- as.list(envPath2Probes);
? pathRow <-? as.numeric(nrow(pathnamesX));
? if(pathL >=1)
? {
??? for(i in 1:pathRow)
??? {
????? pathID <- pathnamesX[,"id"][i];
????? pathID <- as.character(unlist(pathID));

????? pathName <- as.character(unlist(pathnamesX[,"name"][i]));
????? pathName <- trimWhiteSpace(pathName);
????? pathName <- sub("/", "_", pathName);
????? pathName <- sub(" ", "_", pathName);
????? pathName <- sub("? ", "_", pathName);
????? pathName <- sub("?? ", "_", pathName);
????? pathName <- sub(" ", "_", pathName);
????? pathName <- sub("-", "_", pathName);
????? pathFile <- paste("Pathway",pathName,".jpeg",sep = "_");
????? pathSub <- paste(pathName,"Legend: Red = High, Blue = Low, White =
Medium",sep = "? ");
????? pathSub <- paste("Date of Analysis:",date(),pathSub,sep = "? ");

????? Pathway2Heatmap(pathID,pathFile,pathSub); # check out the function below
??? }

? } # if ends here
#

###########################################################
Pathway2Heatmap <- function(pathway,file,Hsub)
{

? kegg <- as.list(envPath2Probes);
? pathProbes <- as.matrix(kegg[[pathway]]); # genes extracted from pathway
? esetSub2Genes <- as.matrix(featureNames(esetSub2));

? temp <- as.matrix(rbind(unique(esetSub2Genes),unique(pathProbes)));
? temp1 <- as.matrix(temp[ as.matrix(duplicated(temp,))]);

? exp2 <- esetSub2[temp1];
? exp2X <-? exprs(exp2);

? pathDEGenes <- as.matrix(featureNames(exp2));
? pathDEGeneNames <- mget(unique(pathDEGenes),env = envGeneNames,ifnotfound="No
Annotation For this Probe");

? row.names(exp2X) <- pathDEGeneNames;
? colnames(exp2X) <- samples;

? if (nrow(exp2X) > 1)
? {
??? jpeg(filename= file,width=2000,height=2000);
??? row.dist <- as.dist(1 - cor(t(exp2X)));
??? Hsub <- c("Generated by EXAMPLE");
??? gmpalette <- bluered(64);

heatmap.2(exp2X,col=gmpalette,Colv= FALSE,Rowv =
as.dendrogram(hclust(row.dist,method="centroid")),scale="row",key=TRUE,keysize=0.60,symkey=FALSE,density.info="none",trace="none",margins=c(5,85),cexRow=1,cexCol=1,
sub=Hsub,cex.sub=1);

dev.off(which = dev.cur());

??? print("Pathway Heat map done");
? }#if

####
?if(nrow(exp2X) == 1)
? {

? dotchart(exp2X);
? p_t <- paste(Hsub,"Gene:",pathDEGeneNames,sep = " ");
? title(sub = p_t,cex.sub = 1);
? dev.off();
?}
#####

}#pathway2heatmap