How to reassign the orientation of clusters in pheatmap
1
0
Entering edit mode
4 months ago
Meghan.T • 0

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.

enter image description here

R pheatmap heatmap • 813 views
ADD COMMENT
2
Entering edit mode

Have a look at this answer on stackoverflow

ADD REPLY
0
Entering edit mode

Thank you very much!

ADD REPLY
0
Entering edit mode

Show us your code please. In the meantime, try this:

# Let's say df is the data object you're plotting using pheatmap(df, ...)
# Try this
pheatmap(df[,4:1], ...)
ADD REPLY
0
Entering edit mode

I tried that, It still results in the same exact plot, Unfortunately,

ADD REPLY
0
Entering edit mode

Thanks, I edited and added my code.

ADD REPLY
1
Entering edit mode
4 months ago
Trivas ★ 1.8k

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.

ADD COMMENT
2
Entering edit mode

Take a look at these similar posts with solutions on stackoverflow and bioconductor

cluster_cols=FALSE is the way to go

ADD REPLY
0
Entering edit mode

Thanks a lot! I appreciate it.

ADD REPLY

Login before adding your answer.

Traffic: 2014 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6