Survival analysis: data clinical and pathways
1
3
Entering edit mode
5.3 years ago
fp89 ▴ 30

Hello, I need to perform survival analysis to find significant associations of specific pathway activities to patient survival. I'm trying to perform the analysis using this tutorial https://github.com/mforde84/RNAseq-Survival-Analysis-TCGA-KIRC/blob/master/survival_rnaseq_analysis.R. I have two files: clinical data and uni_vals. There is something wrong I think in the part of survival analysis. The message is the following:"Error in time[[i]] <- sort(unique(y[who, 1])) : attempt to select less than one element in integerOneIndex"

1)clinical data

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"))

2)uni_vals

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")

3) my code

get the index of the normal/control samples

n_index <- which(substr(colnames(uni_vals),14,14) == '1')
t_index <- which(substr(colnames(uni_vals),14,14) == '0')

input clinical information

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

time to tumor

all_clin$new_time <- c()
for (i in 1:length(as.numeric(as.character(all_clin$new_tumor_days)))){all_clin$new_time[i] <- ifelseis.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])

}

time to death

all_clin$new_death <- c()
for (i in 1:length(as.numeric(as.character(all_clin$death_days)))){
  all_clin$new_death[i] <-ifelseis.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])

}

death censor event

all_clin$death_event <- ifelse(clinical$vital == "alive", 0, 1)

filtering

colnames(uni_vals) <- gsub("\\.","-",substr(colnames(uni_vals),1,12))

match all_clin and uni_vals

ind_tum <- which(unique(colnames(uni_vals)) %in% rownames(all_clin))
ind_clin <- which(rownames(all_clin) %in% colnames(uni_vals))

function of interest

ind_func <- which(rownames(uni_vals) == "Lipid degradation")

create event vector for uni data

event_uni <- t(apply(uni_vals, 1, function(x) ifelse(abs(x) <0.01,1,0)))

survival analysis

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)

)

R survival analysis data clinical pathways • 2.0k views
ADD COMMENT
0
Entering edit mode
5.2 years ago
zx8754 11k

The error is explained at SO:

You are accessing 0th index of a list. In R indexing starts at 1. Try to find out where this is happening in your code or on that GitHub code.

ADD COMMENT

Login before adding your answer.

Traffic: 2272 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6