某个基因与生存相关性曲线绘制
2021-01-12 本文已影响0人
Hayley笔记
某个基因与生存相关性曲线绘制
学习R包ggstatsplot,survival,survminer
- 数据 准备:
矩阵"BLCA_93663_50_50.csv"下载自Oncolnc 生存分析在线工具
基因:ARHGAP18
Cancer:BLCA
- 代码:
rm(list = ls())
library(readr)
dat <- read_csv("Desktop/007/BLCA_93663_50_50.csv")
View(dat)
library(ggstatsplot)
#查看高/低表达组的表达情况,x也可以是状态或生存日期等
ggbetweenstats(data=dat,x = Group, y = 'Expression')
ggsave('Group_Expression_ARHGAP18.png')
Group_Expression_ARHGAP18.png
ggbetweenstats(data=dat,x = Status, y = 'Expression')
ggsave('Status_Expression_ARHGAP18.png')
Status_Expression_ARHGAP18.png
#生存曲线绘制
library(ggplot2)
library(survival)
library(survminer)
table(dat$Status)
dat$Status=ifelse(dat$Status=='Dead',1,0)
sfit <- survfit(Surv(Days, Status)~Group,data=dat)
sfit
summary(sfit)
ggsurvplot(sfit, conf.int=F,pval=TRUE)
ggsave('Survival_ARHGAP18_in_BLCA.png')
Survival_ARHGAP18_in_BLCA.png
ggsurvplot(sfit,palette = c("#E7B800","#2E9FDF"),
risk.table = TRUE,pval = TRUE,
conf.int = TRUE,xlab = "Time in months",
ggtheme = theme_light(),
ncensor.plot = TRUE)
ggsave('Survival1_ARHGAP18_in_BLCA.png')
Survival1_ARHGAP18_in_BLCA.png