Heatmap of two conditions from the normalized gene count data
1
0
Entering edit mode
Amazing570 • 0
@1841e218
Last seen 22 months ago
United States

I created a heatmap of two conditions (Inoculated and Mock control) and two genotypes (Resistant and susceptible), so there are 4 treatments in the column and in the rows there are shared genes with normalized expression data. In the heatmap, my mock treatments from both genotypes are clustered together, while inoculated treatments are clustered together for both genotypes. I want to cluster one genotypes mock and inoculated treatment (side by side). How can I change the following code to get the desired results? TIA.



data <- read.csv("R&S_heatmap.csv")
rnames <- data[,1]                            
mat_data <- data.matrix(data[,2:ncol(data)]) 
rownames(mat_data) <- rnames                  
# creates a own color palette from red to green
my_palette <- colorRampPalette(c("white", "red", "green"))(n = 299)

# creates a 5 x 5 inch image
png("h2_default_clustering.png",
    width = 5*250,        
    height = 5*250,
    res = 300,            
    pointsize = 2)        
row_distance = dist(mat_data, method = "manhattan")
row_cluster = hclust(row_distance, method = "ward.D")
col_distance = dist(t(mat_data), method = "manhattan")
col_cluster = hclust(col_distance, method = "ward.D")

heatmap.2(mat_data,
          cellnote = mat_data,  
          main = "Gene Expression", 
          notecol = "black",      
          density.info = "none",  
          trace = "none",        
          margins = c(30,25),    
          col = my_palette,       
          Rowv = as.dendrogram(row_cluster), 
          Colv = as.dendrogram(col_cluster))
GeneExpression heatmaps • 890 views
ADD COMMENT
0
Entering edit mode
ATpoint ★ 4.6k
@atpoint-13662
Last seen 8 hours ago
Germany

This is not a Bioconductor package. In brief, if you want hand-made order of rows and columns then don't cluster them but add a specific order to the respective parameter in the function. See the manuals for it, check for xample the Bioconductor package ComplexHeatmap which has an extensive manual with much example code.

ADD COMMENT

Login before adding your answer.

Traffic: 356 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6