This is a reformatting of the data from Tromp, et al. in JACC: Heart Failure (J Am Coll Cardiol HF 2022 10:73-84)
https://www.jacc.org/doi/10.1016/j.jchf.2021.09.004
First step is to a load a spreadsheet with the hazard ratios and confidence intervals which were extracted semi-manually from the PDF of the paper.
wb <- loadWorkbook("Raw Data.xlsx")
sheets <- names(getSheets(wb))
all.dat <- lapply(sheets,FUN=function(s) data.frame(endpt=s,read.xlsx("Raw Data.xlsx",sheetName=s))) %>% reduce(.f=bind_rows)
Next step is to split up the parts of the hazard ratio and convert these to beta coefficients and standard errors for those betas. We then use those to compute the differences for all comparisons and estimate the standard errors for all the differences (assuming covariances are all zero).
all.dat <- all.dat %>% mutate(id=row_number(),
HR=as.numeric(substr(HR..95..CI.,1,4)),
HR.lcl=as.numeric(substr(HR..95..CI.,7,10)),
HR.ucl=as.numeric(substr(HR..95..CI.,12,15)),
beta=log(HR),
beta.ste=(log(HR.ucl/HR.lcl))/(qnorm(0.975)-qnorm(0.025)),
beta.var=beta.ste**2) %>%
select(-"HR..95..CI.") %>% relocate(id, .before="endpt")
beta.diff <- expand.grid(id1=1:nrow(all.dat),id2=1:nrow(all.dat)) %>%
mutate(endpt1=all.dat$endpt[id1],endpt2=all.dat$endpt[id2],
tx1=all.dat$Treatment[id1],tx2=all.dat$Treatment[id2],
diff=all.dat$beta[id2]-all.dat$beta[id1],
diff.var=all.dat$beta.var[id2]+all.dat$beta.var[id1],
diff.ste=sqrt(diff.var),
diff.z=diff/diff.ste,
diff.p=pnorm(-abs(diff.z)),
diff.HR=exp(diff)) %>%
filter(endpt1==endpt2)
Here we plot the hazard ratios for all comparisons for each of the three sets of endpoints. The yellow outlines indicate hazard ratios which have P<0.05 (under assumption of no covariance between beta coefficients - which is a fairly unsupported assumption, I think). The text of the hazard ratios is white or black for ease of reading only and does not indicate anything other than a difference in beta coefficients of more than 0.5 (arbitrary magnitude where I thought the color shift from black to white would help legibility of the text).
beta.plots <- beta.diff %>% group_by(endpt1) %>% group_split() %>% lapply(FUN=function(ds) {
ds <- ds %>% arrange(-diff)
tx.order <- unique(ds$tx1)
ds <- ds %>% mutate(tx1=factor(tx1,levels=tx.order,ordered=TRUE),
tx2=factor(tx2,levels=tx.order,ordered=TRUE)) %>% filter(tx1>=tx2)
ds %>% ggplot(aes(x=tx1,y=tx2,fill=diff,color=ifelse(diff.p<0.05,"yellow",NA), label=sprintf("%0.2f",diff.HR))) +
geom_tile() +
geom_text(aes(colour=ifelse(abs(diff)>0.5,"white","black"))) +
scale_colour_identity() +
scale_fill_gradient2() +
scale_y_discrete(position="right") +
coord_equal() +
theme_minimal() +
theme(axis.title=element_blank(), axis.text.x=element_text(angle=90,vjust=0.5,hjust=1),legend.position="none") +
ggtitle(ds$endpt1[1])
})
for(i in 1:length(beta.plots)) print(beta.plots[[i]])