This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to show only highly clustered genes in a heatmap, and the rest will hide

Hello all,

I have done the correlation analysis between the genes at a particular condition and now am trying to plot a heatmap through complexheatmap, but the problem is that i have 270 genes and when i am trying to plot the heatmap keeping the option "show_row_names = TRUE" , it is showing all the genes in the plot and it is really hard to visualize, so, i want to show the only highly correlated genes in heatmap and hide all others .

Any suggestion would be really helpful.

r complexheatmap

1 answer

You could try setting the row_labels option to only the labels you want like this:

Heatmap(..., row_labels = ..., show_row_names = TRUE)

Alternatively, you could turn off row names and add only the labels you want using row annotations. Maybe something like this:

Heatmap(..., show_row_names = FALSE) + rowAnnotation(labels = ...)

But I have one query, row_labels seems to work manually, which means I have to manually put the names of each gene by seeing the plot. Couldn't it be possible that complexheatmap automatically shows the name of only highly correlated genes and hide all other gene names from the rows

Also, I have to change the row clustering order of the plot. Suppose out of 270 genes, I want to show only the top 50 correlated genes in my heatmap then how can I do this as clustering is according to 270, not to 50. Even if I manually put the names of top 50 genes using row_labels, then how to arrange the plot according to row_labels

In this case, just subset the data you feed to Heatmap() so that it only contains the genes of interest. Otherwise see if this solution works for you.

You can programmatically generate the labels vector by keeping some genes in it and putting an empty strings where you don't want a gene.

Log in to answer this question.