raivokolde / pheatmap

Pretty heatmaps
234 stars 83 forks source link

Unable to rotate column labels #20

Open komalsrathi opened 8 years ago

komalsrathi commented 8 years ago

Hi,

Here is my code:

pheatmap(mat, display_numbers = T, scale = 'row',clustering_distance_rows = 'correlation', main = "Differentially Expressed Genes\n", cellwidth = 70 , cellheight = 10)

This is the result: rplot02

But my column names are too long and I'd like to rotate them by say 45 degrees. Is that possible?

Thanks!

Ihmor commented 8 years ago

I've got the same issue. It seems that pheatmap is the only plotting package that rotates the lables by 270° than by 90° ;)

If dublicated draw_colnames as draw_colnames_90 with my preferred values. But that's obviously an ugly hack. It would be great, if the rot value could be a separate parameter to call in pheatmap() itself. But I can't provide a comprehensive code proposition...

Here the hack: change "elem = do.call(draw_colnames, pars)" to "elem = do.call(draw_colnames_90, pars)" and add the following function:

draw_colnames_90 = function(coln, gaps, ...){ coord = find_coordinates(length(coln), gaps) x = coord$coord - 0.5 * coord$size

res = textGrob(coln, x = x, y = unit(1, "npc") - unit(3, "bigpts"), vjust = 0.5, hjust = 1, rot = 90, gp = gpar(...))

return(res)

}

jdreyf commented 6 years ago

It looks like pull #23 provided an implementation of this but the branch hasn't been merged. @raivokolde Are you thinking of incorporating these changes?

pheatmap is really nice, thanks.

saeedfc commented 4 years ago

Hi, Maybe try a work around by breaking the lines if that serves the purpose?

labelscol <- mgsub::mgsub(colnames(mat), pattern = c("Sample", "MEP_"), replacement = c("Sample\n", "MEP\n"))

meshik commented 2 years ago

Has an implementation been introduced to the package? I would love to rotate my x labels.