Hi all,
I am experiencing an issue with my heatmap. When I draw a heatmap with row annotations, my row names disappear. I can restore the row names by removing the annotations, but nothing else seems to cause the issue. Here is the heatmap call and draw function:
Wx1 <- Heatmap(Cx[[i]][[1]],
show_row_names=F, column_names_gp=gpar(fontsize=8),
clustering_distance_rows = distr,clustering_method_rows = method,
name="Log10Dunn",row_title=paste("C",i," - Percent and Dunn-Pvals"),col=cf2,
cluster_rows = cluster_within_group(t(Cx[[i]]
[[2]]), group), row_split = 6, border = TRUE)
cids <- column_order(Wx1);
Wx2 <- Heatmap(Cx[[i]][[2]][,cids],
show_row_names=T, row_names_gp=gpar(fontsize=8), column_names_gp=gpar(fontsize=8),
cluster_columns=FALSE, clustering_distance_rows = distr,
clustering_method_rows = method, name="Z-scores",row_title=paste("Heatmap C",i, sep=''),
col=cf, cluster_rows = cluster_within_group(t(Cx[[i]][[1]]), group), row_split = 6, border = TRUE)
draw(Wx1+Wx2+row_annotation)
dev.off();
Cx is the object that contains my matrices, and row_annotation is a Formal class HeatmapAnnotation object. The following code will produce my heatmaps side-by-side and the row annotation on the far right, followed by the legend. There are no labels for rows, yet I know the data exists because draw(Wx1+Wx2) restores the row labels next to the right heatmap. I've tried changing the margins, changing the order of things, setting show_row_names to true or false, and visualizing the output in RStudio's Plots window (instead of the PDF export currently used) to no avail.
Is there anything about annotations that can hide row names by default? If so, how do I force them to show up?
Thanks for taking the time to read!
Thank you! 'ht + rowAnnotation(rn = anno_text(rownames(mat)))' gave me the exact output I was looking for.