Skip to content

Instantly share code, notes, and snippets.

@tiagochst
Last active November 22, 2017 18:39
Show Gist options
  • Save tiagochst/05d37b42d5373f13dc0adef637a5efee to your computer and use it in GitHub Desktop.
Save tiagochst/05d37b42d5373f13dc0adef637a5efee to your computer and use it in GitHub Desktop.
Find most significant mutations for survival
require(maftools)
maf <- GDCquery_Maf("COAD",pipelines = "mutect2")
clinic <- GDCquery_clinic("TCGA-COAD")
colnames(clinic)[1] <- "Tumor_Sample_Barcode"
clinic$Overall_Survival_Status <- 1
clinic$Overall_Survival_Status[which(clinic$vital_status != "dead")] <- 0
clinic$time <- clinic$days_to_death
clinic$time[is.na(clinic$days_to_death)] <- clinic$days_to_last_follow_up[is.na(clinic$days_to_death)]
acc <- read.maf(maf = maf, clinicalData = clinic,isTCGA = T)
genes <- getGeneSummary(acc)$Hugo_Symbol[1:20]
tbl <- plyr::adply(genes,1, function(x){
surv = mafSurvival(maf = acc,
genes = x,
fn = x,
time = 'time',
Status = 'Overall_Survival_Status',
isTCGA = TRUE)
pvalue <- surv$labels$subtitle
pvalue
},.progress = "text")
tbl$X1 <- genes
colnames(tbl) <- c("gene","pvalue")
tbl$pvalue <- gsub("P-value: ","",tbl$pvalue )
tbl$pvalue <- as.numeric(tbl$pvalue)
tbl <- tbl[order(tbl$pvalue),]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment