# Molecular heterogeneity in major urinary proteins of Mus musculus subspecies: potential candidates involved in speciation # Jane L Hurst, Robert J Beynon, Stuart D Armstrong, Amanda J Davidson, Sarah A Roberts, Guadalupe Gómez-Baena, Carole M Smadja, Guila Ganem # #METHOD : SCALE ON LOG DATA #Copy data from clipboard in Mac OS X data <- read.delim(pipe("pbpaste"), header=TRUE) #If not already installed #install.packages("gplots") #install.packages("devtools") #Load necessary packages library("gplots") library("devtools") library("RColorBrewer") #Load latest version of heatmap.3 function source_url("https://raw.githubusercontent.com/obigriffith/biostar-tutorials/master/Heatmaps/heatmap.3.R") #Load the data data1<-data[,19:32] rownames=data$Sample matrix<-data.matrix(data1) #Create color side bars Species_colors=c("brown2","blue") gcol1=Species_colors[data$subspecies+1] Sex_colors=c("lightpink","lightskyblue") gcol2=Sex_colors[data$sex+1] Area_colors=c("springgreen4","yellow2") gcol3=Area_colors[data$zone+1] Population_colors=colorRampPalette(brewer.pal(n = 11, "Spectral"))(15) gcol4=Population_colors[data$Pop] rlab=t(cbind(gcol1,gcol2,gcol3)) rownames(rlab)=c("Subspecies","Sex","Zone") pal <- colorRampPalette(c("black", "green")) #Define custom dist and hclust functions for use with heatmaps mydist=function(c) {dist(c,method="euclidian")} myclust=function(c) {hclust(c,method="median")} #Create heatmap using custom heatmap.3 source code loaded above heatmap.3(matrix, hclustfun=myclust, distfun=mydist, na.rm = TRUE, scale="none", dendrogram="both", Rowv=TRUE, RowSideColors=rlab, symbreaks=FALSE, key=TRUE, symkey=FALSE, density.info="none", trace="none", labCol=NULL, labRow=data$Sample, cexRow=0.5, col=colorRampPalette(brewer.pal(n = 9, "Oranges"))(100), RowSideColorsSize=4, KeyValueName= "Relative proportion")