Question: creating a heatmap with R and retrieve cluster data from dendogram
gravatar for sharmatina189059
22 months ago by
United States
sharmatina18905940 wrote:

Dear all I have drug resistance profile of 100 bacterial genomes. The data is like

Antibiotic name  ab1 ab2 ab3 ab4 ab5
genome1 S R S R S
genome2 R S S R
genome3 R S S R

I want to generate a R plot. the code for generating a R plot is like:

data <- read.csv("/Users/apple/Desktop/heatmap.csv", sep=",")
rnames <- data[,1]
mat_data <- data.matrix(data[,2:ncol(data)])
rownames(mat_data) <- rnames
my_palette <- colorRampPalette(c("red", "yellow", "green"))(n = 299)
col_breaks = c(seq(-1,0,length=100), # for red
+ seq(0,0.8,length=100),  # for yellow
+ seq(0.81,1,length=100)) # for green

+ main = "Drug Resistance profile",
+ notecol="red",
+ trace="none",
+ margins = c(20,15),
+ col=my_palette,
+ dendogram="row",
+ Colv="NA")

but this code produces a very dense margin on rows labels. Can anyone tell me how to modify this plot to make it visualize to all. also tell me how can I change the color of the plot as well as is there other way to represent this data like how to represent data in a circular way in a heatmap.

R • 2.1k views
ADD COMMENTlink modified 22 months ago by EagleEye6.5k • written 22 months ago by sharmatina18905940

Add the heatmap image so that we can actually see the issue

ADD REPLYlink written 22 months ago by lakhujanivijay4.5k

Please tell me how to upload pic in this forum

ADD REPLYlink written 22 months ago by sharmatina18905940
gravatar for Kevin Blighe
22 months ago by
Kevin Blighe50k
Kevin Blighe50k wrote:

The 'dense' margin appears because your margin sizes are enormous through the following parameter: margins = c(20,15) In any normal situation, this should only be margins=c(5,5)

To represent this as a circular dendrogram, look here: A: how to draw circular dendrogram with distance information

For other 'circular' ideas and for how to colour various dendrogram branches, take a look at the dendextend package: Introduction to dendextend

For extracting cluster information from either heatmap.2 or pheatmap, take a look here: A: extract dendrogram cluster from pheatmap

ADD COMMENTlink modified 22 months ago • written 22 months ago by Kevin Blighe50k
gravatar for EagleEye
22 months ago by
EagleEye6.5k wrote:

For extracting clusters from generated heatmap/dendogram check this previous post.

ADD COMMENTlink written 22 months ago by EagleEye6.5k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2358 users visited in the last hour