This is a test version of Biostars. For the public version, visit https://www.biostars.org.
pheatmap

Hi All,

I made a heat map to show the top 25 significant differentially expressed genes. I would like to make some changes in my heatmap but I couldn't find how to do it, may you please provide me with some solutions please?

Here is the code that I used:

select<- resOrdered$ENSEMBL[1:25] #selected the 25 most significant genes
toplot<- assay(vsd)[select,]  #retreived the vst values for selected genes
rownames(toplot) <- resOrdered$SYMBOL[1:25] #defined the gene symbol
df <- as.data.frame(colData(vsd)["condition"])
ann_colors<- list(condition=c(OE="red", WT="blue"))

pheatmap(toplot,annotation_col = df, annotation_colors = ann_colors,
         scale = "row", border_color = "transparent",
         cutree_cols = 2, cutree_rows = 2,fontsize = 7,
         color = colorRampPalette(c("blue","white","red"))(50))

here is my heatmap

enter image description here

in a row is the name of the genes that I covered, and the column is the name of the sample group by WT and OE.

I want to show WT condition on the left of my plot and, next to it OE condition. exactly the invert one of that already is. but I couldn't figure out how.

I appreciate any solutions please.

pheatmap heatmap differential-expression rna-seq

2 answers

Can you please try this? I have not tested it but it should work.

install.packages("seriation")
install.packages("dendextend")

library(seriation)
library(dendextend)    

phtmap <- pheatmap(toplot,annotation_col = df, annotation_colors = ann_colors,
             scale = "row", border_color = "transparent",
             cutree_cols = 2, cutree_rows = 2,fontsize = 7,
             color = colorRampPalette(c("blue","white","red"))(50))
col_dend =phtmap[[2]]
col_dend <- rotate(col_dend, order = rev(colnames(toplot)[get_order(col_dend)]))

pheatmap(toplot,annotation_col = df, annotation_colors = ann_colors,
             scale = "row", border_color = "transparent",
             cutree_cols = 2, cutree_rows = 2,fontsize = 7, cluster_cols = as.hclust(col_dend),
             color = colorRampPalette(c("blue","white","red"))(50))

Hi, you could maybe try releveling the factor when you define them in your coldata, because otherwise it's alphabetic:

colData$condition <- factor(colData$condition, levels = c("WT", "OE"))

And then run the heatmap as is.

Thank you for your comment, but it did not help!

Log in to answer this question.