大数跨境
0
0

用R语言画出专业医学图表:详解OCT如何改变PCI手术决策

用R语言画出专业医学图表:详解OCT如何改变PCI手术决策 医学统计数据分析
2025-09-16
2
导读:在医学研究中,数据可视化是展示研究成果的重要手段。一张清晰的图表往往比大段文字更能直观地传达信息。



在医学研究中,数据可视化是展示研究成果的重要手段。一张清晰的图表往往比大段文字更能直观地传达信息。今天我们就来深入解析如何使用R语言绘制专业的医学图表,以光学相干断层扫描(OCT)对经皮冠状动脉介入治疗(PCI)决策的影响为例。




为什么要学习医学数据可视化?

在循证医学时代,医生和研究人员需要处理大量临床数据,并通过可视化手段发现数据中的规律和趋势。良好的数据可视化能够:

1.提高研究结果的传达效率

2.帮助识别潜在的数据模式和异常值

3.增强学术报告和论文的说服力

4.促进临床决策的科学化


案例背景:OCT对PCI决策的影响

光学相干断层扫描(OCT)是一种高分辨率的冠状动脉成像技术,能够提供比传统血管造影更详细的血管内部信息。本研究通过分析552个病变,发现OCT提供的信息在88%的病变中改变了基于血管造影的治疗决策,其中术前OCT的影响占83%,术后OCT的影响占31%。




必要的R包:R语言的强大功能很大程度上来自于其丰富的扩展包。

ggplot2:基于图形语法的绘图系统,提供强大而灵活的绘图功能

dplyr和tidyr:数据整理和转换的利器

gridExtra:提供图形排列和布局功能

showtext:解决中文字体显示问题

scales:提供坐标轴标签格式调整功能

pacman包是一个方便的包管理工具,可以自动安装和加载所需的包。






实用技巧与注意事项

1.字体大小适配:根据输出介质调整字体大小,印刷品需要比屏幕显示更大的字体

2.颜色对比度:确保颜色有足够的对比度,考虑色盲人群的可读性

3.数据标签:避免标签重叠,适当调整位置和大小

4.图例设计:保持图例简洁明了,避免过度装饰

5.输出格式:矢量格式(PDF、SVG)适合印刷,位图格式(PNG、JPG)适合网络传播




# 设置工作目录和清理环境
rm(list = ls())
if (!is.null(dev.list())) dev.off()
setwd("C:/Users/hyy/Desktop/")

# 创建结果文件夹
if (!dir.exists("Results")) dir.create("Results")

# 加载必要的包
if (!require(pacman)) install.packages("pacman")
pacman::p_load(ggplot2, dplyr, tidyr, gridExtra, showtext, scales)

# 添加中文字体支持
font_add("SimSun""simsun.ttc")
showtext_auto()

# 创建数据框
data <- data.frame(
  Category = c("Lesion Type (A, B, C)""Lesion Morphology""Treat Peradenopathy"
               "Vessel Prep""Treatment Type""Number of Stents""Stent Length",
               "Edge Detection""Malapposition""Underexpansion""Geographic Miss""Other"),
  Pre_PCI = c(48, 22, 28, 2, 8, 11, 0, 0, 0, 0, 0, 0),  # 前6个有数据,后面为0
  Post_PCI = c(0, 0, 0, 0, 0, 0, 25, 4, 11, 2, 3, 0)    # 后6个有数据,前面为0
)

# 将数据转换为长格式
data_long <- data %>%
  pivot_longer(cols = c(Pre_PCI, Post_PCI), 
               names_to = "Procedure"
               values_to = "Percentage")

# 创建颜色方案
colors <- c("#1f77b4""#aec7e8""#ff7f0e""#ffbb78""#2ca02c""#98df8a",
            "#d62728""#ff9896""#9467bd""#c5b0d5""#8c564b""#c49c94")

# 创建主图表
p_main <- ggplot(data_long, aes(x = Procedure, y = Percentage, fill = Category)) +
  geom_bar(stat = "identity", position = "stack") +
  scale_fill_manual(values = colors) +
  scale_y_continuous(labels = percent_format(scale = 1)) +
  labs(title = "OCT-derived information changes angiographic-based decisions in 88% of lesions",
       subtitle = "Impact of Pre PCI OCT: 83% | Impact of Post PCI OCT: 31% | N=552",
       x = "", y = "Percentage") +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 16, face = "bold", hjust = 0.5),
    plot.subtitle = element_text(size = 12, hjust = 0.5),
    axis.text.x = element_text(size = 12, face = "bold"),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 12),
    legend.position = "right",
    legend.title = element_blank(),
    legend.text = element_text(size = 9)
  )
p_main

# 添加百分比标签
p_main <- p_main + 
  geom_text(data = subset(data_long, Percentage > 0),
            aes(label = paste0(Percentage, "%")),
            position = position_stack(vjust = 0.5),
            size = 3.5, color = "white", fontface = "bold")

# 创建图例单独显示
legend_plot <- ggplot(data_long, aes(x = Procedure, y = Percentage, fill = Category)) +
  geom_bar(stat = "identity") +
  scale_fill_manual(values = colors) +
  theme_minimal() +
  theme(legend.position = "bottom",
        legend.box = "horizontal",
        legend.text = element_text(size = 8)) +
  guides(fill = guide_legend(nrow = 4, byrow = TRUE))

# 提取图例
legend <- cowplot::get_legend(legend_plot)

# 创建最终图表布局
final_plot <- grid.arrange(
  p_main + theme(legend.position = "none"),
  legend,
  nrow = 2,
  heights = c(8, 2)
)

# 保存图表
ggsave("Results/Figure1_OCT_Impact.jpg", final_plot, width = 12, height = 10, dpi = 300)
ggsave("Results/Figure1_OCT_Impact.pdf", final_plot, width = 12, height = 10)

# 添加参考文献文本
ref_text <- "1. O'u.e.K. et al. / Am Coll Cardiol, 2020 Oct. 76; 17. Supplement S) B175-E175."
writeLines(ref_text, "Results/Figure1_Reference.txt")

# 显示图表
print(final_plot)


# 设置工作目录和清理环境
rm(list = ls())
if (!is.null(dev.list())) dev.off()
setwd("C:/Users/hyy/Desktop/")

# 创建结果文件夹
if (!dir.exists("Results")) dir.create("Results")

# 加载必要的包
if (!require(pacman)) install.packages("pacman")
pacman::p_load(ggplot2, dplyr, tidyr, gridExtra, showtext, scales, patchwork)

# 添加中文字体支持
font_add("SimSun""simsun.ttc")
showtext_auto()

# 创建数据框
data <- data.frame(
  Category = c("Lesion Type (A, B, C)""Lesion Morphology""Treat Peradenopathy"
               "Vessel Prep""Treatment Type""Number of Stents""Stent Length",
               "Edge Detection""Malapposition""Underexpansion""Geographic Miss""Other"),
  Pre_PCI = c(48, 22, 28, 2, 8, 11, 0, 0, 0, 0, 0, 0),  # 前6个有数据,后面为0
  Post_PCI = c(0, 0, 0, 0, 0, 0, 25, 4, 11, 2, 3, 0)    # 后6个有数据,前面为0
)

# 将数据转换为长格式
data_long <- data %>%
  pivot_longer(cols = c(Pre_PCI, Post_PCI), 
               names_to = "Procedure"
               values_to = "Percentage")

# 创建颜色方案
pre_colors <- c("#1f77b4""#aec7e8""#ff7f0e""#ffbb78""#2ca02c""#98df8a")
post_colors <- c("#d62728""#ff9896""#9467bd""#c5b0d5""#8c564b""#c49c94")

# 创建Pre-PCI柱状图
pre_data <- data_long %>% 
  filter(Procedure == "Pre_PCI", Percentage > 0) %>%
  mutate(Category = factor(Category, levels = Category))

pre_plot <- ggplot(pre_data, aes(x = Category, y = Percentage, fill = Category)) +
  geom_bar(stat = "identity", width = 0.7) +
  scale_fill_manual(values = pre_colors) +
  labs(title = "Pre-PCI OCT Impact (83%)",
       x = "", y = "Percentage") +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
    axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 12),
    legend.position = "none"
  ) +
  geom_text(aes(label = paste0(Percentage, "%")), 
            vjust = -0.5, size = 4, fontface = "bold") +
  ylim(0, max(pre_data$Percentage) * 1.1)
pre_plot

# 创建Post-PCI柱状图
post_data <- data_long %>% 
  filter(Procedure == "Post_PCI", Percentage > 0) %>%
  mutate(Category = factor(Category, levels = Category))

post_plot <- ggplot(post_data, aes(x = Category, y = Percentage, fill = Category)) +
  geom_bar(stat = "identity", width = 0.7) +
  scale_fill_manual(values = post_colors) +
  labs(title = "Post-PCI OCT Impact (31%)",
       x = "", y = "Percentage") +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
    axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 12),
    legend.position = "none"
  ) +
  geom_text(aes(label = paste0(Percentage, "%")), 
            vjust = -0.5, size = 4, fontface = "bold") +
  ylim(0, max(post_data$Percentage) * 1.1)
post_plot

# 创建组合数据用于折线图
combined_data <- data.frame(
  Procedure = rep(c("Pre-PCI""Post-PCI"), each = 6),
  Category = c(
    "Lesion Type (A, B, C)""Lesion Morphology""Treat Peradenopathy"
    "Vessel Prep""Treatment Type""Number of Stents",
    "Stent Length""Edge Detection""Malapposition"
    "Underexpansion""Geographic Miss""Other"
  ),
  Percentage = c(48, 22, 28, 2, 8, 11, 25, 4, 11, 2, 3, 0)
)

# 创建折线图
line_plot <- ggplot(combined_data, aes(x = Category, y = Percentage, group = Procedure, color = Procedure)) +
  geom_line(size = 1.5) +
  geom_point(size = 3) +
  scale_color_manual(values = c("Pre-PCI" = "#1f77b4""Post-PCI" = "#d62728")) +
  labs(title = "OCT Impact Comparison: Pre-PCI vs Post-PCI",
       x = "Category", y = "Percentage") +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
    axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 12),
    legend.position = "bottom"
  )
line_plot

# 使用patchwork包组合图表
combined_plot <- (pre_plot + post_plot) / line_plot +
  plot_annotation(
    title = "OCT-derived information changes angiographic-based decisions in 88% of lesions",
    subtitle = "N=552 | Omni-arrive OCT impact through progression of workflow",
    theme = theme(plot.title = element_text(size = 16, face = "bold", hjust = 0.5),
                  plot.subtitle = element_text(size = 12, hjust = 0.5))
  )

# 保存图表
ggsave("Results/Figure1_OCT_Impact_Separate.jpg", combined_plot, width = 14, height = 12, dpi = 300)
ggsave("Results/Figure1_OCT_Impact_Separate.pdf", combined_plot, width = 14, height = 12)

# 添加参考文献文本
ref_text <- "1. O'u.e.K. et al. / Am Coll Cardiol, 2020 Oct. 76; 17. Supplement S) B175-E175."
writeLines(ref_text, "Results/Figure1_Reference.txt")

# 显示图表
print(combined_plot)


# 设置工作目录和清理环境
rm(list = ls())
if (!is.null(dev.list())) dev.off()
setwd("C:/Users/hyy/Desktop/")

# 创建结果文件夹
if (!dir.exists("Results")) dir.create("Results")

# 加载必要的包
if (!require(pacman)) install.packages("pacman")
pacman::p_load(ggplot2, dplyr, tidyr, gridExtra, showtext, scales, patchwork, grid)

# 添加中文字体支持
font_add("SimSun""simsun.ttc")
showtext_auto()

# 创建数据框
data <- data.frame(
  Category = c("Lesion Type (A, B, C)""Lesion Morphology""Treat Peradenopathy"
               "Vessel Prep""Treatment Type""Number of Stents""Stent Length",
               "Edge Detection""Malapposition""Underexpansion""Geographic Miss""Other"),
  Pre_PCI = c(48, 22, 28, 2, 8, 11, 0, 0, 0, 0, 0, 0),  # 前6个有数据,后面为0
  Post_PCI = c(0, 0, 0, 0, 0, 0, 25, 4, 11, 2, 3, 0)    # 后6个有数据,前面为0
)

# 计算累计百分比
data$Pre_PCI_Cumulative <- cumsum(data$Pre_PCI)
data$Post_PCI_Cumulative <- cumsum(data$Post_PCI)

# 将数据转换为长格式
data_long <- data %>%
  pivot_longer(cols = c(Pre_PCI, Post_PCI), 
               names_to = "Procedure"
               values_to = "Percentage")

# 创建累计百分比的长格式数据
cumulative_long <- data %>%
  pivot_longer(cols = c(Pre_PCI_Cumulative, Post_PCI_Cumulative), 
               names_to = "Procedure_Cumulative"
               values_to = "Cumulative_Percentage") %>%
  mutate(Procedure = ifelse(Procedure_Cumulative == "Pre_PCI_Cumulative""Pre_PCI""Post_PCI"))

# 创建颜色方案
pre_colors <- c("#1f77b4""#aec7e8""#ff7f0e""#ffbb78""#2ca02c""#98df8a")
post_colors <- c("#d62728""#ff9896""#9467bd""#c5b0d5""#8c564b""#c49c94")

# 创建Pre-PCI柱状图和折线图
pre_data <- data_long %>% 
  filter(Procedure == "Pre_PCI", Percentage > 0) %>%
  mutate(Category = factor(Category, levels = Category))

pre_cumulative <- cumulative_long %>% 
  filter(Procedure == "Pre_PCI", Cumulative_Percentage > 0)

pre_plot <- ggplot(pre_data, aes(x = Category, y = Percentage)) +
  geom_bar(stat = "identity", width = 0.7, fill = pre_colors[1:nrow(pre_data)]) +
  geom_line(data = pre_cumulative, aes(x = Category, y = Cumulative_Percentage, group = 1), 
            color = "black", size = 1.5) +
  geom_point(data = pre_cumulative, aes(x = Category, y = Cumulative_Percentage), 
             color = "black", size = 3) +
  labs(title = "Pre-PCI OCT Impact (83%)",
       x = "", y = "Percentage") +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
    axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 12),
    legend.position = "none"
  ) +
  geom_text(aes(label = paste0(Percentage, "%")), 
            vjust = -0.5, size = 4, fontface = "bold") +
  geom_text(data = pre_cumulative, aes(x = Category, y = Cumulative_Percentage, 
                                       label = paste0(Cumulative_Percentage, "%")), 
            vjust = -1, size = 4, fontface = "bold", color = "black") +
  ylim(0, max(pre_cumulative$Cumulative_Percentage) * 1.2)
pre_plot

# 创建Post-PCI柱状图和折线图
post_data <- data_long %>% 
  filter(Procedure == "Post_PCI", Percentage > 0) %>%
  mutate(Category = factor(Category, levels = Category))

post_cumulative <- cumulative_long %>% 
  filter(Procedure == "Post_PCI", Cumulative_Percentage > 0)

post_plot <- ggplot(post_data, aes(x = Category, y = Percentage)) +
  geom_bar(stat = "identity", width = 0.7, fill = post_colors[1:nrow(post_data)]) +
  geom_line(data = post_cumulative, aes(x = Category, y = Cumulative_Percentage, group = 1), 
            color = "black", size = 1.5) +
  geom_point(data = post_cumulative, aes(x = Category, y = Cumulative_Percentage), 
             color = "black", size = 3) +
  labs(title = "Post-PCI OCT Impact (31%)",
       x = "", y = "Percentage") +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
    axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 12),
    legend.position = "none"
  ) +
  geom_text(aes(label = paste0(Percentage, "%")), 
            vjust = -0.5, size = 4, fontface = "bold") +
  geom_text(data = post_cumulative, aes(x = Category, y = Cumulative_Percentage, 
                                        label = paste0(Cumulative_Percentage, "%")), 
            vjust = -1, size = 4, fontface = "bold", color = "black") +
  ylim(0, max(post_cumulative$Cumulative_Percentage) * 1.2)
post_plot

# 创建组合数据用于总折线图
combined_data <- data.frame(
  Procedure = rep(c("Pre-PCI""Post-PCI"), each = 6),
  Category = c(
    "Lesion Type (A, B, C)""Lesion Morphology""Treat Peradenopathy"
    "Vessel Prep""Treatment Type""Number of Stents",
    "Stent Length""Edge Detection""Malapposition"
    "Underexpansion""Geographic Miss""Other"
  ),
  Percentage = c(48, 22, 28, 2, 8, 11, 25, 4, 11, 2, 3, 0)
)

# 创建总折线图
line_plot <- ggplot(combined_data, aes(x = Category, y = Percentage, group = Procedure, color = Procedure)) +
  geom_line(size = 1.5) +
  geom_point(size = 3) +
  scale_color_manual(values = c("Pre-PCI" = "#1f77b4""Post-PCI" = "#d62728")) +
  labs(title = "OCT Impact Comparison: Pre-PCI vs Post-PCI",
       x = "Category", y = "Percentage") +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
    axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 12),
    legend.position = "bottom"
  )
line_plot

# 使用grid.arrange而不是patchwork来组合图表
combined_grob <- arrangeGrob(
  arrangeGrob(pre_plot, post_plot, nrow = 1),
  line_plot,
  nrow = 2,
  top = textGrob("OCT-derived information changes angiographic-based decisions in 88% of lesions"
                 gp = gpar(fontsize = 16, fontface = "bold")),
  bottom = textGrob("N=552 | Omni-arrive OCT impact through progression of workflow"
                    gp = gpar(fontsize = 12))
)

# 保存图表
ggsave("Results/Figure1_OCT_Impact_With_Cumulative.jpg", combined_grob, width = 16, height = 12, dpi = 300)
ggsave("Results/Figure1_OCT_Impact_With_Cumulative.pdf", combined_grob, width = 16, height = 12)

# 添加参考文献文本
ref_text <- "1. O'u.e.K. et al. / Am Coll Cardiol, 2020 Oct. 76; 17. Supplement S) B175-E175."
writeLines(ref_text, "Results/Figure1_Reference.txt")

# 显示图表
grid.draw(combined_grob)


# 设置工作目录和清理环境
rm(list = ls())
if (!is.null(dev.list())) dev.off()
setwd("C:/Users/hyy/Desktop/")

# 创建结果文件夹
if (!dir.exists("Results")) dir.create("Results")

# 加载必要的包
if (!require(pacman)) install.packages("pacman")
pacman::p_load(ggplot2, dplyr, tidyr, showtext, scales, patchwork)

# 添加中文字体支持
font_add("SimSun""simsun.ttc")
showtext_auto()

# 创建数据框
data <- data.frame(
  Category = c("Lesion Type (A, B, C)""Lesion Morphology""Treat Peradenopathy"
               "Vessel Prep""Treatment Type""Number of Stents""Stent Length",
               "Edge Detection""Malapposition""Underexpansion""Geographic Miss""Other"),
  Pre_PCI = c(48, 22, 28, 2, 8, 11, 0, 0, 0, 0, 0, 0),  # 前6个有数据,后面为0
  Post_PCI = c(0, 0, 0, 0, 0, 0, 25, 4, 11, 2, 3, 0)    # 后6个有数据,前面为0
)

# 计算累计百分比
data$Pre_PCI_Cumulative <- cumsum(data$Pre_PCI)
data$Post_PCI_Cumulative <- cumsum(data$Post_PCI)

# 将数据转换为长格式
data_long <- data %>%
  pivot_longer(cols = c(Pre_PCI, Post_PCI), 
               names_to = "Procedure"
               values_to = "Count")

# 创建颜色方案
pre_colors <- "#1f77b4"  # Pre-PCI颜色
post_colors <- "#d62728" # Post-PCI颜色

# 创建合并的图表
combined_plot <- ggplot() +
  # Pre-PCI柱状图
  geom_bar(data = filter(data_long, Procedure == "Pre_PCI", Count > 0), 
           aes(x = Category, y = Count, fill = "Pre-PCI"), 
           stat = "identity", width = 0.7, alpha = 0.7) +
  # Pre-PCI累计线
  geom_line(data = filter(data, Pre_PCI > 0), 
            aes(x = Category, y = Pre_PCI_Cumulative, group = 1, color = "Pre-PCI Cumulative"), 
            size = 1.5) +
  geom_point(data = filter(data, Pre_PCI > 0), 
             aes(x = Category, y = Pre_PCI_Cumulative, color = "Pre-PCI Cumulative"), 
             size = 3) +
  # Post-PCI柱状图
  geom_bar(data = filter(data_long, Procedure == "Post_PCI", Count > 0), 
           aes(x = Category, y = Count, fill = "Post-PCI"), 
           stat = "identity", width = 0.7, alpha = 0.7) +
  # 添加标志线分隔Pre和Post
  geom_vline(xintercept = 6.5, linetype = "dashed", color = "black", size = 1) +
  # 添加百分比标签
  geom_text(data = filter(data_long, Procedure == "Pre_PCI", Count > 0), 
            aes(x = Category, y = Count, label = paste0(Count, "%")), 
            vjust = -0.5, size = 4, fontface = "bold") +
  geom_text(data = filter(data_long, Procedure == "Post_PCI", Count > 0), 
            aes(x = Category, y = Count, label = paste0(Count, "%")), 
            vjust = -0.5, size = 4, fontface = "bold") +
  # 添加累计百分比标签
  geom_text(data = filter(data, Pre_PCI > 0), 
            aes(x = Category, y = Pre_PCI_Cumulative, label = paste0(Pre_PCI_Cumulative, "%")), 
            vjust = -1, size = 4, fontface = "bold", color = "#1f77b4") +
  geom_text(data = filter(data, Post_PCI > 0), 
            aes(x = Category, y = Post_PCI_Cumulative, label = paste0(Post_PCI_Cumulative, "%")), 
            vjust = -1, size = 4, fontface = "bold", color = "#d62728") +
  # 设置颜色
  scale_fill_manual(name = "Procedure"
                    values = c("Pre-PCI" = pre_colors, "Post-PCI" = post_colors)) +
  scale_color_manual(name = "Cumulative"
                     values = c("Pre-PCI Cumulative" = "#1f77b4"
                                "Post-PCI Cumulative" = "#d62728")) +
  # 标题和标签
  labs(title = "OCT-derived information changes angiographic-based decisions in 88% of lesions",
       subtitle = "N=552 | Omni-arrive OCT impact through progression of workflow",
       x = "", y = "Percentage") +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 16, face = "bold", hjust = 0.5),
    plot.subtitle = element_text(size = 12, hjust = 0.5),
    axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 12),
    legend.position = "bottom",
    legend.box = "horizontal"
  ) +
  # 调整Y轴范围以容纳所有标签
  ylim(0, max(c(data$Pre_PCI_Cumulative, data$Post_PCI_Cumulative)) * 1.2) +
  # 添加Pre-PCI和Post-PCI的标题注释
  annotate("text", x = 3.5, y = max(c(data$Pre_PCI_Cumulative, data$Post_PCI_Cumulative)) * 1.1, 
           label = "Impact of Pre PCI OCT: 83%", size = 5, fontface = "bold", color = pre_colors) +
  annotate("text", x = 9.5, y = max(c(data$Pre_PCI_Cumulative, data$Post_PCI_Cumulative)) * 1.1, 
           label = "Impact of Post PCI OCT: 31%", size = 5, fontface = "bold", color = post_colors)
combined_plot

# 保存图表
ggsave("Results/Figure1_OCT_Impact_Combined.jpg", combined_plot, width = 16, height = 10, dpi = 300)
ggsave("Results/Figure1_OCT_Impact_Combined.pdf", combined_plot, width = 16, height = 10)

# 添加参考文献文本
ref_text <- "1. O'u.e.K. et al. / Am Coll Cardiol, 2020 Oct. 76; 17. Supplement S) B175-E175."
writeLines(ref_text, "Results/Figure1_Reference.txt")

# 显示图表
print(combined_plot)



总结

通过本文的详细解析,我们不仅学习了如何绘制专业的医学图表,还了解了数据可视化在医学研究中的重要性。R语言提供了强大而灵活的可视化工具,能够帮助医学研究人员更好地展示和传达他们的研究成果。

无论你是医学研究者还是数据分析师,掌握这些可视化技能都将大大提高你的工作效率和研究影响力。希望本文能够为你提供有用的指导和灵感,在你的研究工作中发挥实际作用。



医学统计数据分析分享交流SPSS、R语言、Python、ArcGis、Geoda、GraphPad、数据分析图表制作等心得。承接数据分析,论文返修,医学统计,机器学习,生存分析,空间分析,问卷分析业务。若有投稿和数据分析代做需求,可以直接联系我,谢谢!



!!!可加我粉丝群!!!

公众号右下角-联系作者,

可加我微信,邀请入粉丝群!

【临床】有临床流行病学数据分析如(t检验、方差分析、χ2检验、logistic回归)、(重复测量方差分析与配对T检验、ROC曲线)、(非参数检验、生存分析、样本含量估计)、(筛检试验:灵敏度、特异度、约登指数等计算)、(绘制柱状图、散点图、小提琴图、列线图等)、机器学习、深度学习、生存分析等需求的同仁们,加入【临床】粉丝群。

【公卫】疾控,公卫岗位的同仁,可以加一下【公卫】粉丝群,分享生态学研究、空间分析、时间序列、监测数据分析、时空面板技巧等工作科研自动化内容。

【生信】有实验室数据分析需求的同仁们,可以加入【生信】粉丝群,交流NCBI(基因序列)、UniProt(蛋白质)、KEGG(通路)、GEO(公共数据集)等公共数据库、基因组学转录组学蛋白组学代谢组学表型组学等数据分析和可视化内容。




往期推荐:【监测预警自动化】系列教程





往期推荐:样本含量估计(样本量计算与功效分析)




往期推荐:SPSS、R语言、Python等临床数据分析专题




往期推荐:科研图表绘制专题





往期推荐:重复测量数据分析专题




往期推荐:生信分析、基因测序数据、实验室数据专题




往期推荐:生存分析及机器学习




往期推荐:二分类因变量机器学习及相关评价可视化




往期推荐:时间序列分析




往期推荐:地统计分析-GIS、地图、相关、聚类、回归




往期推荐:科研自动化探究




往期推荐:趣味阅读


医学统计数据分析工作室分享交流SPSS、R语言、Python、ArcGis、Geoda、GraphPad、数据分析图表制作等心得;承接数据分析,论文修回,医学统计,机器学习、深度学习、生存分析、空间分析,问卷分析业务。欢迎有科研需求的广大医务工作者关注“医学统计数据分析”工作室!!!


【声明】内容源于网络
0
0
医学统计数据分析
分享交流SPSS、R语言、Python、ArcGis、Geoda、GraphPad、数据分析图表制作等心得。承接数据分析,论文返修,医学统计,空间分析,机器学习,生存分析,时间序列,时空面板,深度学习,问卷分析等业务。公众号右下角可联系作者
内容 323
粉丝 0
医学统计数据分析 分享交流SPSS、R语言、Python、ArcGis、Geoda、GraphPad、数据分析图表制作等心得。承接数据分析,论文返修,医学统计,空间分析,机器学习,生存分析,时间序列,时空面板,深度学习,问卷分析等业务。公众号右下角可联系作者
总阅读32
粉丝0
内容323