Section 4 Figure 1
We now start assemblying the main Figures of the paper, with all the data and the informations coming from the different analysis. As a first step we clear the workspace from all the current variable.
#Clean workspace
rm(list = ls())And then we load back all the different dataframe in order, to avoid that some specific variable could be overwritten.
#load the 2 workspaces
load("../Markdown/workspaces/02-Paralogs_AlongTissues_CompleteWorkspace.RData")
load("../Markdown/workspaces/01-Paralogs_RNASeqData_CompleteWorkspace.RData")As a first step we create a panel for the GOEnrichment coming from the different dataset that will appear in the first figure.
#Combined GOPlot
tab1 <- GOEnrich.var.Pairs.dev$table;tab1$cond <- "Dev. ()"
tab2 <- GOEnrich.var.Pairs.tr$table;tab2$cond <- "Transcr ()."
tab3 <- GOEnrich.var.Pairs.pr$table;tab3$cond <- "Prot ()."
GOTable <- rbind(tab1,tab2,tab3)
GOfig1 <- GOSummaryPlot(GOTable,top = 10) +
theme(legend.position = "right",axis.text.x = element_text(angle = 35)) + coord_flip()To assemble the first Figure, we use the cowplot strategy and the
plot_grid function.
library(gtable)
library(grid)
library(egg)
library(ggpubr)
library(cowplot)
library("ggplotify")First we convert some specific plot into grobs. And creates an empty blank plot
#Convert Combined plot in ggplot
p03RNA$p.all <- as.ggplot(p03RNA$p.all)
p15Tiss$p.all <- as.ggplot(p15Tiss$p.all)
#empty plot
blankplot <- ggplot() + theme_void()We then update some of the labels for the plots, in particular regarding y and x axis names, adding also different titles to the plots.
#Change some labels for the plot
p05RNA <- p05RNA + xlab("Mean sequence identity [%]") + ylab("Pearson R Correlation") +
ggtitle("Development")
p04Tiss <- p04Tiss + xlab("Mean sequence identity [%]") + ylab("Pearson R Correlation") +
ggtitle("Tissues")
p14RNA <- p14RNA + ylab("Fraction of paralogs") + ggtitle("Development")
p36Tiss <- p36Tiss + ylab("Fraction of paralogs") + ggtitle("Tissues")
p30Tiss <- p30Tiss + ylab("Fraction of paralogs") + ggtitle("Tissues - Proteome")We also change some specific color palettes
p18RNA <- p18RNA + scale_color_manual(values = c("#ff928b","#bfd7ea")) +
ylab("Log2(Fold Change)")
p17RNA <- p17RNA + scale_color_manual(values = c("#ff928b","#bfd7ea")) +
ylab("Log2(Fold Change)")
p19RNA <- p19RNA + ylab("Log2(Fold Change)")
p10RNA <- p20RNA + ylab("Log2(Fold Change)")
p15RNA <- p15RNA + xlab("median R Pearson correlation with complex")
p34Tiss <- p34Tiss + xlab("median R Pearson correlation with complex")
p34Tiss <- p34Tiss + xlab("median R Pearson correlation with complex")Then we organize and align all the plots. Depending on the different
blocks. We use align_plot to align the different axes of the plots.
#Pie Plots
pies.plots <- plot_grid(pie.RNA,p39Tiss,ncol = 1)
dens.plots <- plot_grid(p03RNA$p.all,p15Tiss$p.all,ncol = 1,labels = c("B","C"))
upper.block <- plot_grid(blankplot,pies.plots,dens.plots,ncol=3,labels = c("A"),
rel_widths = c(0.32,0.16,0.5))
#Middle Block
middle.block <- plot_grid(p05RNA,p04Tiss,p14RNA,p36Tiss,
ncol=4, align = "h",
axis = "bt",labels = c("D", "E","F","G"))## Warning: Removed 7 rows containing missing values (geom_smooth).
plots <- align_plots(GOfig1, p18RNA, align = 'h', axis = 'b')
plots.2 <- align_plots(plots[[1]],p17RNA,align = 'h', axis = 't')
paralog.profiles.1 <- plot_grid(plots.2[[2]],plots[[2]],
ncol = 1,align = "v",axis = "bt",
labels = c("I",""))
paralog.profiles.2 <- plot_grid(p19RNA,p20RNA,ncol = 1,align = "vh",axis = "bt",
labels = c("L"))
bottom.block <- plot_grid(plots[[1]],paralog.profiles.1,paralog.profiles.2,
nrow=1,rel_widths = c(1,0.5,0.5),
axis = "b",labels = c("H", "","",""))And we assemble the figure.
#Assembled Fig
Fig1.Prev <- plot_grid(upper.block,middle.block,bottom.block,nrow = 3,align = "v",axis = "bt",
rel_heights = c(1,0.8,1.3))Save it.
#save
pdf(paste("../out/figures/Fig1/Fig1Prelimiary_Aligned",Sys.Date(),".pdf",sep = ""),width = 10,height = 10)
Fig1.Prev
dev.off()## png
## 2
Fig1.Prev