I have these two plots (a heatmap and a stacked barplot). How can I put these plots near each other? Indeed I want to integrate these two plots.
Thanks for any help.
Here is my script:
df.bar <- data.frame(Gene.name=c('Gene1','Gene1','Gene1','Gene2','Gene2','Gene2','Gene3','Gene3','Gene3',
'Gene4','Gene4','Gene4'),
Alteration.frequency=c(0.0909, 2.1838, 0.6369, 0.1819, 1.0919, 0.3639, 0.4549,0.7279,
0.7279, 0.000, 0.3639, 0.4549),
Alteration.Type=c("Deep deletion", "Amplification", "Point mutation", "Deep deletion",
"Amplification", "Point mutation", "Deep deletion", "Amplification" ,
"Point mutation", "Deep deletion", "Amplification" , "Point mutation"))
library(ggplot2)
ggplot(df.bar,
aes(fill=factor(Alteration.Type, levels = c('Point mutation','Amplification','Deep deletion')),
y=Alteration.frequency, x=Gene.name)) +
geom_bar(position="stack", stat="identity")+theme_bw()+
theme(axis.text.x = element_text(size = 10, angle = 45, hjust = 1, colour = 'black'))+
scale_fill_manual(values=c("seagreen2", "maroon2",'deepskyblue3'))+
labs(fill = 'Alteration type')
df.heatmap <- data.frame(Gene_name=c('Gene1','Gene2','Gene3','Gene4'),
log2FC=c(0.56,-1.5,-0.8,2))
library(gplots)
heatmap.2(cbind(df.heatmap$log2FC, df.heatmap$log2FC), trace="n", Colv = NA,
dendrogram = "none", labCol = "", labRow = df$Gene_name, cexRow = 0.75,
col=my_palette)
I need such this plot.