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
<- GOEnrich.var.Pairs.dev$table;tab1$cond <- "Dev. ()"
tab1 <- GOEnrich.var.Pairs.tr$table;tab2$cond <- "Transcr ()."
tab2 <- GOEnrich.var.Pairs.pr$table;tab3$cond <- "Prot ()."
tab3
<- rbind(tab1,tab2,tab3)
GOTable
<- GOSummaryPlot(GOTable,top = 10) +
GOfig1 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
$p.all <- as.ggplot(p03RNA$p.all)
p03RNA$p.all <- as.ggplot(p15Tiss$p.all)
p15Tiss#empty plot
<- ggplot() + theme_void() blankplot
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 + xlab("Mean sequence identity [%]") + ylab("Pearson R Correlation") +
p05RNA ggtitle("Development")
<- p04Tiss + xlab("Mean sequence identity [%]") + ylab("Pearson R Correlation") +
p04Tiss ggtitle("Tissues")
<- p14RNA + ylab("Fraction of paralogs") + ggtitle("Development")
p14RNA <- p36Tiss + ylab("Fraction of paralogs") + ggtitle("Tissues")
p36Tiss
<- p30Tiss + ylab("Fraction of paralogs") + ggtitle("Tissues - Proteome") p30Tiss
We also change some specific color palettes
<- p18RNA + scale_color_manual(values = c("#ff928b","#bfd7ea")) +
p18RNA ylab("Log2(Fold Change)")
<- p17RNA + scale_color_manual(values = c("#ff928b","#bfd7ea")) +
p17RNA ylab("Log2(Fold Change)")
<- p19RNA + ylab("Log2(Fold Change)")
p19RNA <- p20RNA + ylab("Log2(Fold Change)")
p10RNA
<- p15RNA + xlab("median R Pearson correlation with complex")
p15RNA <- p34Tiss + xlab("median R Pearson correlation with complex")
p34Tiss <- p34Tiss + xlab("median R Pearson correlation with complex") p34Tiss
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
<- plot_grid(pie.RNA,p39Tiss,ncol = 1)
pies.plots <- plot_grid(p03RNA$p.all,p15Tiss$p.all,ncol = 1,labels = c("B","C"))
dens.plots
<- plot_grid(blankplot,pies.plots,dens.plots,ncol=3,labels = c("A"),
upper.block rel_widths = c(0.32,0.16,0.5))
#Middle Block
<- plot_grid(p05RNA,p04Tiss,p14RNA,p36Tiss,
middle.block ncol=4, align = "h",
axis = "bt",labels = c("D", "E","F","G"))
## Warning: Removed 7 rows containing missing values (geom_smooth).
<- align_plots(GOfig1, p18RNA, align = 'h', axis = 'b')
plots .2 <- align_plots(plots[[1]],p17RNA,align = 'h', axis = 't')
plots
.1 <- plot_grid(plots.2[[2]],plots[[2]],
paralog.profilesncol = 1,align = "v",axis = "bt",
labels = c("I",""))
.2 <- plot_grid(p19RNA,p20RNA,ncol = 1,align = "vh",axis = "bt",
paralog.profileslabels = c("L"))
<- plot_grid(plots[[1]],paralog.profiles.1,paralog.profiles.2,
bottom.block nrow=1,rel_widths = c(1,0.5,0.5),
axis = "b",labels = c("H", "","",""))
And we assemble the figure.
#Assembled Fig
<- plot_grid(upper.block,middle.block,bottom.block,nrow = 3,align = "v",axis = "bt",
Fig1.Prev 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.Prevdev.off()
## png
## 2
Fig1.Prev