forked from malcolmbarrett/tidymeta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
104 lines (74 loc) · 3.64 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
fig.height = 8,
dpi = 320
)
#[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/malcolmbarrett/tidymeta?branch=master&svg=true)](https://ci.appveyor.com/project/malcolmbarrett/tidymeta)
```
[![Travis build status](https://travis-ci.org/malcolmbarrett/tidymeta.svg?branch=master)](https://travis-ci.org/malcolmbarrett/tidymeta)
# tidymeta
Tidy and plot meta-analyses from popular meta-analytic tools in R. Currently in early development.
## Installation
`tidymeta` requires the development version of several packages, including `ggplot2`, to function correctly. You can install the required packages for this vignette with the following code:
```{r, eval=FALSE}
install.packages(c("devtools", "yaml", "ggrepel"))
library(devtools)
install_github("r-lib/rlang")
install_github("malcolmbarrett/tidymeta")
install_github("malcolmbarrett/mbmisc")
install_github("tidyverse/ggplot2")
```
# Tidy Meta-Analysis
`tidymeta` is a toolkit for working with meta-analyses in R. Currently, it includes a data set, called `iud_cxca`, for a meta-analysis of the relationship between IUD use and cervical cancer.
```{r, warning = FALSE, message = FALSE}
library(tidymeta)
library(ggplot2)
library(dplyr)
library(broom)
iud_cxca
```
`tidymeta` includes `broom` methods for cleaning meta-analysis results, although it currently only supports the `metafor` package. The `tidy()` function in `broom` puts results into a tidy data frame.
```{r, message = FALSE}
library(metafor)
meta4 <- rma(yi = lnes, sei = selnes, data = iud_cxca)
tidy(meta4) %>%
as_tibble() # for space
```
`tidymeta` also includes wrapper functions for working with meta-analysis packages in the context of the tidyverse. The main function for this is `meta_analysis()`, which models and tidies the object, as well as storing the results in the `meta` column to facilitate other analysis.
```{r}
# same as above but stores the meta-analysis object
iud_cxca %>%
meta_analysis(yi = lnes, sei = selnes, slab = study_name)
```
`tidymeta` doesn't actually do meta-analysis; it unifies existing tools with the tidyverse. The benefit of this approach is that you can do meta-analyses with tidy tools in mind. For example, if you want to conduct a sub-group analysis, you can use the `group_by()` function from `dplyr`. Here, `group` is a variable with information about study design.
```{r}
ma <- iud_cxca %>%
group_by(group) %>%
meta_analysis(yi = lnes, sei = selnes, slab = study_name, exponentiate = TRUE)
ma
```
You can also do sensitivy analyses and cumulative analyses with `sensitivity()` and `cumulative()`.
# Visualization for Meta-Analysis
`tidymeta` includes functionality for working with results in `ggplot2`, including meta-analysis specific geoms (such as `geom_funnel()`) and quick plots for common visualizations.
With tidy data, most data visualizations for meta-analyses are easy to build from the ground up. Nevertheless, `tidymeta` has several quick plot functions to make the process easier. `forest_plot()` takes a tidied meta-analysis and plots the effect sizes.
```{r}
fp <- ma %>%
forest_plot(group = group)
fp
```
Because the results are still `ggplot2` objects, it's easy to make changes to the plot to your liking.
```{r}
fp <- fp +
scale_x_log() +
theme(axis.text.y = element_text(face = c("bold", rep("plain", 21))))
fp
```
`tidymeta` currently supports forest plots, funnel plots, influence plots, and cumulative plots.