荟萃分析中缺失 CI 需要调整 Forestplot
Forestplot tweak needed for a missing CI in meta-analysis
这是一个系统综述,所以我只能分析以前论文提供的数据。对于七个这样的,有足够的数据让我可以构建 CI,我想以通常的森林图方式呈现,包括根据 CI 的长度调整框大小的吸引人的特征.
对于第八个——这里标记为尴尬——因为没有显示样本量,我只能显示(最好是在同一个森林图上)平均值,而不是 CI。因此,我需要帮助来调整下面的代码,以便在不扭曲其他七个 Okay 框的大小的情况下将此均值显示为绘图上的单个点。
在为尴尬添加一个极窄的 CI 时:CI 太窄并且 R 舍入值导致没有显示框,或者 CI 太窄森林图库将其解释为 "sure" 事物并赋予它最高的权重(因此是一个非常大的盒子),这反过来导致所有其他盒子变得无法区分地小并且有点违背了目的。一名学生还研究了为 Awkward 分配一个非常大的 CI——这给了 Awkward 一个小盒子并保持其他状态相对成比例,尽管 Awkward OR 的上限和下限的 "whiskers" 变得非常长。
在显示中强制显示所需效果的一种方法可能是为 Awkward 声明一个非常大的 CI(减轻权重),然后在 white/transparent 中打印 CI 行(所以不可见);我不知道该怎么做。
(您可能已经猜到了,我绝对是初学者。)
library(forestplot)
# grafted from https://cran.r-project.org/web/packages/forestplot/vignettes/forestplot.html
##According to this Awkward doesn't have a confidence interval; entries of 0.1 and 30 are fictitious
Table1_19225_OR <-
structure(list(
mean = c(NA, NA, 6, 4.19, 3.11, 3.79, 13.20, 3.84, 2.32, 5.78, NA, 4.41, 5.99, 5.43),
lower = c(NA, NA, 0.1, 2.54, 1.39, 1.83, 6.25, 2.69, 1.04, 2.89, NA, 3.13, 4.65, 4.79),
upper = c(NA, NA, 30, 6.91, 6.96, 7.85, 27.87, 5.49, 5.2, 11.54, NA, 6.23, 7.71, 6.14)),
.Names = c("mean", "lower", "upper"),
row.names = c(NA, -14L),
class = "data.frame")
#State data pooled using random effects model
tabletext<-cbind(
c("", "State", "Awkward", "Okay1", "Okay2", "Okay3", "Okay4", "Okay5", "Okay6", "Okay7", NA, "State data", "National", "National"),
c("Change", "Year", "1977", "1977", "1977", "1982", "1989", "1997", "2000", "2012", NA, "", "1995-2003", "2005-2008"),
c("Odds", "Ratio", "6.00", "4.19", "3.11", "3.89", "13.20", "3.84", "2.32", "5.78", NA, "4.41", "5.99", "5.43"))
forestplot(tabletext,
hrzl_lines = gpar(col="#444444"),
Table1_19225_OR, new_page = TRUE,
is.summary=c(TRUE,TRUE,rep(FALSE,9),TRUE,FALSE,FALSE), #TRUE means bold
clip=c(2, 14),
ci.vertices = TRUE,
xlog=FALSE,
xticks = c(2.0, 4.0, 6.0, 8.0, 10, 12),
grid=TRUE,
xlab="95% CIs for Odds Ratio",
col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))
字体大小更改
拥有<-fpTxtGp()
自己的#checking 以查看默认值是什么——我认为每次调用 forestplot 库时都会加载这些值
own$xlab$cex <- 1.25 #default is 1, 不确定这个东西是什么单位所以试错
own$legend$cex <- 0.8 #default 是 0.8,改变这个似乎不会改变 forestplot 上的任何东西
own$ticks$cex <- 0.8 #default is 0.5, 更改 CI scale
上数字的大小
由于您无法真正了解场景中的置信区间,我认为最简单的方法是简单地修改置信区间函数来处理带有缺失数据的绘图值。在下面的示例中,我在下部或上部检查 NA
,如果我找不到它,我会绘制一个 grid.circle
而不是 fpDrawnormalCI
使用的 grid.rect
。
library(forestplot)
fn <- function(...,
y.offset = 0.5,
lower_limit, estimate, upper_limit,
clr.marker){
if (is.na(lower_limit) || is.na(upper_limit)) {
grid.circle(x = unit(estimate, "native"), y = y.offset,
r = unit(.1, "snpc"),
gp = gpar(fill = clr.marker, col = clr.marker))
} else {
# Forward otherwise to the default function
fpDrawNormalCI(...,
y.offset = y.offset,
lower_limit = lower_limit,
estimate = estimate,
upper_limit = upper_limit,
clr.marker = clr.marker)
}
}
# grafted from https://cran.r-project.org/web/packages/forestplot/vignettes/forestplot.html
##According to this Awkward doesn't have a confidence interval; entries of 0.1 and 30 are fictitious
Table1_19225_OR <-
structure(list(
mean = c(NA, NA, 6, 4.19, 3.11, 3.79, 13.20, 3.84, 2.32, 5.78, NA, 4.41, 5.99, 5.43),
lower = c(NA, NA, NA, 2.54, 1.39, 1.83, 6.25, 2.69, 1.04, 2.89, NA, 3.13, 4.65, 4.79),
upper = c(NA, NA, NA, 6.91, 6.96, 7.85, 27.87, 5.49, 5.2, 11.54, NA, 6.23, 7.71, 6.14)),
.Names = c("mean", "lower", "upper"),
row.names = c(NA, -14L),
class = "data.frame")
#State data pooled using random effects model
tabletext<-cbind(
c("", "State", "Awkward", "Okay1", "Okay2", "Okay3", "Okay4", "Okay5", "Okay6", "Okay7", NA, "State data", "National", "National"),
c("Change", "Year", "1977", "1977", "1977", "1982", "1989", "1997", "2000", "2012", NA, "", "1995-2003", "2005-2008"),
c("Odds", "Ratio", "6.00", "4.19", "3.11", "3.89", "13.20", "3.84", "2.32", "5.78", NA, "4.41", "5.99", "5.43"))
forestplot(tabletext,
Table1_19225_OR,
fn.ci_norm = fn,
hrzl_lines = gpar(col="#444444"),
new_page = TRUE,
is.summary=c(TRUE,TRUE,rep(FALSE,9),TRUE,FALSE,FALSE), #TRUE means bold
clip=c(2, 14),
ci.vertices = TRUE,
xlog=FALSE,
xticks = c(2.0, 4.0, 6.0, 8.0, 10, 12),
grid=TRUE,
xlab="95% CIs for Odds Ratio",
col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))
这是情节本身:
这是一个系统综述,所以我只能分析以前论文提供的数据。对于七个这样的,有足够的数据让我可以构建 CI,我想以通常的森林图方式呈现,包括根据 CI 的长度调整框大小的吸引人的特征.
对于第八个——这里标记为尴尬——因为没有显示样本量,我只能显示(最好是在同一个森林图上)平均值,而不是 CI。因此,我需要帮助来调整下面的代码,以便在不扭曲其他七个 Okay 框的大小的情况下将此均值显示为绘图上的单个点。
在为尴尬添加一个极窄的 CI 时:CI 太窄并且 R 舍入值导致没有显示框,或者 CI 太窄森林图库将其解释为 "sure" 事物并赋予它最高的权重(因此是一个非常大的盒子),这反过来导致所有其他盒子变得无法区分地小并且有点违背了目的。一名学生还研究了为 Awkward 分配一个非常大的 CI——这给了 Awkward 一个小盒子并保持其他状态相对成比例,尽管 Awkward OR 的上限和下限的 "whiskers" 变得非常长。
在显示中强制显示所需效果的一种方法可能是为 Awkward 声明一个非常大的 CI(减轻权重),然后在 white/transparent 中打印 CI 行(所以不可见);我不知道该怎么做。 (您可能已经猜到了,我绝对是初学者。)
library(forestplot)
# grafted from https://cran.r-project.org/web/packages/forestplot/vignettes/forestplot.html
##According to this Awkward doesn't have a confidence interval; entries of 0.1 and 30 are fictitious
Table1_19225_OR <-
structure(list(
mean = c(NA, NA, 6, 4.19, 3.11, 3.79, 13.20, 3.84, 2.32, 5.78, NA, 4.41, 5.99, 5.43),
lower = c(NA, NA, 0.1, 2.54, 1.39, 1.83, 6.25, 2.69, 1.04, 2.89, NA, 3.13, 4.65, 4.79),
upper = c(NA, NA, 30, 6.91, 6.96, 7.85, 27.87, 5.49, 5.2, 11.54, NA, 6.23, 7.71, 6.14)),
.Names = c("mean", "lower", "upper"),
row.names = c(NA, -14L),
class = "data.frame")
#State data pooled using random effects model
tabletext<-cbind(
c("", "State", "Awkward", "Okay1", "Okay2", "Okay3", "Okay4", "Okay5", "Okay6", "Okay7", NA, "State data", "National", "National"),
c("Change", "Year", "1977", "1977", "1977", "1982", "1989", "1997", "2000", "2012", NA, "", "1995-2003", "2005-2008"),
c("Odds", "Ratio", "6.00", "4.19", "3.11", "3.89", "13.20", "3.84", "2.32", "5.78", NA, "4.41", "5.99", "5.43"))
forestplot(tabletext,
hrzl_lines = gpar(col="#444444"),
Table1_19225_OR, new_page = TRUE,
is.summary=c(TRUE,TRUE,rep(FALSE,9),TRUE,FALSE,FALSE), #TRUE means bold
clip=c(2, 14),
ci.vertices = TRUE,
xlog=FALSE,
xticks = c(2.0, 4.0, 6.0, 8.0, 10, 12),
grid=TRUE,
xlab="95% CIs for Odds Ratio",
col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))
字体大小更改
拥有<-fpTxtGp() 自己的#checking 以查看默认值是什么——我认为每次调用 forestplot 库时都会加载这些值 own$xlab$cex <- 1.25 #default is 1, 不确定这个东西是什么单位所以试错 own$legend$cex <- 0.8 #default 是 0.8,改变这个似乎不会改变 forestplot 上的任何东西 own$ticks$cex <- 0.8 #default is 0.5, 更改 CI scale
上数字的大小由于您无法真正了解场景中的置信区间,我认为最简单的方法是简单地修改置信区间函数来处理带有缺失数据的绘图值。在下面的示例中,我在下部或上部检查 NA
,如果我找不到它,我会绘制一个 grid.circle
而不是 fpDrawnormalCI
使用的 grid.rect
。
library(forestplot)
fn <- function(...,
y.offset = 0.5,
lower_limit, estimate, upper_limit,
clr.marker){
if (is.na(lower_limit) || is.na(upper_limit)) {
grid.circle(x = unit(estimate, "native"), y = y.offset,
r = unit(.1, "snpc"),
gp = gpar(fill = clr.marker, col = clr.marker))
} else {
# Forward otherwise to the default function
fpDrawNormalCI(...,
y.offset = y.offset,
lower_limit = lower_limit,
estimate = estimate,
upper_limit = upper_limit,
clr.marker = clr.marker)
}
}
# grafted from https://cran.r-project.org/web/packages/forestplot/vignettes/forestplot.html
##According to this Awkward doesn't have a confidence interval; entries of 0.1 and 30 are fictitious
Table1_19225_OR <-
structure(list(
mean = c(NA, NA, 6, 4.19, 3.11, 3.79, 13.20, 3.84, 2.32, 5.78, NA, 4.41, 5.99, 5.43),
lower = c(NA, NA, NA, 2.54, 1.39, 1.83, 6.25, 2.69, 1.04, 2.89, NA, 3.13, 4.65, 4.79),
upper = c(NA, NA, NA, 6.91, 6.96, 7.85, 27.87, 5.49, 5.2, 11.54, NA, 6.23, 7.71, 6.14)),
.Names = c("mean", "lower", "upper"),
row.names = c(NA, -14L),
class = "data.frame")
#State data pooled using random effects model
tabletext<-cbind(
c("", "State", "Awkward", "Okay1", "Okay2", "Okay3", "Okay4", "Okay5", "Okay6", "Okay7", NA, "State data", "National", "National"),
c("Change", "Year", "1977", "1977", "1977", "1982", "1989", "1997", "2000", "2012", NA, "", "1995-2003", "2005-2008"),
c("Odds", "Ratio", "6.00", "4.19", "3.11", "3.89", "13.20", "3.84", "2.32", "5.78", NA, "4.41", "5.99", "5.43"))
forestplot(tabletext,
Table1_19225_OR,
fn.ci_norm = fn,
hrzl_lines = gpar(col="#444444"),
new_page = TRUE,
is.summary=c(TRUE,TRUE,rep(FALSE,9),TRUE,FALSE,FALSE), #TRUE means bold
clip=c(2, 14),
ci.vertices = TRUE,
xlog=FALSE,
xticks = c(2.0, 4.0, 6.0, 8.0, 10, 12),
grid=TRUE,
xlab="95% CIs for Odds Ratio",
col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))
这是情节本身: