/
Full_Analysis.Rmd
1059 lines (853 loc) · 44.6 KB
/
Full_Analysis.Rmd
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "PLATCOV Statistical Analysis: Regeneron and Remdesivir"
author: "James Watson"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
html_document:
toc: yes
fig_caption: yes
keep_md: yes
number_sections: yes
pdf_document:
toc: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(cache = F, cache.comments = FALSE,
echo = F, include = TRUE,
fig.width = 8, fig.height = 8,
fig.pos = 'H',dev = 'png', dpi = 300)
library(rstan)
library(loo)
library(RColorBrewer)
library(reshape2)
library(plotrix)
library(brms)
```
# Preamble
This Statistical Analysis Plan (SAP) is written for the PLATCOV trial (registered at ClinicalTrials.gov: <https://clinicaltrials.gov/ct2/show/NCT05041907>).
Data preparation is done in a different R script called data_prep.R. This Markdown script assumes that the data are saved in a .csv file *interim_dat.csv* in long format. The file *interim_dat.csv* contains the patient clinical and viral load data with the following column headers:
- ID: anonymized patient id code
- Time: time from randomization
- Trt: treatment allocation as written in CRF
- Site: site at enrollment
- Timepoint_ID: Day of study (integer 0 to 14)
- BARCODE: unique sample id code (in the following format: PLT-site-number-swab type-timepoint)
- Swab_ID: RTS or TSL (right versus left tonsil)
- Plate: unique Plate ID for the PCR assay (matching with plate identifiers in interim_control_dat.csv)
- Rand_date: date of randomization
- Any_dose: (0/1) any doses of any manufacturer received
- N_dose: integer number of doses received (any manufacturer)
- Antibody_test: 0/1 (negative/positive for SARS-CoV-2 antibody rapid test)
- Weight (kg)
- BMI: kg/weight\^2
- Age: (years - has to be between 18-50)
- Sex: 0/1 (male: 1; female/other: 0)
- Symptom_onset: time since onset of symptoms (days)
- Variant: variant of concern (using standard WHO terminology for the main lineages, reference will be the predominant variant in the data set at the start of the study)
- CT_NS: observed CT value for the N/S gene
- CT_RNaseP: observed CT value for the human RNase P gene
- Per_protocol_sample: whether at the time of sampling the patient was still in per protocol with respect to drug dosing
- IgG: + IgG band on the LFT
- IgM: + IgM band on the LFT
- log10_viral_load: log10 number of viral copies per mL (estimated from control samples using a mixed effects model)
- log10_cens_vl: censoring value
## Computational setup
```{r}
## information on software/hardware used
version
sessionInfo()
study_threshold = 1.125
rstan_options(auto_write = TRUE)
## parameters for the analysis
Dmax = 8
RUN_MODELS = F
my_probs = c(0.025, 0.1, .5, .9, .975)
source('functions.R')
```
# Overview of data
## Load data
```{r}
platcov_dat = read.csv('Paper2_analysis.csv')
platcov_dat$Rand_date = as.POSIXct(platcov_dat$Rand_date)
# make per protocol summary for all patients
PP=merge(aggregate(Timepoint_ID ~ ID+Trt,
platcov_dat[platcov_dat$Per_protocol_sample==1, ], max),
aggregate(Per_protocol_sample ~ ID, platcov_dat, sum),by = 'ID')
PP$Include_mITT = PP$Timepoint_ID>=2
# We remove patients who only have undetectable virus
xx_undetectble = table(platcov_dat$ID, platcov_dat$CT_NS==40)
ids_neg = names(which(xx_undetectble[,1]==0))
writeLines(sprintf('All negative samples for id: %s', ids_neg))
# Exclude from mITT pop
PP$Include_mITT[PP$ID %in% ids_neg] = F
platcov_dat = platcov_dat[!platcov_dat$ID %in% ids_neg, ]
writeLines(sprintf('PCR database contains data from %s patients',nrow(PP)))
itt_pop = read.csv('ITT_population.csv')
ind_missing = which(!itt_pop$ID %in% PP$ID & (itt_pop$Treatment %in% c('No study drug','Regeneron')))
writeLines(sprintf('we are missing patient %s',itt_pop$ID[ind_missing]))
table(itt_pop$Treatment)
# PLT-TH1-056 dropped out before any swabs were taken
# PLT-TH1-031 also withdrew on first day
platcov_dat = platcov_dat[platcov_dat$ID %in% PP$ID[PP$Include_mITT],]
```
## Data summaries
number of patients by analysis
```{r}
platcov_dat$Remdesivir_analysis =
platcov_dat$Rand_date<as.POSIXct('2022-06-11') & platcov_dat$Trt != 'Regeneron'
platcov_dat$Regeneron_analysis =
platcov_dat$Site != 'br003' & platcov_dat$Trt != 'Remdesivir'
ind_dup = !duplicated(platcov_dat$ID)
IDs = unique(platcov_dat$ID)
writeLines(sprintf('In the remdesivir analysis there are %s patients (%s controls and %s remdesivir)',
length(unique(platcov_dat$ID[platcov_dat$Remdesivir_analysis & ind_dup])),
length(unique(platcov_dat$ID[platcov_dat$Remdesivir_analysis &
ind_dup &
platcov_dat$Trt=='No study drug'])),
length(unique(platcov_dat$ID[platcov_dat$Remdesivir_analysis &
ind_dup &
platcov_dat$Trt=='Remdesivir']))
))
writeLines(sprintf('In the regeneron analysis there are %s patients (%s controls and %s remdesivir)',
length(unique(platcov_dat$ID[platcov_dat$Regeneron_analysis & ind_dup])),
length(unique(platcov_dat$ID[platcov_dat$Regeneron_analysis &
ind_dup &
platcov_dat$Trt=='No study drug'])),
length(unique(platcov_dat$ID[platcov_dat$Regeneron_analysis &
ind_dup &
platcov_dat$Trt=='Regeneron']))
))
```
Display the per protocol matrix
```{r pp}
writeLines('Number of patients per arm in modified intention to treat analysis')
table(PP$Trt, Include_mITT = PP$Include_mITT)
writeLines('Number of swabs per protocol per treatment')
table(PP$Trt, PP_swabs = PP$Per_protocol_sample)
```
```{r data_summaries}
writeLines(sprintf('In the mITT dataset we have %s PCR datapoints on %s patients from %s sites between %s and %s:',
nrow(platcov_dat),
length(IDs),
length(unique(platcov_dat$Site)),
min(platcov_dat$Rand_date),
max(platcov_dat$Rand_date)))
writeLines('N patients in mITT pop by site:')
table(platcov_dat$Site[ind_dup])
# define the major lineages for the pre-specified subgroup analyses
platcov_dat$Greek_Lineage = 'Omicron'
platcov_dat$Greek_Lineage[platcov_dat$Variant=='Delta'] = 'Delta'
platcov_dat$Greek_Lineage =
factor(platcov_dat$Greek_Lineage, levels = c('Delta','Omicron'))
# define the G446S subgroup analyses - post hoc
platcov_dat$G446S_subgroups = 'Omicron_notG446S'
platcov_dat$G446S_subgroups[platcov_dat$Variant=='BA.1'] = 'Omicron_G446S'
platcov_dat$G446S_subgroups[platcov_dat$Variant=='Delta'] = 'Delta'
platcov_dat$G446S_subgroups =
factor(platcov_dat$G446S_subgroups,
levels = c('Delta','Omicron_G446S','Omicron_notG446S'))
table(platcov_dat$Trt[ind_dup], platcov_dat$Variant[ind_dup])
table(platcov_dat$Trt[ind_dup], platcov_dat$Greek_Lineage[ind_dup])
table(platcov_dat$Trt[ind_dup], platcov_dat$G446S_subgroups[ind_dup])
# baseline samples: taken within 6 hours of randomisation
baseline_ind = platcov_dat$Timepoint_ID==0
bvl = aggregate(log10_viral_load ~ ID + Site,
platcov_dat[baseline_ind, ], median)
nrow(bvl) == length(IDs)
writeLines(sprintf('In the %s patients, the geometric mean baseline (defined as samples taken within 6 hours of randomisation) viral load was %s copies per mL (95 percentile interval from %s to %s; range from %s to %s)',
length(IDs),
round(10^mean(bvl$log10_viral_load)),
round(10^(mean(bvl$log10_viral_load)-1.96*sd(bvl$log10_viral_load))),
round(10^(mean(bvl$log10_viral_load)+1.96*sd(bvl$log10_viral_load))),
round(min(10^bvl$log10_viral_load)),
round(max(10^bvl$log10_viral_load))))
```
```{r variants_time}
par(las=1, cex.lab=1.5, cex.axis=1.5, family='serif')
plot(platcov_dat$Rand_date[ind_dup], 1:length(IDs),
col= adjustcolor(as.numeric(as.factor(platcov_dat$Variant[ind_dup])),.5),
pch = 15-platcov_dat$Variant_Imputed[ind_dup]*15+1,
xlab='Enrollment date', ylab='Patient ID',panel.first=grid())
legend('topleft',col = 1:length(unique(platcov_dat$Variant)),cex=1.5,
legend = levels(as.factor(platcov_dat$Variant[ind_dup])),pch=16,inset = 0.03)
legend('left',col=1, pch=c(16,1),legend = c('Genotyped','Imputed\n(based on date)'),inset = 0.03,cex=1.3)
```
Summary table
```{r table1}
plat_summary = aggregate(log10_viral_load ~ ID+Timepoint_ID+Trt+Age+Variant+Rand_date+Weight+Sex+Symptom_onset+Site+N_dose+Antibody_test,
data = platcov_dat, mean)
plat_summary = dplyr::arrange(plat_summary, Site, ID, Rand_date)
write.csv(plat_summary, file = '~/Downloads/platcov_regeneron_remdesivir.csv',quote = F,row.names = F)
platcov_dat$Trt[platcov_dat$Trt=='Regeneron']='Casirivimab\nimdevimab'
print(unique(platcov_dat$Trt))
platcov_dat$Trt_code =
factor(platcov_dat$Trt,
levels=c("No study drug", 'Casirivimab\nimdevimab','Remdesivir'))
ind_dup = !duplicated(platcov_dat$ID)
writeLines(sprintf('female is %s%%',round(100*mean(platcov_dat$Sex[ind_dup]==0))))
writeLines(sprintf('median age is %s (IQR: %s-%s)',median(platcov_dat$Age[ind_dup]),
quantile(platcov_dat$Age[ind_dup],.25),
quantile(platcov_dat$Age[ind_dup],.75)))
writeLines(sprintf('median time since symptom onset is %s (IQR: %s-%s)',median(platcov_dat$Symptom_onset[ind_dup]),
quantile(platcov_dat$Symptom_onset[ind_dup],.25),
quantile(platcov_dat$Symptom_onset[ind_dup],.75)))
writeLines(sprintf('At least 1 vaccine is %s%%',round(100*mean(platcov_dat$N_dose[ind_dup]>0))))
xx=aggregate(log10_viral_load~ID, data=platcov_dat[platcov_dat$Timepoint_ID==0, ],mean)
round(10^quantile(xx$log10_viral_load, probs = c(0.25, .5, .75)))
writeLines('Censored values up until day 7:')
table(platcov_dat$censor[platcov_dat$Time<8])
writeLines(sprintf('The proportion censored is %s%%',round(100*mean(platcov_dat$censor[platcov_dat$Time<8]=='left'),1)))
writeLines('Variants in mITT database:')
table(platcov_dat$Variant[ind_dup])
writeLines('Variants in mITT database by treatment:')
table(platcov_dat$Trt[ind_dup], platcov_dat$Variant[ind_dup])
xx=make_baseline_table(input_data = platcov_dat[platcov_dat$Remdesivir_analysis,])
knitr::kable(xx, caption = sprintf('Summary of patient characteristics included in the final Remdesivir analysis (n= %s). Age: median (range); baseline viral load (log10 copies per mL: mean (range)); vaccinated: %% with any number of doses; number of vaccine doses: median (range); antibody data are from rapid tests done at screening (+ is presence of IgM or IgG band).', sum(PP$Include_mITT)))
xx=make_baseline_table(input_data = platcov_dat[platcov_dat$Regeneron_analysis,])
knitr::kable(xx, caption = sprintf('Summary of patient characteristics included in the final Regeneron analysis (n= %s). Age: median (range); baseline viral load (log10 copies per mL: mean (range)); vaccinated: %% with any number of doses; number of vaccine doses: median (range); antibody data are from rapid tests done at screening (+ is presence of IgM or IgG band).', sum(PP$Include_mITT)))
xx=make_baseline_table(input_data = platcov_dat)
knitr::kable(xx, caption = sprintf('Summary of patient characteristics included in the final mITT populations (all patients; n= %s). Age: median (range); baseline viral load (log10 copies per mL: mean (range)); vaccinated: %% with any number of doses; number of vaccine doses: median (range); antibody data are from rapid tests done at screening (+ is presence of IgM or IgG band).', sum(PP$Include_mITT)))
```
## Summary data plot
This includes all patients in the mITT population with the per protocol swabs.
```{r trt_data_plot}
plot_baseline_data(platcov_dat)
trt_cols = brewer.pal(n = 8,name = 'Set2')[c(1,2,4)]
names(trt_cols) = c('No study drug', 'Remdesivir','Casirivimab\nimdevimab')
par(las=1, cex.lab=1.3, cex.axis=1.3, family='serif', mfrow=c(2,3))
plot_serial_data(xx = platcov_dat[platcov_dat$Remdesivir_analysis,],
trt_cols = trt_cols)
title('All variants')
plot_serial_data(xx = platcov_dat[platcov_dat$Regeneron_analysis,], trt_cols = trt_cols)
title('All variants')
for(vv in unique(platcov_dat$Variant[platcov_dat$Variant!='BA.4'])){
ind = platcov_dat$Variant==vv &
platcov_dat$Regeneron_analysis
plot_serial_data(xx = platcov_dat[ind,],
trt_cols = trt_cols)
title(vv)
}
```
# Model fitting
## Simple model using brms
Did this as a sanity check for handwritten models... basically gives the same results
```{r}
# ind_fit = platcov_dat$Timepoint_ID<14
# platcov_dat$CT_RNaseP_scaled = scale(platcov_dat$CT_RNaseP)
# platcov_dat$Epoch = as.factor(platcov_dat$Epoch)
# platcov_dat$Variant = factor(platcov_dat$Variant,
# levels = c('Delta','BA.1','BA.2','BA.4','BA.5'))
# platcov_dat$Trt = factor(platcov_dat$Trt, levels = c('No study drug','Casirivimab\nimdevimab'))
#
# if(RUN_MODELS){
# mod_naive = brm(log10_viral_load | cens(censor) ~ Time*Trt-Trt +
# Time*Variant+Time*Epoch+CT_RNaseP_scaled+(1+Time|ID),
# data = platcov_dat[ind_fit, ],
# prior = c(prior(lkj(2), class = "cor"),
# prior(normal(5, 5), class = Intercept),
# prior(normal(0,1), class='b'),
# prior(constant(7), class = 'nu')),
# family = 'student', cores = 4, chains = 4)
# save(mod_naive, file = 'Rout/naive_mod.RData')
# } else {
# load( file = 'Rout/naive_mod.RData')
# }
# summary(mod_naive, pars=c('Trt', 'Variant','Epoch'))
# plot(mod_naive, pars=c('Trt', 'Variant','Epoch'), N=4)
```
## Full analysis
The primary analysis consists of fitting a sequence of Bayesian hierarchical models to the mITT population (viral load data up until day 7, only patients who did not leave or switch before day 3).
There are a series of model fits, which are combinations of three models:
- Model 1: vanilla student-t regression with left censoring at 0 and with individual random effects for slope an intercept;
- Model 2: Linear model with additional RNaseP adjustment (this needs special treatment as we need to subtract the effect of RNaseP for the linear predictions);
- Model 3: Non-linear model (up and then down) with RNaseP adjustment.
two sets of priors:
- Weakly informative priors
- Quasi flat prior (multiply SDs by 10)
and two sets of covariate adjustments:
- basic covariate adjustment (slope and intercept):
- Variant (main Greek lineages as defined by WHO)
- Site
- Full covariate adjustment (slope and intercept), adding in:
- Vaccination (number of doses)
- Age (standardized to have mean=0 and sd=1)
- Time since symptom onset (days, between 0 and 4)
## Specify priors
get priors
```{r priors}
source('priors.R')
# print(all_priors)
```
## Prepare models
We make the stan data sets.
```{r make_datasets}
analysis_datasets =
c('Remdesivir',
'Regeneron',
'REGN_Remdesivir_contemporaneous',
'Subgroup_Greek',
'Subgroup_G446S',
'Subgroup_Sublineages',
'Full')
platcov_dat_list = vector(mode = 'list',length = length(analysis_datasets));
names(platcov_dat_list) = analysis_datasets
platcov_dat_list[['Remdesivir']]=
platcov_dat[platcov_dat$Remdesivir_analysis,] # Remdesivir
platcov_dat_list[['Regeneron']]=
platcov_dat[platcov_dat$Regeneron_analysis,] # all Regeneron
platcov_dat_list[['REGN_Remdesivir_contemporaneous']]=
platcov_dat[platcov_dat$Rand_date < '2022-06-11' &
platcov_dat$Site!='br003',] # thai sites where could be randomised to remdesivir or regen-cov
platcov_dat_list[['Subgroup_Greek']]=
platcov_dat[platcov_dat$Regeneron_analysis,] # Regeneron Subgroup analysis based on major Greek Lineage
platcov_dat_list[['Subgroup_G446S']]=
platcov_dat[platcov_dat$Regeneron_analysis,] # Regeneron Subgroup analysis based on G446S mutations
platcov_dat_list[['Subgroup_Sublineages']]=
platcov_dat[platcov_dat$Regeneron_analysis & platcov_dat$Variant!='BA.4',] # Regeneron Subgroup analysis based on Omicron sublineages
platcov_dat_list[['Full']]=platcov_dat # everything
trt_list = vector(mode = 'list',length = length(analysis_datasets));
names(trt_list) = analysis_datasets
trt_list[['Remdesivir']] = c("No study drug", 'Remdesivir')
trt_list[['Regeneron']] = c("No study drug", 'Casirivimab\nimdevimab')
trt_list[['REGN_Remdesivir_contemporaneous']] = c("No study drug", 'Remdesivir',
'Casirivimab\nimdevimab')
trt_list[['Subgroup_Greek']] = c("No study drug", 'Casirivimab\nimdevimab')
trt_list[['Subgroup_G446S']] = c("No study drug", 'Casirivimab\nimdevimab')
trt_list[['Subgroup_Sublineages']] = c("No study drug", 'Casirivimab\nimdevimab')
trt_list[['Full']] = c("No study drug", 'Remdesivir',
'Casirivimab\nimdevimab')
for(dd in analysis_datasets){
writeLines(sprintf('In %s there are %s PCR datapoints and %s patients',
dd,
nrow(platcov_dat_list[[dd]]),
length(unique(platcov_dat_list[[dd]]$ID))))
## re-arrange so that censored values come last
platcov_dat_list[[dd]] =
dplyr::arrange(platcov_dat_list[[dd]],
log10_viral_load==log10_cens_vl)
# any missing timepoints or negative timepoints replace with protocol time
ind_change_time = is.na(platcov_dat_list[[dd]]$Time) | platcov_dat_list[[dd]]$Time <0
platcov_dat_list[[dd]]$Time[ind_change_time] =
platcov_dat_list[[dd]]$Timepoint_ID[ind_change_time]
# Datapoints that will be used in the analysis
ind = platcov_dat_list[[dd]]$Time < Dmax &
platcov_dat_list[[dd]]$Per_protocol_sample==1 &
platcov_dat_list[[dd]]$ID %in% PP$ID[PP$Include_mITT]
platcov_dat_list[[dd]]$Trt = factor(platcov_dat_list[[dd]]$Trt,
levels = trt_list[[dd]])
platcov_dat_list[[dd]]$Variant = factor(platcov_dat_list[[dd]]$Variant,
levels = c('Delta','BA.1','BA.2','BA.4','BA.5'))
platcov_dat_list[[dd]]$Site = factor(platcov_dat_list[[dd]]$Site,
levels = c('th001','th057','th058','br003'))
platcov_dat_list[[dd]] = platcov_dat_list[[dd]][ind, ]
writeLines(sprintf('Analysis dataset contains %s patients and %s datapoints',
length(unique(platcov_dat_list[[dd]]$ID)),
nrow(platcov_dat_list[[dd]])))
}
names(platcov_dat_list) = analysis_datasets
```
```{r make_stan_datasets}
covs_base = c('Variant','Site')
covs_full=c(covs_base, 'Age_scaled','Symptom_onset')
stan_inputs = vector(mode = 'list',length = length(analysis_datasets));
names(stan_inputs) = analysis_datasets
for(dd in analysis_datasets){
stan_inputs[[dd]] =
make_stan_inputs(input_data_fit = platcov_dat_list[[dd]],
int_covs_base = covs_base,
int_covs_full = covs_full,
slope_covs_base = covs_base,
slope_covs_full = covs_full,
trt_frmla = formula('~ Trt'),
Dmax = Dmax)
}
stan_inputs$REGN_Remdesivir_contemporaneous$Trt_matrix =
cbind(stan_inputs$REGN_Remdesivir_contemporaneous$Trt_matrix,
as.numeric(platcov_dat_list$REGN_Remdesivir_contemporaneous$Variant!='Delta' &
platcov_dat_list$REGN_Remdesivir_contemporaneous$Trt=='Casirivimab\nimdevimab'))
stan_inputs$Full$Trt_matrix =
cbind(stan_inputs$Full$Trt_matrix,
as.numeric(platcov_dat_list$Full$Variant!='Delta' &
platcov_dat_list$Full$Trt=='Casirivimab\nimdevimab'))
stan_inputs[['Subgroup_Greek']] =
make_stan_inputs(input_data_fit = platcov_dat_list[['Subgroup_Greek']],
int_covs_base = c('Variant','Site'),
int_covs_full = c('Variant','Site','Symptom_onset',
'Age_scaled'),
slope_covs_base = c('Variant','Site'),
slope_covs_full = c('Variant','Site','Symptom_onset',
'Age_scaled'),
trt_frmla = formula('~ Trt*Greek_Lineage'),
Dmax = Dmax)
stan_inputs[['Subgroup_G446S']] =
make_stan_inputs(input_data_fit = platcov_dat_list[['Subgroup_G446S']],
int_covs_base = 'Site',
int_covs_full = c('Site','Symptom_onset',
'Age_scaled'),
slope_covs_base = 'Site',
slope_covs_full = c('Site','Symptom_onset',
'Age_scaled'),
trt_frmla = formula('~ Trt*G446S_subgroups'),
Dmax = Dmax)
stan_inputs[['Subgroup_Sublineages']] =
make_stan_inputs(input_data_fit = platcov_dat_list[['Subgroup_Sublineages']],
int_covs_base = 'Site',
int_covs_full = c('Site','Symptom_onset',
'Age_scaled'),
slope_covs_base = 'Site',
slope_covs_full = c('Site','Symptom_onset',
'Age_scaled'),
trt_frmla = formula('~ Trt*Variant'),
Dmax = Dmax)
```
## Setup model runs
List all parameters settings for the model fitting:
```{r setup_models}
all_mods = list.files('Stan_models',full.names = TRUE,pattern = '*stan')
model_settings = rbind(expand.grid(mod = all_mods[2:3],
prior = 1:2,
cov_matrices = 1,
dataset = analysis_datasets),
expand.grid(mod = all_mods[2],
prior = 1,
cov_matrices = 2,
dataset = analysis_datasets))
model_settings$Niter = 4000
model_settings$Nwarmup = 2000
model_settings$Nthin = 8
model_settings$Nchain = 4
writeLines(sprintf('We are running all models with %s chains and %s samples for each chain, discarding %s for burn-in and thining every %s, thus giving a total of %s posterior samples per model.',
unique(model_settings$Nchain),
unique(model_settings$Niter),
unique(model_settings$Nwarmup),
unique(model_settings$Nthin),
unique(model_settings$Nchain*(model_settings$Niter-model_settings$Nwarmup)/model_settings$Nthin)))
save(model_settings,
platcov_dat_list,
analysis_datasets,
stan_inputs,
all_priors,
file = 'Rout/model_run_setup.RData')
```
All model fitting is run on a cluster using run_models.R (bmrc.sh provides bash commands)
Load model fits
```{r}
ff = list.files('Rout/')
ff = ff[grep(pattern = 'model_fits_',x = ff)]
if(!length(ff)==nrow(model_settings)) stop('not all outputs are ready for all model settings')
ff = paste0('Rout/',ff)
```
# Results
main models
```{r}
main_mods = model_settings$prior==1&
model_settings$cov_matrices==1&
model_settings$mod==all_mods[2]
model_cols = brewer.pal(n = 5, name = 'Dark2')
names(model_cols) = paste('model', 1:5)
```
## Remdesivir
Plot the remdesivir versus no study drug output
```{r remdesivir_only_analysis}
all_res_rems = which(model_settings$dataset=='Remdesivir')
all_res_rems_main = which(model_settings$dataset=='Remdesivir' & main_mods)
effect_ests_rems=list()
for(i in all_res_rems){
load(paste0('Rout/model_fits_',i,'.RData'))
effect_ests_rems[[which(i==all_res_rems)]] = summary(out, pars='trt_effect',use_cache=F,probs=my_probs)$summary[,c('2.5%','10%','50%','90%','97.5%'),drop=F]
rownames(effect_ests_rems[[which(i==all_res_rems)]])='Remdesivir'
}
par(las=1, mar=c(5,10,2,2))
plot_effect_estimates(effect_ests = effect_ests_rems,
plot_models = 1:length(effect_ests_rems),
study_threshold = study_threshold,
mod_cols = model_cols,
my_pch = as.numeric(model_settings$mod[all_res_rems]==all_mods[3])+15
)
legend('topright',pch=15:16,legend = c('Linear','Non-linear'),inset=0.03)
legend('bottomright',lwd=3,legend = names(model_cols), col = model_cols,inset=0.03)
load(paste0('Rout/model_fits_',all_res_rems_main,'.RData'))
round(100*(exp(quantile(extract(out, pars = 'trt_effect')$trt_effect, probs = my_probs))-1))
xx=make_slopes_plot(stan_out = out,
analysis_data_stan = stan_inputs$Remdesivir$analysis_data_stan,
ID_map = stan_inputs$Remdesivir$ID_map,
data_summary = plat_summary[!duplicated(plat_summary$ID),],
trt_cols = trt_cols,
my_lims = c(2,50),
my_vals = c(5,15,25,35,45))
load(paste0('Rout/model_fits_',all_res_rems_main,'.RData'))
par(las=1, mfrow=c(1,2), mar=c(5,7,2,2))
plot_coef_effects(stan_out = out,cov_mat = 1,
stan_inputs = stan_inputs$Remdesivir)
```
## Regeneron
Same effect in all variants assumed
```{r regeneron_only_main}
all_res_regn = which(model_settings$dataset=='Regeneron')
all_res_regn_main = which(model_settings$dataset=='Regeneron' & main_mods)
effect_ests_regn=list()
for(i in all_res_regn){
load(paste0('Rout/model_fits_',i,'.RData'))
effect_ests_regn[[which(i==all_res_regn)]] = summary(out, pars='trt_effect',use_cache=F,probs=my_probs)$summary[,c('2.5%','10%','50%','90%','97.5%'),drop=F]
rownames(effect_ests_regn[[which(i==all_res_regn)]])='Casirivimab\nimdevimab'
}
par(las=1, mar=c(5,10,2,2))
plot_effect_estimates(effect_ests = effect_ests_regn,
plot_models = 1:length(effect_ests_regn),
study_threshold = study_threshold,
mod_cols = model_cols,
my_pch = as.numeric(model_settings$mod[all_res_rems]==all_mods[3])+15
)
legend('topright',pch=15:16,legend = c('Linear','Non-linear'),inset=0.03)
legend('bottomright',lwd=3,legend = names(model_cols), col = model_cols,inset=0.03)
load(paste0('Rout/model_fits_',all_res_regn_main,'.RData'))
round(100*(exp(quantile(extract(out, pars = 'trt_effect')$trt_effect, probs = my_probs))-1))
my_data_summary = plat_summary[!duplicated(plat_summary$ID),]
my_data_summary$Trt[my_data_summary$Trt=='Regeneron']='Casirivimab\nimdevimab'
xx=make_slopes_plot(stan_out = out,
analysis_data_stan = stan_inputs$Regeneron$analysis_data_stan,
ID_map = stan_inputs$Regeneron$ID_map,
data_summary = my_data_summary,
trt_cols = trt_cols,
my_lims = c(2,50),
my_vals = c(5,15,25,35,45))
load(paste0('Rout/model_fits_',all_res_regn_main,'.RData'))
par(las=1, mfrow=c(1,2), mar=c(5,7,2,2))
plot_coef_effects(stan_out = out,cov_mat = 1,
stan_inputs = stan_inputs$Full)
```
## Both interventions together
Up until 10 June in Thai sites (where regeneron was available)
```{r regeneron_remdesivir_contemp}
all_res = which(model_settings$dataset=='REGN_Remdesivir_contemporaneous')
all_res_main = which(model_settings$dataset=='REGN_Remdesivir_contemporaneous' & main_mods)
effect_ests_all=list()
for(i in all_res){
load(paste0('Rout/model_fits_',i,'.RData'))
j = which(i==all_res)
effect_ests_all[[j]] = extract(out, pars='trt_effect')$trt_effect
effect_ests_all[[j]][,3] = rowSums(effect_ests_all[[j]][,2:3])
effect_ests_all[[j]] = t(apply(effect_ests_all[[j]], 2, quantile, probs=my_probs))
rownames(effect_ests_all[[j]])= c('Remdesivir',
'Casirivimab\nimdevimab (Delta)',
'Casirivimab\nimdevimab (Omicron)')
}
par(las=1, mar=c(5,13,2,2))
plot_effect_estimates(effect_ests = effect_ests_all,
plot_models = 1:length(effect_ests_all),
study_threshold = study_threshold,
mod_cols = model_cols,
my_pch = as.numeric(model_settings$mod[all_res]==all_mods[3])+15
)
legend('topright',pch=15:16,legend = c('Linear','Non-linear'),inset=0.03)
legend('bottomright',lwd=3,legend = names(model_cols), col = model_cols,inset=0.03)
load(paste0('Rout/model_fits_',all_res_main,'.RData'))
round(100*(exp(quantile(extract(out, pars = 'trt_effect')$trt_effect, probs = my_probs))-1))
xx=make_slopes_plot(stan_out = out,
analysis_data_stan = stan_inputs$REGN_Remdesivir_contemporaneous$analysis_data_stan,
ID_map = stan_inputs$REGN_Remdesivir_contemporaneous$ID_map,
data_summary = my_data_summary,
trt_cols = trt_cols,
my_lims = c(2,50),
my_vals = c(5,15,25,35,45))
```
```{r full_analysis_contemp}
load(paste0('Rout/model_fits_',all_res_main,'.RData'))
thetas_all = extract(out,pars='trt_effect')$trt_effect
writeLines('probability that remdesivir is less than REGN in Delta:')
mean(thetas_all[,1] < thetas_all[,2])
writeLines('probability that remdesivir is greater than REGN in Omicron:')
mean(thetas_all[,1] > rowSums(thetas_all[,2:3]))
```
### All data combined
```{r everything}
everything = which(model_settings$dataset=='Full')
everything_main = which(model_settings$dataset=='Full' & main_mods)
effect_ests_everything=list()
for(i in everything){
load(paste0('Rout/model_fits_',i,'.RData'))
j = which(i==everything)
effect_ests_everything[[j]] = extract(out, pars='trt_effect')$trt_effect
effect_ests_everything[[j]][,3] = rowSums(effect_ests_everything[[j]][,2:3])
effect_ests_everything[[j]] = t(apply(effect_ests_everything[[j]], 2,
quantile, probs=my_probs))
rownames(effect_ests_everything[[j]])=
c('Remdesivir',
'Casirivimab\nimdevimab (Delta)',
'Casirivimab\nimdevimab (Omicron)')
}
load(paste0('Rout/model_fits_',everything_main,'.RData'))
thetas_trt = extract(out, pars='trt_effect')$trt_effect
thetas_trt[,3] = rowSums(thetas_trt[,2:3])
thetas_rank = apply(thetas_trt,1,rank)
rownames(thetas_rank) = c('Remdesivir',
'Casirivimab\nimdevimab (Delta)',
'Casirivimab\nimdevimab (Omicron)')
writeLines('Ranking probabilities:')
apply(thetas_rank,1, table)
par(las=1, mar=c(5,13,2,2))
plot_effect_estimates(effect_ests = effect_ests_everything,
plot_models = 1:length(effect_ests_everything),
study_threshold = study_threshold,
mod_cols = model_cols,
my_pch = as.numeric(model_settings$mod[everything]==all_mods[3])+15
)
legend('topright',pch=15:16,legend = c('Linear','Non-linear'),inset=0.03)
legend('bottomright',lwd=3,legend = names(model_cols), col = model_cols,inset=0.03)
load(paste0('Rout/model_fits_',everything_main,'.RData'))
my_data_summary_greek = my_data_summary
my_data_summary_greek$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'&
my_data_summary$Variant=='Delta']='REGN (Delta)'
my_data_summary_greek$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'&
my_data_summary$Variant!='Delta']='REGN (Omicron)'
my_data_summary_greek$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant=='Delta']='No study drug (Delta)'
my_data_summary_greek$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant!='Delta']='No study drug (Omicron)'
table(my_data_summary_greek$Trt)
trt_cols_var = brewer.pal(n = 6, name = 'Set2')
names(trt_cols_var) = unique(my_data_summary_greek$Trt)
xx=make_slopes_plot(stan_out = out,
analysis_data_stan = stan_inputs$Full$analysis_data_stan,
ID_map = stan_inputs$Full$ID_map,
data_summary = my_data_summary_greek,
trt_cols = trt_cols_var,
my_lims = c(2,50),
my_vals = c(5,15,25,35,45))
```
```{r everything_coef_plot, fig.height=7, fig.width=9}
par(las=1, mfrow=c(1,2), mar=c(5,7,2,2))
i=which(model_settings$dataset=='Full' & model_settings$cov_matrices==2)
load(paste0('Rout/model_fits_',i,'.RData'))
plot_coef_effects(stan_out = out,cov_mat = 2,
stan_inputs = stan_inputs$Full)
```
## Regeneron subgroups
### Greek variant
```{r greek_subgroup_analysis}
Greek_res_mod = which(model_settings$dataset=='Subgroup_Greek')
Greek_res_mod_main = which(model_settings$dataset=='Subgroup_Greek' & main_mods)
effect_ests_greek=list()
for(i in Greek_res_mod){
load(paste0('Rout/model_fits_',i,'.RData'))
j = which(i==Greek_res_mod)
effect_ests_greek[[j]] = extract(out, pars='trt_effect')$trt_effect
effect_ests_greek[[j]][,3] = rowSums(effect_ests_greek[[j]][,c(1,3)])
effect_ests_greek[[j]] = t(apply(effect_ests_greek[[j]], 2, quantile, probs=my_probs))[c(1,3), ]
rownames(effect_ests_greek[[j]])=
c('Casirivimab\nimdevimab (Delta)',
'Casirivimab\nimdevimab (Omicron)')
}
par(las=1, mar=c(5,13,2,2))
plot_effect_estimates(effect_ests = effect_ests_greek,
plot_models = 1:length(effect_ests_greek),
mod_cols = model_cols,
study_threshold = study_threshold,
my_pch = as.numeric(model_settings$mod[all_res_rems]==all_mods[3])+15
)
legend('topright',pch=15:16,legend = c('Linear','Non-linear'),inset=0.03)
legend('right',lwd=3,legend = names(model_cols),
col = model_cols,inset=0.03)
load(paste0('Rout/model_fits_',Greek_res_mod_main,'.RData'))
thetas_all = extract(out, pars='trt_effect')$trt_effect
trt_delta_regn = quantile(thetas_all[,1],probs = my_probs)
trt_omicron_regn =
quantile(rowSums(thetas_all[,c(1,3)]),probs = my_probs)
my_data_summary_var = my_data_summary
my_data_summary_var$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'& my_data_summary$Variant=='Delta']='Casirivimab\nimdevimab (Delta)'
my_data_summary_var$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'&
my_data_summary$Variant!='Delta']='Casirivimab\nimdevimab (Omicron)'
my_data_summary_var$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant=='Delta']='No study drug (Delta)'
my_data_summary_var$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant!='Delta']='No study drug (Omicron)'
table(my_data_summary_var$Trt)
trt_cols_var = brewer.pal(n = 6, name = 'Set2')
names(trt_cols_var) = unique(my_data_summary_var$Trt)
xx=make_slopes_plot(stan_out = out,
analysis_data_stan = stan_inputs$Subgroup_Greek$analysis_data_stan,
ID_map = stan_inputs$Subgroup_Greek$ID_map,
data_summary = my_data_summary_var,
trt_cols = trt_cols_var,
my_lims = c(2,50),
my_vals = c(5,15,25,35,45))
```
### G446S mutation
```{r g446s_subgroup_analysis}
G446S_res_mod = which(model_settings$dataset=='Subgroup_G446S')
G446S_res_mod_main = which(model_settings$dataset=='Subgroup_G446S' & main_mods)
effect_ests_g446s=list()
for(i in G446S_res_mod){
load(paste0('Rout/model_fits_',i,'.RData'))
j = which(i==G446S_res_mod)
effect_ests_g446s[[j]] = extract(out, pars='trt_effect')$trt_effect
effect_ests_g446s[[j]][,4] = rowSums(effect_ests_g446s[[j]][,c(1,4)])
effect_ests_g446s[[j]][,5] = rowSums(effect_ests_g446s[[j]][,c(1,5)])
effect_ests_g446s[[j]] = t(apply(effect_ests_g446s[[j]], 2, quantile, probs=my_probs))[c(1,4,5), ]
rownames(effect_ests_g446s[[j]])=
c('Casirivimab\nimdevimab (Delta)',
'Casirivimab\nimdevimab\n(Omicron G446S)',
'Casirivimab\nimdevimab\n(Omicron not G446S)')
}
par(las=1, mar=c(5,13,2,2))
plot_effect_estimates(effect_ests = effect_ests_g446s,
plot_models = 1:length(effect_ests_g446s),
study_threshold = study_threshold,
mod_cols = model_cols,
my_pch = as.numeric(model_settings$mod[all_res_rems]==all_mods[3])+15
)
legend('topright',pch=15:16,legend = c('Linear','Non-linear'), inset = 0.03)
legend('right',lwd=3,legend = names(model_cols),
col = model_cols,inset=0.03)
load(paste0('Rout/model_fits_',G446S_res_mod_main,'.RData'))
# make output for the main results plot
trt_names =colnames(stan_inputs$Subgroup_G446S$Trt_matrix)[-1]
thetas_g446s = extract(out,pars='trt_effect')$trt_effect
colnames(thetas_g446s)=trt_names
trt_delta_g446s_regn = quantile(thetas_g446s[,"TrtCasirivimab\nimdevimab"],probs = my_probs)
trt_omicron_g446s_regn =
quantile(rowSums(thetas_g446s[,c("TrtCasirivimab\nimdevimab",
"TrtCasirivimab\nimdevimab:G446S_subgroupsOmicron_G446S")]),probs = my_probs)
trt_omicron_notg446s_regn =
quantile(rowSums(thetas_g446s[,c("TrtCasirivimab\nimdevimab",
"TrtCasirivimab\nimdevimab:G446S_subgroupsOmicron_notG446S")]),probs = my_probs)
# make the individual half life estimates plot
my_data_summary_var = my_data_summary
my_data_summary_var$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'& my_data_summary$Variant=='Delta']='Casirivimab\nimdevimab (Delta)'
my_data_summary_var$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'&
my_data_summary$Variant=='BA.1']='Casirivimab\nimdevimab (G446S)'
my_data_summary_var$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'&
my_data_summary$Variant%in%c('BA.2','BA.4','BA.5')]='Casirivimab\nimdevimab (not G446S)'
my_data_summary_var$Trt[my_data_summary$Trt=='No study drug'& my_data_summary$Variant=='Delta']='No study drug (Delta)'
my_data_summary_var$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant=='BA.1']='No study drug (G446S)'
my_data_summary_var$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant%in%c('BA.2','BA.4','BA.5')]='No study drug (not G446S)'
table(my_data_summary_var$Trt)
trt_cols_var = brewer.pal(n = 7, name = 'Set2')
names(trt_cols_var) = unique(my_data_summary_var$Trt)
xx=make_slopes_plot(stan_out = out,
analysis_data_stan = stan_inputs$Subgroup_G446S$analysis_data_stan,
ID_map = stan_inputs$Subgroup_G446S$ID_map,
data_summary = my_data_summary_var,
trt_cols = trt_cols_var,
my_lims = c(2,50),
my_vals = c(5,15,25,35,45))
```
## Sublineages subgroup analysis
```{r sublineage_subgroup_analysis}
Sublineage_mod = which(model_settings$dataset=='Subgroup_Sublineages')
Sublineage_mod_main = which(model_settings$dataset=='Subgroup_Sublineages' & main_mods)
effect_ests_sublineage=list()
for(i in Sublineage_mod){
load(paste0('Rout/model_fits_',i,'.RData'))
j = which(i==Sublineage_mod)
effect_ests_sublineage[[j]] = extract(out, pars='trt_effect')$trt_effect[,c(1,6:7,9)]
effect_ests_sublineage[[j]][,2] = rowSums(effect_ests_sublineage[[j]][,c(1,2)])
effect_ests_sublineage[[j]][,3] = rowSums(effect_ests_sublineage[[j]][,c(1,3)])
effect_ests_sublineage[[j]][,4] = rowSums(effect_ests_sublineage[[j]][,c(1,4)])
effect_ests_sublineage[[j]] = t(apply(effect_ests_sublineage[[j]], 2, quantile, probs=my_probs))
rownames(effect_ests_sublineage[[j]])=
c('Casirivimab\nimdevimab (Delta)',
'Casirivimab\nimdevimab (BA.1)',
'Casirivimab\nimdevimab (BA.2)',
'Casirivimab\nimdevimab (BA.5)')
}
par(las=1, mar=c(5,13,2,2))
plot_effect_estimates(effect_ests = effect_ests_sublineage,
plot_models = 1:length(effect_ests_sublineage),
mod_cols = model_cols,
study_threshold = study_threshold,
my_pch = as.numeric(model_settings$mod[Sublineage_mod]==all_mods[3])+15
)
legend('topright',pch=15:16,legend = c('Linear','Non-linear'),inset=0.03)
legend('right',lwd=3,legend = names(model_cols),
col = model_cols,inset=0.03)
load(paste0('Rout/model_fits_',Sublineage_mod_main,'.RData'))
my_data_summary_var = my_data_summary
my_data_summary_var$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'&
my_data_summary$Variant=='Delta']='Casirivimab\nimdevimab (Delta)'
my_data_summary_var$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'&
my_data_summary$Variant=='BA.1']='Casirivimab\nimdevimab (BA.1)'
my_data_summary_var$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'&
my_data_summary$Variant=='BA.2']='Casirivimab\nimdevimab (BA.2)'
my_data_summary_var$Trt[my_data_summary$Trt=='Casirivimab\nimdevimab'&
my_data_summary$Variant=='BA.5']='Casirivimab\nimdevimab (BA.5)'
my_data_summary_var$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant=='Delta']='No study drug (Delta)'
my_data_summary_var$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant=='BA.1']='No study drug (BA.1)'
my_data_summary_var$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant=='BA.2']='No study drug (BA.2)'
my_data_summary_var$Trt[my_data_summary$Trt=='No study drug'&
my_data_summary$Variant%in%c('BA.4','BA.5')]='No study drug (BA.5)'
table(my_data_summary_var$Trt)
trt_cols_var = brewer.pal(n = 9, name = 'Paired')
names(trt_cols_var) = unique(my_data_summary_var$Trt)
xx=make_slopes_plot(stan_out = out,
analysis_data_stan = stan_inputs$Subgroup_Sublineages$analysis_data_stan,
ID_map = stan_inputs$Subgroup_Sublineages$ID_map,
data_summary = my_data_summary_var,
trt_cols = trt_cols_var,
my_lims = c(2,50),
my_vals = c(5,15,25,35,45))
```
### Make main figure
```{r Main_Result, fig.width=8, fig.height=6}
trt_matrix =
rbind(effect_ests_rems[[which(all_res_rems_main==all_res_rems)]],
effect_ests_regn[[which(all_res_regn_main==all_res_regn)]],
trt_delta_regn, trt_omicron_regn,
trt_delta_g446s_regn, trt_omicron_g446s_regn, trt_omicron_notg446s_regn
)
rownames(trt_matrix) = c('All variants\n(n=67 vs n=64)',
'All variants\n(n=74 vs n=84)',
'Delta\n(n=13 vs n=10)',
'Omicron\n(n=61 vs n=74)',
'Delta\n(n=13 vs n=10)',
'Omicron\nG446S mutated\n(n=15 vs n=11)',
'Omicron\nnot G446S mutated\n(n=46 vs n=63)')