Entering edit mode
5.2 years ago
micecanfly
▴
10
I am trying to plot multiple volcano plots to the same PDF page with the following code. However, instead I get a PDF file with multiple pages, one plot on each. Also pdf('volcanos.pdf', width = 10, height = 10)
controls for the size of each page but not the plot itself. How to control for the size of each volcano plot, and to plot many of them on the same page? data
= my dataframe with datasets from volcano plots
for(i in 1:(ncol(data)/2)) {
pdf(paste0('./volcano_', gsub('log2FC', '', colnames(data)[2*i-1]), '.pdf'))
volcano <- EnhancedVolcano(data,
lab = rownames(data),
title = gsub('log2FC_', '', colnames(data)[2*i-1]),
x = colnames(data)[2*i-1],
y = colnames(data)[2*i],
ylab = bquote(~-Log[10]~adjusted~italic(P))
xlim = c(-2, 2),
pCutoff = 0.05,
FCcutoff = 0.5,
transcriptLabSize = 5,
drawConnectors = TRUE,
widthConnectors = 0.2,
legendPosition = 'right')
print(volcano)
dev.off()
}