This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to Remove Sample Names from Heatmap

Hi there,

I constructed a heatmap to display the results of my differential expression analysis through the Heatmap function from the ComplexHeatmap package. As I have many samples (400+) the sample names are unreadable and therefore I would just like to remove them so the visualization is a bit easier to understand. Is there a way to just get rid of the sample names, I tried a few different things like setting show_row_ names = false but it didn't change anything. I have attached an image for how it looks right nowenter image description here

heatmap complexheatmap

use show_column_names = FALSE

enter image description hereThank you! It now shows up like this, do you know how I can get the gene names to appear on the right side cleanly? There are only 20 genes so I want to make it readable. Removing the numbers might help, I think those show the expression value but not sure

Try:

png("test.png", width=12, height = 4, units="in",res=300)
Your heatmap code here......
dev.off()

Change width and height to get the plot appropriately

Thank you. I adjusted the dimensions and it makes it look better. However, on the right side, the gene symbol seems to be overlapping with the number. Is this due to a setting, I can't seem to fix it by adjusting the dimensions.

1 answer

Try the following way

mat = matrix(rnorm(80, 2), 8, 10)
mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
rownames(mat) = letters[1:12]
colnames(mat) = letters[1:10]

Then

Heatmap(mat, show_column_names = FALSE)

output

To save the plot:

png("heatmap_test.png", width=12, height = 4, units="in", res=300)
Heatmap(mat, show_column_names = FALSE)
dev.off()

or

 png("heatmap_test.png", width=12, height = 4, units="in", res=300)
 ht <- Heatmap(mat, show_column_names = FALSE)
 draw(ht)
 dev.off()

Log in to answer this question.