yuxuan
ICGC数据下载、表达矩阵整理相关内容详见小洁老师“生信星球”公众号的推文《ICGC数据下载和整理》,本整理过程也会用其整理的数据,详见: https://mp.weixin.qq.com/s/F-d9PyEgHNpJn432cszcVA
整理生存信息
#载入所需R包:
rm(list = ls())
library(stringr)
library(tidyverse)
load("RECA_exp_pd_Group.Rdata")
dim(exp)
#> [1] 46881 136
table(Group) #查看肿瘤和正常样本的数量
#> Group
#> normal tumor
#> 45 91
exp <- exp[,Group == "tumor"] #只要肿瘤样本
dim(exp) #查看是否是只有肿瘤样本
#> [1] 46881 91
surv <- data.table::fread('donor.RECA-EU.tsv.gz',data.table = F) #读取有生存信息的表格
colnames(surv) #只有患者icgc_donor_id,无法与exp的列名sample_i匹配,需要把患者id和样品id串联匹配。
#> [1] "icgc_donor_id"
#> [2] "project_code"
#> [3] "study_donor_involved_in"
#> [4] "submitted_donor_id"
#> [5] "donor_sex"
#> [6] "donor_vital_status"
#> [7] "disease_status_last_followup"
#> [8] "donor_relapse_type"
#> [9] "donor_age_at_diagnosis"
#> [10] "donor_age_at_enrollment"
#> [11] "donor_age_at_last_followup"
#> [12] "donor_relapse_interval"
#> [13] "donor_diagnosis_icd10"
#> [14] "donor_tumour_staging_system_at_diagnosis"
#> [15] "donor_tumour_stage_at_diagnosis"
#> [16] "donor_tumour_stage_at_diagnosis_supplemental"
#> [17] "donor_survival_time"
#> [18] "donor_interval_of_last_followup"
#> [19] "prior_malignancy"
#> [20] "cancer_type_prior_malignancy"
#> [21] "cancer_history_first_degree_relative"
sample <- data.table::fread('sample.RECA-EU.tsv.gz',data.table = F)
sample = unite(sample, "sample_id", icgc_specimen_id, icgc_donor_id,remove = FALSE)
sample <- sample[match(colnames(exp),sample$sample_id),]
identical(colnames(exp),sample$sample_id)
#> [1] TRUE
surv <- surv[match(sample$icgc_donor_id,surv$icgc_donor_id),]
rownames(surv) <- sample$sample_id
identical(rownames(surv),colnames(exp))
#> [1] TRUE
colnames(surv)
#> [1] "icgc_donor_id"
#> [2] "project_code"
#> [3] "study_donor_involved_in"
#> [4] "submitted_donor_id"
#> [5] "donor_sex"
#> [6] "donor_vital_status"
#> [7] "disease_status_last_followup"
#> [8] "donor_relapse_type"
#> [9] "donor_age_at_diagnosis"
#> [10] "donor_age_at_enrollment"
#> [11] "donor_age_at_last_followup"
#> [12] "donor_relapse_interval"
#> [13] "donor_diagnosis_icd10"
#> [14] "donor_tumour_staging_system_at_diagnosis"
#> [15] "donor_tumour_stage_at_diagnosis"
#> [16] "donor_tumour_stage_at_diagnosis_supplemental"
#> [17] "donor_survival_time"
#> [18] "donor_interval_of_last_followup"
#> [19] "prior_malignancy"
#> [20] "cancer_type_prior_malignancy"
#> [21] "cancer_history_first_degree_relative"
#挑选所需要的列:
surv2 <- surv[,c(
'donor_sex', #性别
'donor_age_at_diagnosis', #诊断时患者年龄
'donor_vital_status', #生存状态
'donor_survival_time', #患者生存时间
'donor_tumour_stage_at_diagnosis' #TNM分期
)]
#生死转换为二分类数值0和1:
status <- surv2$donor_vital_status
table(status)
#> status
#> alive deceased
#> 61 30
surv2$donor_vital_status <- ifelse(surv2$donor_vital_status == "alive",0,1)
table(surv2$donor_vital_status) #61生,30死
#>
#> 0 1
#> 61 30
surv2$donor_survival_time <- surv2$donor_survival_time/30
#2.AJCC肾癌TNM分期整理成临床分期(2017版):
surv2$T_satge <- substr(surv2$donor_tumour_stage_at_diagnosis,1,2)#提取T stage
table(surv2$T_satge)
#>
#> T1 T2 T3 T4
#> 54 13 22 2
surv2$N_stage <- substr(surv2$donor_tumour_stage_at_diagnosis,3,4) #提取N stage
table(surv2$N_stage)
#>
#> N0 N1 NX
#> 79 2 10
surv2$M_stage <- substr(surv2$donor_tumour_stage_at_diagnosis,5,6) #提取M_stage
table(surv2$M_stage)
#>
#> M0 M1 MX
#> 81 9 1
surv2$stage <- ifelse(
surv2$T_satge=='T1'&surv2$N_stage=='N0'&surv2$M_stage=='M0','I',
ifelse(surv2$T_satge=='T2'&surv2$N_stage=='N0'&surv2$M_stage=='M0','II',
ifelse(surv2$T_satge=='T3'&surv2$N_stage=='N0'&surv2$M_stage=='M0','III',
ifelse(surv2$T_satge%in%c('T1','T2','T3')&surv2$N_stage=='N1'&surv2$M_stage=='M0','III',
ifelse(surv2$T_satge=='T4','IV',
ifelse(surv2$M_stage=='M1','IV','')))))
)
table(surv2$stage)#由于TNM分期中存在NX和MX,所以有9个样本无法确定总临床分期。
#>
#> I II III IV
#> 9 48 12 13 9
#提取和简化列名
colnames(surv2)
#> [1] "donor_sex" "donor_age_at_diagnosis"
#> [3] "donor_vital_status" "donor_survival_time"
#> [5] "donor_tumour_stage_at_diagnosis" "T_satge"
#> [7] "N_stage" "M_stage"
#> [9] "stage"
surv2 <- surv2[,c(
"donor_sex",
"donor_age_at_diagnosis",
"donor_vital_status",
"donor_survival_time",
"donor_tumour_stage_at_diagnosis",
"stage")]
colnames(surv2) <- c("gender","age","event","time","TNM","stage")
identical(colnames(exp),rownames(surv2))
#> [1] TRUE
surv <- surv2
save(exp,pd,surv,file = c('ICGC_RECA_exp_surv.Rdata'))