In [1]:
library(data.table)
In [2]:
sms <- list.files("/media/igna/Elements/HotelDieu/Cochrane/MappingRCTs_vs_Burden/Replicates/Metrics_over_repl/")
In [3]:
dis <- as.numeric(substr(sms,25,nchar(sms)-4))
dis
In [4]:
Mgbd <- read.table("../Data/27_gbd_groups.txt")
In [5]:
k <- 1
DF <- fread(paste(c("/media/igna/Elements/HotelDieu/Cochrane/MappingRCTs_vs_Burden/Replicates/Metrics_over_repl/Metrics_over_replicates_",
as.character(k),".txt"),collapse=""))
regs <- sort(unique(DF$Region))
regs <- regs[regs!="All"]
In [6]:
data_f <- data.frame()
for(k in dis[dis!=0]){
DF <- fread(paste(c("/media/igna/Elements/HotelDieu/Cochrane/MappingRCTs_vs_Burden/Replicates/Metrics_over_repl/Metrics_over_replicates_",
as.character(k),".txt"),collapse=""))
DFr <- DF[DF$Region%in%regs & DF$Dis == "dis",]
DFr$RCTs_all <- rep(DF$RCTs[DF$Dis=="dis" & DF$Region=="All"],each=length(regs))
DFr$RCTs_NHI <- rep(DF$RCTs[DF$Dis=="dis" & DF$Region=="Non-HI"],each=length(regs))
DFr$Patients_all <- rep(DF$Patients[DF$Dis=="dis" & DF$Region=="All"],each=length(regs))
DFr$Patients_NHI <- rep(DF$Patients[DF$Dis=="dis" & DF$Region=="Non-HI"],each=length(regs))
df <- data.frame(cbind(regs,as.character(Mgbd$x[k]),
do.call('rbind',by(DFr[DFr$RCTs_all!=0,],
DFr$Region[DFr$RCTs_all!=0],
function(x){100*quantile(x$RCTs/x$RCTs_all,probs=c(0.025,0.5,0.975))})),
do.call('rbind',by(DFr[DFr$Patients_all!=0,],
DFr$Region[DFr$Patients_all!=0],
function(x){100*quantile(x$Patients/x$Patients_all,probs=c(0.025,0.5,0.975))})),
do.call('rbind',by(DFr[DFr$RCTs_NHI!=0,],
DFr$Region[DFr$RCTs_NHI!=0],
function(x){100*quantile(x$RCTs/x$RCTs_NHI,probs=c(0.025,0.5,0.975))})),
do.call('rbind',by(DFr[DFr$Patients_NHI!=0,],
DFr$Region[DFr$Patients_NHI!=0],
function(x){100*quantile(x$Patients/x$Patients_NHI,probs=c(0.025,0.5,0.975))})))
)
names(df) <- c("Region","Disease",
paste(paste("Prop_all","RCTs",sep="_"),c("low","med","up"),sep="_"),
paste(paste("Prop_all","Patients",sep="_"),c("low","med","up"),sep="_"),
paste(paste("Prop_NHI","RCTs",sep="_"),c("low","med","up"),sep="_"),
paste(paste("Prop_NHI","Patients",sep="_"),c("low","med","up"),sep="_"))
data_f <- rbind(data_f,df)
}
In [7]:
#All diseases
k <- 0
DF <- fread(paste(c("/media/igna/Elements/HotelDieu/Cochrane/MappingRCTs_vs_Burden/Replicates/Metrics_over_repl/Metrics_over_replicates_",
as.character(k),".txt"),collapse=""))
DFr <- DF[DF$Region%in%regs,]
DFr$RCTs_all <- rep(DF$RCTs[DF$Region=="All"],each=length(regs))
DFr$RCTs_NHI <- rep(DF$RCTs[DF$Region=="Non-HI"],each=length(regs))
DFr$Patients_all <- rep(DF$Patients[DF$Region=="All"],each=length(regs))
DFr$Patients_NHI <- rep(DF$Patients[DF$Region=="Non-HI"],each=length(regs))
df <- data.frame(cbind(regs,"All",
do.call('rbind',by(DFr[DFr$RCTs_all!=0,],
DFr$Region[DFr$RCTs_all!=0],
function(x){100*quantile(x$RCTs/x$RCTs_all,probs=c(0.025,0.5,0.975))})),
do.call('rbind',by(DFr[DFr$Patients_all!=0,],
DFr$Region[DFr$Patients_all!=0],
function(x){100*quantile(x$Patients/x$Patients_all,probs=c(0.025,0.5,0.975))})),
do.call('rbind',by(DFr[DFr$RCTs_NHI!=0,],
DFr$Region[DFr$RCTs_NHI!=0],
function(x){100*quantile(x$RCTs/x$RCTs_NHI,probs=c(0.025,0.5,0.975))})),
do.call('rbind',by(DFr[DFr$Patients_NHI!=0,],
DFr$Region[DFr$Patients_NHI!=0],
function(x){100*quantile(x$Patients/x$Patients_NHI,probs=c(0.025,0.5,0.975))})))
)
names(df) <- c("Region","Disease",
paste(paste("Prop_all","RCTs",sep="_"),c("low","med","up"),sep="_"),
paste(paste("Prop_all","Patients",sep="_"),c("low","med","up"),sep="_"),
paste(paste("Prop_NHI","RCTs",sep="_"),c("low","med","up"),sep="_"),
paste(paste("Prop_NHI","Patients",sep="_"),c("low","med","up"),sep="_"))
data_f <- rbind(data_f,df)
In [8]:
rownames(data_f) <- NULL
In [9]:
data_f[data_f$Region%in%c("High-income","Non-HI"),grep("NHI",names(data_f))] <- NA
In [10]:
head(data_f)
In [11]:
write.table(data_f,"../Data/RCTs_and_Patients_prop_among_all_and_HI_median_UI_across_regions_per_disease.txt")
In [ ]: