library(meta)
library(grid)


m.sens <- metaprop(100 - 1:10, rep(100, 10), studlab = LETTERS[1:10])
m.spec <- metaprop(170 + 1:10, rep(200, 10), studlab = LETTERS[1:10])


ncols <- 2
nrows <- 1
firstcol <- .53

width <- 10.25
height <- 3.75


pdf("forest-sensspec.pdf", width = width, height = height)

pushViewport(viewport(
  layout = grid.layout(nrow = nrows, ncol = ncols,
                       widths = unit(c(2 * firstcol, 2 * (1 - firstcol)) *
                                     width / ncols, "inches"),
                       heights = unit(height / nrows, "inches"))))


pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 1,
                      layout = grid.layout(just = "left")))

forest(m.sens, new = FALSE,
       overall = FALSE, overall.hetstat = FALSE,
       xlim = c(0.5, 1),
       leftlabs = c(NA, "TP", "n1"),
       rightlabs = c("Sens", NA),
       xlab = "Sensitivity")

popViewport()


pushViewport(viewport(layout.pos.col = 2, layout.pos.row = 1,
                      layout = grid.layout(just = "right")))

forest(m.spec, new = FALSE,
       overall = FALSE,
       xlim = c(0.5, 1),
       leftcols = c("event", "n"),
       leftlabs = c("TN", "n2"),
       rightlabs = c("Spec", NA),
       xlab = "Specificity")

popViewport()

dev.off()
