Skip to content

Instantly share code, notes, and snippets.

@dceoy
Last active September 13, 2019 15:11
Show Gist options
  • Save dceoy/a3c63540a8722afbc4dd to your computer and use it in GitHub Desktop.
Save dceoy/a3c63540a8722afbc4dd to your computer and use it in GitHub Desktop.
#!/usr/bin/env Rscript
sapply(c('data.table', 'ggplot2'), function(p) require(p, character.only = TRUE))
or_ci <- fread('odds_ratio.csv')
forest <- ggplot(or_ci, aes(x = group, y = odds_ratio, ymin = ci_lower, ymax = ci_upper, colour = class)) +
geom_hline(aes(yintercept = 1), colour = '#4400FF', linetype = 2) +
geom_pointrange(size = 0.7, shape = 15) +
scale_y_log10(limits = c(0.01, 100), breaks = c(0.1, 1, 10)) +
scale_x_discrete(limits = rev(or_ci$group)) +
scale_colour_manual(values = c('#FF00FF', '#4400FF')) +
theme(panel.grid.major.y = element_blank(), panel.grid.minor.y = element_blank(), panel.background = element_rect(fill = '#DDDDFF')) +
coord_flip()
svg('forest.svg', width = 6, height = 7)
plot(forest)
dev.off()
group class odds_ratio ci_lower ci_upper
Group A A_E 1.2449352 0.67203877 2.2783992
Group B A_E 4.4078327 2.26286951 8.7109339
Group C A_E 0.1399230 0.03792926 0.5132163
Group D A_E 0.1258163 0.06423664 0.2409733
Group E A_E 23.6469770 12.93365350 44.8902730
Group F F_J 0.1703764 0.08284161 0.3305291
Group G F_J 16.7660398 6.56914161 54.8668813
Group H F_J 0.1670522 0.10099002 0.2700260
Group I F_J 0.5147020 0.33633240 0.7857115
Group J F_J 3.6561027 1.37950440 9.9886371
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment