我有数据显示以下关系 暴露->中间体->结果 我的目标是通过如下图可视化这些数据。我现在只有一种暴露(体力活动),但有多种中间结果和一种最终结果(乳腺癌)。箭头应通过着色变量(方向)进行着色,并通过大小变量(exposure_int_es)进行大小调整。节点应带有标签(曝光、结果),箭头应包含效果大小和 95%CI 文本标签。
下面,我添加了一个可重现的数据集。如果有人可以提供帮助,我将非常感激。
#Reproducible datasets
data <-read.table(
text = "Author Exposure Outcome Pathway exp_in_es_measure exposure_int_es exposure_int_lower exposure_it_higher exp_int_grade exp_int_n_studies
Swain_CT_2023 Physical_activity CRP Inflammation SMD -0.27 -0.62 0.08 Low 12
Swain_CT_2023 Physical_activity TNF_alpha Inflammation SMD -0.63 -1.04 -0.22 Moderate 8
Swain_CT_2023 Physical_activity IL-6 Inflammation SMD -0.55 -0.97 -0.13 Moderate 11
Swain_CT_2023 Physical_activity Adiponectin Inflammation SMD 0.01 -0.14 0.17 High 5
Swain_CT_2023 Physical_activity Leptin Inflammation SMD -0.5 -1.1 0.09 Low 4
Lou_MWC_2023 CRP Breast_Cancer Inflammation RR 1.13 1.01 1.26 Moderate 16
Lou_MWC_2023 TNF_alpha Breast_Cancer Inflammation RR 0.84 0.57 1.1 Moderate 4
Lou_MWC_2023 IL-6 Breast_Cancer Inflammation RR 1.04 0.66 1.42 Very_low 3
Lou_MWC_2023 Adiponectin Breast_Cancer Inflammation RR 0.76 0.61 0.91 Moderate 8
Lou_MWC_2023 Leptin Breast_Cancer Inflammation RR 0.9 0.63 1.18 Low 8",
header = TRUE
)
# Function to determine the direction of association
get_direction <- function(es_measure, lower, upper, effect_type) {
if (effect_type == "SMD") {
if (es_measure > 0 & lower > 0 & upper > 0) {
return("Positive")
}
else if (es_measure < 0 & lower < 0 & upper < 0) {
return("Negative")
}
else{
return("Null")
}
}
else if (effect_type == "RR") {
if (es_measure > 1 & lower > 1 & upper > 1) {
return("Positive")
}
else if (es_measure < 1 & lower < 1 & upper < 1) {
return("Negative")
}
else {
return("Null")
}
}
}
# Determine the direction of association
data$direction <- with(data, mapply(get_direction, exposure_int_es,
exposure_int_lower, exposure_it_higher,
effect_type = exp_in_es_measure))