我需要进行生存分析,以发现特定途径活动与患者生存之间的显着关联。我正在尝试使用本教程https://github.com/mforde84/RNAseq-Survival-Analysis-TCGA-KIRC/blob/master/survival_rnaseq_analysis.R进行分析。 我有两个文件:临床数据和uni_vals。我认为生存分析部分存在问题。该消息如下:“时间错误[[i]] <-sort(unique(y [who,1])): 尝试在integerOneIndex中选择少于一个元素”
structure(list(Tumor_Sample_Barcode = structure(c(126L, 128L, 133L), .Label = c("TCGA-A7-A0CE", "TCGA-A7-A0CH",
"TCGA-A7-A0DC"), class = "factor"),
classification_of_tumor = structure(c(1L, 1L, 1L), .Label = "not reported", class = "factor"),
last_known_disease_status = structure(c(1L, 1L,1L
), .Label = "not reported", class = "factor"), updated_datetime = structure(c(1L,
1L, 1L), .Label = "2018-01-19T13:39:21.801433-06:00", class = "factor"),
primary_diagnosis = structure(c(6L, 6L, 6L), .Label = c("C50.2",
"C50.3", "C50.4", "C50.5", "C50.8", "C50.9", "C50.919"), class = "factor")), row.names = c(NA,5L), class = c("data.table", "data.frame"))
structure(list(`TCGA-A7-A0CE` = c(0.800945270510658, 0.99887793401069,
0.667341683672123, 0.999999999314536, 0.999999999314536), `TCGA-A7-A0CE.1` = c(0.778700980142054,
0.998594728888895, 0.762898025094707, 0.999999999620033, 0.999999999620033
), `TCGA-A7-A0CH` = c(0.608118239725987, 0.992929539569249, 0.706256002082062,
0.999999998256691, 0.999999998256691), `TCGA-A7-A0CH.1` = c(0.899309224249365,
0.999869380713655, 0.797778413011216, 0.9999999997944, 0.9999999997944
), `TCGA-A7-A0DC` = c(0.535342987646728, 0.993464915142776, 0.409818699577936,
0.999999996633627, 0.999999996633627)), row.names = c("Lipid degradation",
"Lipid metabolism", "Chemotaxis", "Transcription regulation",
"Transcription"), class = "data.frame")
n_index <- which(substr(colnames(uni_vals),14,14) == '1')
t_index <- which(substr(colnames(uni_vals),14,14) == '0')
all_clin < -data.frame(cbind(clinical[,7],clinical[,10],clinical[,22]))
colnames(all_clin) <- c("new_tumor_days", "death_days", "followUp_days")
rownames(all_clin) <- clinical$Tumor_Sample_Barcode
all_clin$new_time <- c() for (i in 1:length(as.numeric(as.character(all_clin$new_tumor_days)))){all_clin$new_time[i] <-ifelse(is.na(as.numeric(as.character(all_clin$new_tumor_days))[i]),
as.numeric(as.character(all_clin$followUp_days))[i],
as.numeric(as.character(all_clin$new_tumor_days))[i])}
all_clin$new_death <- c()
for (i in 1:length(as.numeric(as.character(all_clin$death_days)))){
all_clin$new_death[i] <- ifelse(is.na(as.numeric(as.character(all_clin$death_days))[i]),
as.numeric(as.character(all_clin$followUp_days))[i],
as.numeric(as.character(all_clin$death_days))[i])
}
all_clin$death_event <- ifelse(clinical$vital == "alive", 0, 1)
colnames(uni_vals) <- gsub("\\.","-",substr(colnames(uni_vals),1,12))
ind_tum <- which(unique(colnames(uni_vals)) %in% rownames(all_clin))
ind_clin <- which(rownames(all_clin) %in% colnames(uni_vals))
ind_func <- which(rownames(uni_vals) == "Lipid degradation")
event_uni <- t(apply(uni_vals, 1, function(x) ifelse(abs(x) <0.01,1,0)))
s <- survfit(Surv(as.numeric(as.character(all_clin$new_death))[ind_clin],
all_clin$death_event[ind_clin]) ~ event_uni[ind_func, ind_tum])
s1 <- tryCatch( survdiff(Surv(as.numeric(as.character(all_clin$new_death))[ind_clin],
all_clin$death_event[ind_clin]) ~ event_uni[ind_func, ind_tum]),
error = function(e)
return(NA))