Question: How To Plot Heatmap With Multiple Categories In A Single Cell With Ggplot2?
4
gravatar for Gahoo
5.9 years ago by
Gahoo260
United States
Gahoo260 wrote:

How to plot heatmap with multiple categories in a single cell with ggplot2? Heatmap plot of categorical variables could be done with this code

#data 
datf <- data.frame(indv=factor(paste("ID", 1:20),
    levels =rev(paste("ID", 1:20))), matrix(sample(LETTERS[1:7], 400, T), ncol = 20))



library(ggplot2); 
library(reshape2)
# converting data to long form for ggplot2 use

datf1 <- melt(datf, id.var = 'indv')

ggplot(datf1, aes(variable, indv)) + geom_tile(aes(fill = value),
   colour = "white")  +   scale_fill_manual(values= rainbow (7))

The codes came from here: http://rgraphgallery.blogspot.com/2013/04/rg54-heatmap-plot-of-categorical.html

But what about multiple categories in a single cell like this? Is it possible to use triangle or other shape as a cell?

http://postimg.org/image/4dudrv0nz/

http://postimg.org/image/4dudrv0nz/

R heatmap • 5.6k views
ADD COMMENTlink modified 4.9 years ago by konstantinkul90 • written 5.9 years ago by Gahoo260

It interesting task does anybody figure out how to do it ????

ADD REPLYlink written 4.9 years ago by konstantinkul90
0
gravatar for Alex Reynolds
5.9 years ago by
Alex Reynolds29k
Seattle, WA USA
Alex Reynolds29k wrote:

Take a look at geom_polygon.

ADD COMMENTlink written 5.9 years ago by Alex Reynolds29k

I've thought of that. But I don't know how to properly caclulate the correct coordinates of ploygon points. I prefer to write a function works like geom_tile using geom_polygon which can solve coordinates automatically.

ADD REPLYlink written 5.9 years ago by Gahoo260

Your question is probably more likely to get a useful answer on Stack Overflow. I think the ggplot2 developer hangs out there.

ADD REPLYlink modified 5.9 years ago • written 5.9 years ago by Alex Reynolds29k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 780 users visited in the last hour