-
Notifications
You must be signed in to change notification settings - Fork 2
/
chemoResponse.R
29 lines (27 loc) · 1.25 KB
/
chemoResponse.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
library("TCGAbiolinks")
# 1) receive pid from TCGAbiolinks
pid<-TCGAbiolinks:::getGDCprojects()$project_id
pid<-pid[grep("TCGA",pid)]
# 1) receive pid from github
pid<-read.table("https://raw.githubusercontent.com/Shicheng-Guo/HowtoBook/master/TCGA/drug_response/Pid.drugResponse.txt",head=F,sep="\t")
pid<-as.character(pid[,1])
drug2csv<-function(clinical.drug){
bcr_patient_barcode<-clinical.drug$bcr_patient_barcode
therapy_types<-clinical.drug$therapy_types
drug_name<-clinical.drug$drug_name
measure_of_response<-clinical.drug$measure_of_response
days_to_drug_therapy_start<-clinical.drug$days_to_drug_therapy_start
days_to_drug_therapy_end<-clinical.drug$days_to_drug_therapy_end
therapy_ongoing<-clinical.drug$therapy_ongoing
new.clinical.drug<-data.frame(bcr_patient_barcode,therapy_types,drug_name,measure_of_response,days_to_drug_therapy_start,days_to_drug_therapy_end,therapy_ongoing)
return(new.clinical.drug)
}
rlt<-c()
for(i in pid){
query <- GDCquery(project=i,data.category = "Clinical",file.type = "xml")
GDCdownload(query)
clinical.drug <- GDCprepare_clinic(query,"drug")
drugResponse<-drug2csv(clinical.drug)
rlt<-rbind(rlt,drugResponse)
}
write.table(rlt,file="Pancancer.drugresponse.txt",sep="\t",col.names=NA,row.names=T,quote=F)