0

I'm trying to use geom_tile to plot a heatmap.

Sample data. And the code is as follow:

#define color
library(wesanderson)
pal <- wes_palette("Zissou1", 50, type = "continuous")
                          
b<- ggplot(C1.TN)
d<- b + 
  geom_tile(aes(x=Combination, y=Drug_dose, fill=Avg.percent))+
  geom_text(aes(x=Combination, y=Drug_dose,label=Avg.percent), size=3)+
  scale_fill_gradientn(colors=pal)+
  theme(legend.text = element_text(size=10, face="bold", color = "black"))+
  theme(axis.text.x = element_text(size = 15,  face="bold", color = "black")) +
  theme(axis.text.y = element_text(size = 9,  face="bold", color = "black")) +
  theme(axis.title.x = element_text(size = 15,  face="bold", color = "black", vjust = 3))+
  theme(axis.title.y = element_text(size = 15,  face="bold", color = "black", hjust = 0.5))+
  theme(plot.title = element_text(size = 16))+
  theme(strip.text.y  = element_text(size = 10, face = "bold", color = "black"))+
  scale_x_discrete(position ="top") +
  xlab("Combination added")+
  ylab("Treatments in the screen")+
  ggtitle("Cluster 1 Enriched in TN response")


  print(d)

Here is the figure output

enter image description here

The issue is I want each band to be bigger in width and height so everything is clear and readble.

I have tried to set height and width in geom_tile

 geom_tile(aes(x=Combination, y=Drug_dose, fill=Avg.percent, height=3))+

but the problem is then my y axis treatment label will be off alignment. Same problem if I change the width, then my x axis column names are completely off alignment. enter image description here

So how can I change the size of the each tile to make it bigger, while maintain the aligment of my axis labels? Preferably I wan to also adjust the spacing of y axis labels.

Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32
ML33M
  • 341
  • 2
  • 19
  • The problem is simply that you don't have enough space on the screen to show this plot. If I enlarge the plot to the size of my screen the numbers are small and cramped. Even if you have a large screen with 1400 pixels vertically, around 1200 of them will be devoted to the panel itself, and since there are 84 rows, you will have about 14 pixels of height to try to draw nicely spaced and legible text. It's simply not going to happen. Even if this was printed on a large poster so it became legible, it is still a cumbersome way to present the data. You need to rethink how to present this. – Allan Cameron Nov 03 '20 at 20:14
  • I see. yes, this is a summary of the treatment used. The finale take home will be breaking this apart by different drug classes. Thank you Allan – ML33M Nov 03 '20 at 20:18
  • yes, I think breaking it into drug classes would make for an appealling and informative presentation. – Allan Cameron Nov 03 '20 at 20:23
  • @AllanCameron sorry but could I ask if there's anyway I can plot this map with an order. I know it looks horrible for a summary. But I'm thinking by the given long form data, can I arrange this ggplot in a way that all treatments are ranked in a descending order by the percentage number in the "none" column. So at least from the summary I can easily see what treatment on its own /"none" is above DMSO. Then I can proceed to later filtering – ML33M Nov 03 '20 at 20:39

0 Answers0