Take a look at these similar posts with solutions on stackoverflow and bioconductor
cluster_cols=FALSE is the way to go
Hi everyone,
I have a very basic question that I can't get over it :D
I am plotting a heatmap using pheatmap function in R and clustering columns with the option cluster_cols = T. the resulting picture is like below. However, I want the column 1 to be at the right side of the plot, next to gene labels. is there any function in R that allows me to to that? Or does pheatmap has any option for this?
this is my code:
ph.breaks <- seq(from = -8.1, to = 12, length.out = 101)
ph.cols <- colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(100)
pdf(paste0(fig_name , "_withLFC_main.pdf"), width = 6.25 , height = 20)
print(pheatmap(t, cluster_cols = T , show_colnames = T,
fontsize_row = 28 , fontsize_col = 20 , cluster_rows = T, fontsize = 20 , legend = T
, annotation_legend = T , angle_col = 315 , na_col="#800080" , breaks = ph.breaks) )
dev.off()
graphics.off()
Thank you in advance.
This is because your samples are being clustered and the order is dictated by the dendrogram. If you change it to cluster_cols = FALSE you can set the order of the columns.
Take a look at these similar posts with solutions on stackoverflow and bioconductor
cluster_cols=FALSE is the way to go
Thanks a lot! I appreciate it.
Log in to answer this question.
Show us your code please. In the meantime, try this:
I tried that, It still results in the same exact plot, Unfortunately,
Thanks, I edited and added my code.
Have a look at this answer on stackoverflow
Thank you very much!