R Language - How to Create Pheatmap Chart in R

avatar

In this post, we take a look at How to Create Pheatmap Chart in R. This chart is often used by the people who are into the analytics and the people who are trying to find out the psychology behind the web page clicks. So this is handy chart.

Previously we looked at how to create the waffle chart. That chart was something a lot of people wanted to do because it was like githubs progress chart. Now here we are going to be trying out one of the variation of the heatmap. So slight change in the heatmap variation there.

Rstudio is the tool I am using for plotting the pheatmap. This would bea good idea for you compared to using the command line of the R terminal for the plots. So use the rstudio if you are planning on making the chart.

I have created a video to give you an overview on How to Create Pheatmap Chart in R. You should give this one a try.



For this library you may want to make use of the pheatmap library. You have to install the package and then make sure to use the package for the calling the libarary.

install.packages("pheatmap")
library(pheatmap)

You can see the Rstudio after this action like this.

rs.png

Now once installed you are good to go for making the data for this chart. So let's focus on that part.

set.seed(8)
m <- matrix(rnorm(200), 10, 10)
colnames(m) <- paste("Col", 1:10)
rownames(m) <- paste("Row", 1:10)

This would be making use of the seed and also the column and row each 1x10. So that would be a good start for you to work with.

Now let's draw the chart using below code.

pheatmap(m)

Now take a look at the chart output below.

ph.png

As you can see this is one chart where you would have the dendrogram too. I'd be going in the detail about these in next tutorial. But for now look at the values and also the legend. So you get the gradient color for the legends too.

That's it. You get the idea on how to draw the pheatmap. Now it's time to do more customization and you would be able to get more points and changes. Like even the orientation of the label is something you would make things cool. I'd say you should check out the those custom changes through documentation.

Now I have managed to do some of the changes in the pheatmap with say legend colors etc. I can say you should experiment too. Because it'd be more cool based on your data. You can also find some test data on the kaggle. Like this you have option to plot different variations of this plot.

Once I am done with the datasets and library tutorials, I'd be moving onto the Rstudio tutorials for the cloud too. Because that is something we have not much explored here as well. So that's one of the things that I have plans to explore with the R packages.

Next in the tutorial series are - dendrogram and CalendR plots. So the plots I have few more in the pipeline. I think Power BI cloud and desktop is something I would going ahead with this year because I have some data connectors to cover as well.

If you happen to like this content, do give me feedback over there and that would help me improve my efforts in near future.



0
0
0.000
4 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000
avatar

thanks for bringing that tutorial! this library is very important to do heatmaps
!1UP

0
0
0.000