metafor:森林去除或移动元元音柱

发布于 2025-02-06 09:02:37 字数 1329 浏览 0 评论 0原文

我试图改变我的森林情节的形式,以准备出版。

我想移动最终的右侧列,该列显示当前显示效果估计值(在我的情况下,赔率比)。这列是固定在图的右侧,还是可以移动,使其与其他列对齐,森林图本身在最右侧。

这是我目前的森林情节代码,

# Forest plot of odds ratio
options(na.action = "na.pass")
forest(res.or,
       addpred=TRUE, header=TRUE,
       atransf=exp,
       order = ormri$year,
       xlim = c(-22,10),
       ilab=cbind(m1$hiv, m1$con, m1$diffci),
       ilab.xpos=c(-14, -10, -5),
       ilab.pos = 2,
       mlab = "",
       digits = 2, cex = 0.75,
       col = "blue",
       xlab = c("Odds Ratio"),
       at=log(c(0.1, .25, 1, 10, 100))) 
text(c(-15.5, -11.5, -6.5), 16.5, c("LGE+/N (%)", "LGE+/N (%)", "Diff [95% CI]"), cex=0.75)
text(c(-15.5, -11.5), 17.5, c("HIV+", "HIV -"), font =2, cex = 0.75)
## add text with Q-value, dfs, p-value, and I^2 statistic
text(-22, -1, pos=4, cex=0.75, bquote(paste("RE Model (Q = ",
                                              .(formatC(res.or$QE, digits=2, format="f")), ", df = ", .(res.or$k - res.or$p),
                                              ", p = ", .(formatC(res.or$QEp, digits=2, format="f")), "; ", I^2, " = ",
                                              .(formatC(res.or$I2, digits=1, format="f")), "%)")))

它赋予了这个情节 “

我想将优势比列与diff [95 ci]列并肩移动。

I am attempting to change the format of my forest plot to prepare for publication.

I would like to move the far right hand column that shows the effect estimate currently (in my case odds ratios). Is this column fixed to the right hand side of plot or can it be moved so that it aligns with the other columns and the forest plot itself is on the far right hand side.

This is my current forest plot code

# Forest plot of odds ratio
options(na.action = "na.pass")
forest(res.or,
       addpred=TRUE, header=TRUE,
       atransf=exp,
       order = ormri$year,
       xlim = c(-22,10),
       ilab=cbind(m1$hiv, m1$con, m1$diffci),
       ilab.xpos=c(-14, -10, -5),
       ilab.pos = 2,
       mlab = "",
       digits = 2, cex = 0.75,
       col = "blue",
       xlab = c("Odds Ratio"),
       at=log(c(0.1, .25, 1, 10, 100))) 
text(c(-15.5, -11.5, -6.5), 16.5, c("LGE+/N (%)", "LGE+/N (%)", "Diff [95% CI]"), cex=0.75)
text(c(-15.5, -11.5), 17.5, c("HIV+", "HIV -"), font =2, cex = 0.75)
## add text with Q-value, dfs, p-value, and I^2 statistic
text(-22, -1, pos=4, cex=0.75, bquote(paste("RE Model (Q = ",
                                              .(formatC(res.or$QE, digits=2, format="f")), ", df = ", .(res.or$k - res.or$p),
                                              ", p = ", .(formatC(res.or$QEp, digits=2, format="f")), "; ", I^2, " = ",
                                              .(formatC(res.or$I2, digits=1, format="f")), "%)")))

Which gives this plot
forest

I would like to move the ODDS RATIO column to be alongside the diff[95 CI] column.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泛滥成性 2025-02-13 09:02:38

不久前,有人要求我调整研究标签的位置(左侧)和注释(右侧)。为此,我添加了textpos参数。请参阅:

https:/ metafor/reference/forest.rma.html#afre-arguments-1

使用这个示例,我可以说明如何使用此示例。交换forest()text()与此相关的部分:

### forest plot with extra annotations
forest(res, atransf=exp, at=log(c(.05, .25, 1, 4)), xlim=c(-20,2),
       ilab=cbind(tpos, tneg, cpos, cneg), ilab.xpos=c(-14,-12,-10,-8), 
       cex=.75, header="Author(s) and Year", mlab="", textpos=c(-20,-3))
op <- par(cex=.75, font=2)
text(c(-14,-12,-10,-8), 15, c("TB+", "TB-", "TB+", "TB-"))
text(c(-11,-9),     16, c("Vaccinated", "Control"))
par(op)
 
### add text with Q-value, dfs, p-value, and I^2 statistic
text(-20, -1, pos=4, cex=0.75, bquote(paste("RE Model (Q = ",
     .(formatC(res$QE, digits=2, format="f")), ", df = ", .(res$k - res$p),
     ", p = ", .(formatC(res$QEp, digits=2, format="f")), "; ", I^2, " = ",
     .(formatC(res$I2, digits=1, format="f")), "%)")))

voila,注释在实际森林图的左侧。找到xlimiLab.xpostextpos的良好值是有点痛苦的绘图设备),但似乎您已经花了一些时间来处理此操作,因此现在您再次经历了该过程。

Somebody asked me a while ago to make it possible to adjust the position of the study labels (on the left) and the annotations (on the right). For this, I have added the textpos argument. See:

https://wviechtb.github.io/metafor/reference/forest.rma.html#additional-arguments-1

Using this example, I can illustrate how to make use of this. Swap out the forest() and text() parts with this:

### forest plot with extra annotations
forest(res, atransf=exp, at=log(c(.05, .25, 1, 4)), xlim=c(-20,2),
       ilab=cbind(tpos, tneg, cpos, cneg), ilab.xpos=c(-14,-12,-10,-8), 
       cex=.75, header="Author(s) and Year", mlab="", textpos=c(-20,-3))
op <- par(cex=.75, font=2)
text(c(-14,-12,-10,-8), 15, c("TB+", "TB-", "TB+", "TB-"))
text(c(-11,-9),     16, c("Vaccinated", "Control"))
par(op)
 
### add text with Q-value, dfs, p-value, and I^2 statistic
text(-20, -1, pos=4, cex=0.75, bquote(paste("RE Model (Q = ",
     .(formatC(res$QE, digits=2, format="f")), ", df = ", .(res$k - res$p),
     ", p = ", .(formatC(res$QEp, digits=2, format="f")), "; ", I^2, " = ",
     .(formatC(res$I2, digits=1, format="f")), "%)")))

and voila, the annotations are to the left of the actual forest plot. It's a bit of pain to find good values for xlim, ilab.xpos, and textpos to make everything look nice (within the actual dimensions of the plotting device), but it seems like you've already spent some time dealing with this, so now you just have go through that process once more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文