|
1 |
| -# Forest Plots |
2 |
| - |
3 |
| - |
4 |
| - |
5 |
| -```{block,type='rmdinfo'} |
6 |
| -Now that we created the **output of our meta-analysis** using the `metagen`, `metacont` or `metabin` functions in `meta` (see [Chapter 4.1](#fixed),[Chapter 4.2](#random) and [Chapter 4.3](#binary)), it is time to present the data in a more digestable way. |
7 |
| -
|
8 |
| -**Forest Plots** are an easy way to do this, and it is conventional to report forest plots in meta-analysis publications. |
9 |
| -``` |
10 |
| - |
11 |
| -<br><br> |
12 |
| - |
13 |
| ---- |
14 |
| - |
15 |
| -## Generating a Forest Plot |
16 |
| - |
17 |
| -To produce a forest plot, we use the meta-analysis output we just created (e.g., `m`, `m.raw`) und the `meta::forest()` function. I'll use my `m.hksj.raw` output from [Chapter 4.2.3](#random.raw) to create the forest plot |
18 |
| - |
19 |
| -```{r,echo=FALSE,warning=FALSE,message=FALSE} |
20 |
| -load("metacont_data.RData") |
21 |
| -metacont$Ne<-as.numeric(metacont$Ne) |
22 |
| -metacont$Me<-as.numeric(metacont$Me) |
23 |
| -metacont$Se<-as.numeric(metacont$Se) |
24 |
| -metacont$Mc<-as.numeric(metacont$Mc) |
25 |
| -metacont$Sc<-as.numeric(metacont$Sc) |
26 |
| -library(meta) |
27 |
| -library(metafor) |
28 |
| -m.hksj.raw<-metacont(Ne, |
29 |
| - Me, |
30 |
| - Se, |
31 |
| - Nc, |
32 |
| - Mc, |
33 |
| - Sc, |
34 |
| - data=metacont, |
35 |
| - studlab=paste(Author), |
36 |
| - comb.fixed = FALSE, |
37 |
| - comb.random = TRUE, |
38 |
| - method.tau = "SJ", |
39 |
| - hakn = TRUE, |
40 |
| - prediction=TRUE, |
41 |
| - sm="SMD") |
42 |
| -metacont$intervention.type<-c("PCI","PCI","Mindfulness","CBT","CBT","CBT") |
43 |
| -``` |
44 |
| - |
45 |
| -```{r,fig.width=11,fig.height=4,fig.align='center'} |
46 |
| -forest(m.hksj.raw) |
47 |
| -``` |
48 |
| - |
49 |
| -Looks good so far. We see that the function plotted a forest plot with a **diamond** (i.e. the overall effect and its confidence interval) and a **prediction interval**. |
50 |
| - |
51 |
| -There are plenty of **other parameters** within the `meta::forest` function which we can use to modify the forest plot. |
52 |
| - |
53 |
| -```{r,echo=FALSE} |
54 |
| -library(knitr) |
55 |
| -library(grid) |
56 |
| -load("foresttable.RData") |
57 |
| -kable(foresttable) |
58 |
| -``` |
59 |
| - |
60 |
| -This is again just an overview. For all settings, type `?meta::forest` in your **console** to see more. |
61 |
| - |
62 |
| -Let's play around with the function a little now: |
63 |
| - |
64 |
| -```{r,fig.width=9,fig.height=3.5,fig.align='center'} |
65 |
| -forest(m.hksj.raw, |
66 |
| - sortvar=TE, |
67 |
| - xlim = c(-1.5,0.5), |
68 |
| - rightlabs = c("g","95% CI","weight"), |
69 |
| - leftlabs = c("Author", "N","Mean","SD","N","Mean","SD"), |
70 |
| - lab.e = "Intervention", |
71 |
| - pooled.totals = FALSE, |
72 |
| - smlab = "", |
73 |
| - text.random = "Overall effect", |
74 |
| - print.tau2 = FALSE, |
75 |
| - col.diamond = "blue", |
76 |
| - col.diamond.lines = "black", |
77 |
| - col.predict = "black", |
78 |
| - print.I2.ci = TRUE, |
79 |
| - digits.sd = 2 |
80 |
| -) |
81 |
| -
|
82 |
| -``` |
83 |
| - |
84 |
| -Looks good so far! For special **layout types**, proceed to [Chapter 5.2](#layouttypes) now. |
85 |
| - |
86 |
| -<br><br> |
87 |
| - |
88 |
| ---- |
89 |
| - |
90 |
| - |
91 |
| -## Layout types {#layouttypes} |
92 |
| - |
93 |
| -The `meta::forest` function also has two **Layouts** preinstalled which we can use. Those layouts can be accessed with the `layout=` parameter. |
94 |
| - |
95 |
| -* **"RevMan5"**. This layout is used for Cochrane reviews and generated by *Review Manager 5*. |
96 |
| -* **"JAMA"**. This layout gives you a forest plot according to the guidelines of the *Journal of the American Medical Association* as output (see details [here](https://jamanetwork.com/journals/jama/pages/instructions-for-authors)). |
97 |
| - |
98 |
| -The **RevMan** layout looks like this: |
99 |
| - |
100 |
| -```{r,fig.width=10,fig.height=4,fig.align='center'} |
101 |
| -forest(m.hksj.raw, |
102 |
| - layout = "RevMan5", |
103 |
| - digits.sd = 2) |
104 |
| -
|
105 |
| -``` |
106 |
| -The **JAMA** layout looks like this: |
107 |
| - |
108 |
| -```{r,fig.width=7,fig.height=3,fig.align='center'} |
109 |
| -forest(m.hksj.raw, |
110 |
| - layout = "JAMA", |
111 |
| - text.predict = "95% PI", |
112 |
| - col.predict = "black", |
113 |
| - colgap.forest.left = unit(15,"mm")) |
114 |
| -``` |
115 |
| - |
116 |
| -<br><br> |
117 |
| - |
118 |
| ---- |
119 |
| - |
120 |
| -## Saving the forest plots |
121 |
| - |
122 |
| -Let's say i want to save the JAMA version of my Forest Plot now. To do this, i have to reuse the code with which i plotted my forest plot, and put it between `pdf(file='name_of_the_pdf_i_want_to_create.pdf')` and `dev.off`, both in separate lines. This saves the plot into a PDF in my Working Directory. |
123 |
| - |
124 |
| -This way, i can export the plot in different formats (you can find more details on the saving options [here](#saving)). |
125 |
| - |
126 |
| -<br></br> |
127 |
| - |
128 |
| -**PDF** |
129 |
| - |
130 |
| -```{r, eval=FALSE} |
131 |
| -pdf(file='forestplot.pdf') |
132 |
| -forest.jama<-forest(m.hksj.raw, |
133 |
| - layout = "JAMA", |
134 |
| - text.predict = "95% PI", |
135 |
| - col.predict = "black", |
136 |
| - colgap.forest.left = unit(15,"mm")) |
137 |
| -dev.off() |
138 |
| -``` |
139 |
| - |
140 |
| -**PNG** |
141 |
| - |
142 |
| -```{r, eval=FALSE} |
143 |
| -png(file='forestplot.png') |
144 |
| -forest.jama<-forest(m.hksj.raw, |
145 |
| - layout = "JAMA", |
146 |
| - text.predict = "95% PI", |
147 |
| - col.predict = "black", |
148 |
| - colgap.forest.left = unit(15,"mm")) |
149 |
| -dev.off() |
150 |
| -``` |
151 |
| - |
152 |
| -**Scalable Vector Graphic** |
153 |
| - |
154 |
| -```{r, eval=FALSE} |
155 |
| -svg(file='forestplot.svg') |
156 |
| -forest.jama<-forest(m.hksj.raw, |
157 |
| - layout = "JAMA", |
158 |
| - text.predict = "95% PI", |
159 |
| - col.predict = "black", |
160 |
| - colgap.forest.left = unit(15,"mm")) |
161 |
| -dev.off() |
162 |
| -``` |
163 |
| - |
164 |
| - |
165 |
| -<br><br> |
166 |
| - |
167 |
| ---- |
168 |
| - |
169 |
| - |
| 1 | +# Forest Plots |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +```{block,type='rmdinfo'} |
| 6 | +Now that we created the **output of our meta-analysis** using the `metagen`, `metacont` or `metabin` functions in `meta` (see [Chapter 4.1](#fixed),[Chapter 4.2](#random) and [Chapter 4.3](#binary)), it is time to present the data in a more digestable way. |
| 7 | +
|
| 8 | +**Forest Plots** are an easy way to do this, and it is conventional to report forest plots in meta-analysis publications. |
| 9 | +``` |
| 10 | + |
| 11 | +<br><br> |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Generating a Forest Plot |
| 16 | + |
| 17 | +To produce a forest plot, we use the meta-analysis output we just created (e.g., `m`, `m.raw`) und the `meta::forest()` function. I'll use my `m.hksj.raw` output from [Chapter 4.2.3](#random.raw) to create the forest plot |
| 18 | + |
| 19 | +```{r,echo=FALSE,warning=FALSE,message=FALSE} |
| 20 | +load("metacont_data.RData") |
| 21 | +metacont$Ne<-as.numeric(metacont$Ne) |
| 22 | +metacont$Me<-as.numeric(metacont$Me) |
| 23 | +metacont$Se<-as.numeric(metacont$Se) |
| 24 | +metacont$Mc<-as.numeric(metacont$Mc) |
| 25 | +metacont$Sc<-as.numeric(metacont$Sc) |
| 26 | +library(meta) |
| 27 | +library(metafor) |
| 28 | +m.hksj.raw<-metacont(Ne, |
| 29 | + Me, |
| 30 | + Se, |
| 31 | + Nc, |
| 32 | + Mc, |
| 33 | + Sc, |
| 34 | + data=metacont, |
| 35 | + studlab=paste(Author), |
| 36 | + comb.fixed = FALSE, |
| 37 | + comb.random = TRUE, |
| 38 | + method.tau = "SJ", |
| 39 | + hakn = TRUE, |
| 40 | + prediction=TRUE, |
| 41 | + sm="SMD") |
| 42 | +metacont$intervention.type<-c("PCI","PCI","Mindfulness","CBT","CBT","CBT") |
| 43 | +``` |
| 44 | + |
| 45 | +```{r,fig.width=11,fig.height=4,fig.align='center'} |
| 46 | +forest(m.hksj.raw) |
| 47 | +``` |
| 48 | + |
| 49 | +Looks good so far. We see that the function plotted a forest plot with a **diamond** (i.e. the overall effect and its confidence interval) and a **prediction interval**. |
| 50 | + |
| 51 | +There are plenty of **other parameters** within the `meta::forest` function which we can use to modify the forest plot. |
| 52 | + |
| 53 | +```{r,echo=FALSE} |
| 54 | +library(knitr) |
| 55 | +library(grid) |
| 56 | +load("foresttable.RData") |
| 57 | +kable(foresttable) |
| 58 | +``` |
| 59 | + |
| 60 | +This is again just an overview. For all settings, type `?meta::forest` in your **console** to see more. |
| 61 | + |
| 62 | +Let's play around with the function a little now: |
| 63 | + |
| 64 | +```{r,fig.width=9,fig.height=3.5,fig.align='center'} |
| 65 | +forest(m.hksj.raw, |
| 66 | + sortvar=TE, |
| 67 | + xlim = c(-1.5,0.5), |
| 68 | + rightlabs = c("g","95% CI","weight"), |
| 69 | + leftlabs = c("Author", "N","Mean","SD","N","Mean","SD"), |
| 70 | + lab.e = "Intervention", |
| 71 | + pooled.totals = FALSE, |
| 72 | + smlab = "", |
| 73 | + text.random = "Overall effect", |
| 74 | + print.tau2 = FALSE, |
| 75 | + col.diamond = "blue", |
| 76 | + col.diamond.lines = "black", |
| 77 | + col.predict = "black", |
| 78 | + print.I2.ci = TRUE, |
| 79 | + digits.sd = 2 |
| 80 | +) |
| 81 | +
|
| 82 | +``` |
| 83 | + |
| 84 | +Looks good so far! For special **layout types**, proceed to [Chapter 5.2](#layouttypes) now. |
| 85 | + |
| 86 | +<br><br> |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | + |
| 91 | +## Layout types {#layouttypes} |
| 92 | + |
| 93 | +The `meta::forest` function also has two **Layouts** preinstalled which we can use. Those layouts can be accessed with the `layout=` parameter. |
| 94 | + |
| 95 | +* **"RevMan5"**. This layout is used for Cochrane reviews and generated by *Review Manager 5*. |
| 96 | +* **"JAMA"**. This layout gives you a forest plot according to the guidelines of the *Journal of the American Medical Association* as output (see details [here](https://jamanetwork.com/journals/jama/pages/instructions-for-authors)). |
| 97 | + |
| 98 | +The **RevMan** layout looks like this: |
| 99 | + |
| 100 | +```{r,fig.width=10,fig.height=4,fig.align='center'} |
| 101 | +forest(m.hksj.raw, |
| 102 | + layout = "RevMan5", |
| 103 | + digits.sd = 2) |
| 104 | +
|
| 105 | +``` |
| 106 | +The **JAMA** layout looks like this: |
| 107 | + |
| 108 | +```{r,fig.width=7,fig.height=3,fig.align='center'} |
| 109 | +forest(m.hksj.raw, |
| 110 | + layout = "JAMA", |
| 111 | + text.predict = "95% PI", |
| 112 | + col.predict = "black", |
| 113 | + colgap.forest.left = unit(15,"mm")) |
| 114 | +``` |
| 115 | + |
| 116 | +<br><br> |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Saving the forest plots |
| 121 | + |
| 122 | +Let's say i want to save the JAMA version of my Forest Plot now. To do this, i have to reuse the code with which i plotted my forest plot, and put it between `pdf(file='name_of_the_pdf_i_want_to_create.pdf')` and `dev.off`, both in separate lines. This saves the plot into a PDF in my Working Directory. |
| 123 | + |
| 124 | +This way, i can export the plot in different formats (you can find more details on the saving options [here](#saving)). |
| 125 | + |
| 126 | +<br></br> |
| 127 | + |
| 128 | +**PDF** |
| 129 | + |
| 130 | +```{r, eval=FALSE} |
| 131 | +pdf(file='forestplot.pdf') |
| 132 | +forest.jama<-forest(m.hksj.raw, |
| 133 | + layout = "JAMA", |
| 134 | + text.predict = "95% PI", |
| 135 | + col.predict = "black", |
| 136 | + colgap.forest.left = unit(15,"mm")) |
| 137 | +dev.off() |
| 138 | +``` |
| 139 | + |
| 140 | +**PNG** |
| 141 | + |
| 142 | +```{r, eval=FALSE} |
| 143 | +png(file='forestplot.png') |
| 144 | +forest.jama<-forest(m.hksj.raw, |
| 145 | + layout = "JAMA", |
| 146 | + text.predict = "95% PI", |
| 147 | + col.predict = "black", |
| 148 | + colgap.forest.left = unit(15,"mm")) |
| 149 | +dev.off() |
| 150 | +``` |
| 151 | + |
| 152 | +**Scalable Vector Graphic** |
| 153 | + |
| 154 | +```{r, eval=FALSE} |
| 155 | +svg(file='forestplot.svg') |
| 156 | +forest.jama<-forest(m.hksj.raw, |
| 157 | + layout = "JAMA", |
| 158 | + text.predict = "95% PI", |
| 159 | + col.predict = "black", |
| 160 | + colgap.forest.left = unit(15,"mm")) |
| 161 | +dev.off() |
| 162 | +``` |
| 163 | + |
| 164 | + |
| 165 | +<br><br> |
| 166 | + |
| 167 | +--- |
| 168 | + |
| 169 | + |
0 commit comments