久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

R語言生存分析

 醫(yī)科研 2021-01-25

  

歡迎來到醫(yī)科研,,這里是白介素2的讀書筆記,,跟我一起聊臨床與科研的故事, 生物醫(yī)學(xué)數(shù)據(jù)挖掘,,R語言,,TCGA,、GEO數(shù)據(jù)挖掘,。

  R語言生存分析 

生存分析是醫(yī)學(xué)數(shù)據(jù)挖掘中的重要內(nèi)容 R語言中用于生存分析的包主要有survival與survminer

library(survival)
library(survminer)
library(RTCGA.clinical)

提取生存信息

應(yīng)用RTCGA.clinical包

Sys.setlocale('LC_ALL','C')
## [1] "C"
survivalTCGA(BRCA.clinical, OV.clinical,
             extract.cols = "admin.disease_code") -> BRCAOV.survInfo
head(BRCAOV.survInfo)
##   times bcr_patient_barcode patient.vital_status admin.disease_code
## 1  3767        TCGA-3C-AAAU                    0               brca
## 2  3801        TCGA-3C-AALI                    0               brca
## 3  1228        TCGA-3C-AALJ                    0               brca
## 4  1217        TCGA-3C-AALK                    0               brca
## 5   158        TCGA-4H-AAAK                    0               brca
## 6  1477        TCGA-5L-AAT0                    0               brca

Surv(OS_time,status)~factor(分組因素)

構(gòu)建生存對象需要生存時間,,生存狀態(tài),,data

fit <- survfit(Surv(times, patient.vital_status) ~ admin.disease_code,
               data = BRCAOV.survInfo)
fit
## Call: survfit(formula = Surv(times, patient.vital_status) ~ admin.disease_code, 
##     data = BRCAOV.survInfo)
#
##                            n events median 0.95LCL 0.95UCL
## admin.disease_code=brca 1098    104   3472    3126    4456
## admin.disease_code=ov    576    297   1354    1229    1470

survminer包可視化:生存對象,,data,risk.table是風(fēng)險表

survminer::ggsurvplot(fit, data = BRCAOV.survInfo, risk.table = TRUE)
Fig1

對生存曲線進(jìn)一步細(xì)節(jié)控制美化

調(diào)整參數(shù)

ggsurvplot(
   fit,                     # 生存對象
   data = BRCAOV.survInfo,  # data. 
   risk.table = TRUE,       # 風(fēng)險表.
   pval = TRUE,             # p-value of log-rank test.
   conf.int = TRUE,         # 95%CI 
                            # 生存曲線的點(diǎn)估計.
   xlim = c(0,2000),        # present narrower X axis, but not affect
                            # survival estimates.
   break.time.by = 500,     # break X axis in time intervals by 500.
   ggtheme = theme_minimal(), # 主題定制.
 risk.table.y.text.col = T, # colour risk table text annotations.
  risk.table.y.text = FALSE # show bars instead of names in text annotations
                            # in legend of risk table
)
image.png

基礎(chǔ)版本的生存曲線

library("survival")
head(lung)
##   inst time status age sex ph.ecog ph.karno pat.karno meal.cal wt.loss
## 1    3  306      2  74   1       1       90       100     1175      NA
## 2    3  455      2  68   1       0       90        90     1225      15
## 3    3 1010      1  56   1       0       90        90       NA      15
## 4    5  210      2  57   1       1       90        60     1150      11
## 5    1  883      2  60   1       0      100        90       NA       0
## 6   12 1022      1  74   1       1       50        80      513       0
fit<- survfit(Surv(time, status) ~ sex, data = lung)

繪圖

ggsurvplot(fit, data = lung)
image.png

定制版的生存曲線

ggsurvplot(fit, data = lung,
   title = "Survival curves", subtitle = "Based on Kaplan-Meier estimates",#標(biāo)題
   caption = "created with survminer",#說明-右下角
   font.title = c(16, "bold""darkblue"),#標(biāo)題字體
   font.subtitle = c(15, "bold.italic""purple"),#副標(biāo)題字體
   font.caption = c(14, "plain""orange"),#說明字體
   font.x = c(14, "bold.italic""red"),#x軸字體
   font.y = c(14, "bold.italic""darkred"),#y軸字體
   font.tickslab = c(12, "plain""darkgreen"))#
image.png

風(fēng)險表risk.table

ggsurvplot(fit, data = lung, risk.table = TRUE)
image.png

ncens plot-展示刪失數(shù)據(jù)的情況 這個功能在文章里面見得比較少,但是也能畫

ggsurvplot(fit, data = lung, risk.table = TRUE, ncensor.plot = TRUE)
image.png

    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多