-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathORR_survival_clinical_efficacy.Rmd
237 lines (179 loc) · 6.41 KB
/
ORR_survival_clinical_efficacy.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
---
title: "J15221 Evanthia TNBC - Clinical efficacy, survival, ORR"
author: "L. Danilova, J. A. Tandurella, C. Wang"
date: "`r Sys.Date()`"
output:
html_document:
toc: yes
toc_float: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = FALSE,
warning = FALSE)
rm(list = ls())
library(dplyr)
library(ggplot2)
library(ggpubr)
library(ggrepel)
library(data.table)
library("DT")
library(gridExtra)
library(survival)
library(survminer)
source("functions.r")
```
```{r fig.width = 10}
# set colors
recistCol = c("Non-responder" = "red","Responder" = "blue")
cbrCol = c("CR,PR,SD" = "blue","PD" = "red")
subtypeCol = c("HR+" = "red", "TNBC" = "blue")
timeCol = c("Baseline" = "black", "Time 1" = 'grey45', "Time 2" = 'grey75')
# set root folder
rootDir = "./"
# Load data patient data
dta_pts = read.csv(paste0(rootDir,"input_tables/table_24patient_info.csv"), row.names = 1)
dta_pts$ID = rownames(dta_pts)
# number of prior therapies by subtype
print("summary of the number of prior therapies by subtype")
print(aggregate(dta_pts$n_therapies, by = list(dta_pts$Subtype), FUN = summary))
t.test(dta_pts$n_therapies ~ dta_pts$Subtype)
# load data for a spider plot
dta_tumor = read.csv(paste0(rootDir,"input_tables/table_tumor_size_change.csv"))
colnames(dta_tumor) = c("ID",'Days', "Y" )
datatable(dta_pts)
```
# ORR and CBR
## 20 patients with evaulable response
```{r fig.width = 10}
dta_pts_20 = dta_pts %>% filter(Best_Resp != "Unknown")
# get table with ORR for RECIST
tab1 = get_freq_table(dta_pts_20, "OR")
# get table with CBR for RECIST
tab2 = get_freq_table(dta_pts_20, "CB_6mth_yn")
# get table with ORR for irRECIST
tab3 = get_freq_table(dta_pts_20, "irOR")
print("ORR with RECIST")
datatable(tab1)
write.csv(tab1, file = "table_orr_RECIST.csv", row.names = F)
print("ORR with irRECIST")
datatable(tab3)
write.csv(tab1, file = "table_orr_irRECIST.csv", row.names = F)
print("CBR")
datatable(tab2)
write.csv(tab1, file = "table_orr_cbr.csv", row.names = F)
```
## Excluding dose level 4
```{r fig.width = 10}
# get table with ORR for RECIST
tab1 = get_freq_table(dta_pts_20 %>% filter(Dose_level != 4), "OR")
# get table with CBR for RECIST
tab2 = get_freq_table(dta_pts_20%>% filter(Dose_level != 4), "CB_6mth_yn")
# get table with ORR for irRECIST
tab3 = get_freq_table(dta_pts_20%>% filter(Dose_level != 4), "irOR")
print("ORR with RECIST")
datatable(tab1)
write.csv(tab1, file = "table_orr_RECIST_noDose4.csv", row.names = F)
print("ORR with irRECIST")
datatable(tab3)
write.csv(tab1, file = "table_orr_irRECIST_noDose4.csv", row.names = F)
print("CBR")
datatable(tab2)
write.csv(tab1, file = "table_orr_cbr_noDose4.csv", row.names = F)
```
# Best response
```{r fig.width = 7}
#=========================================
# # waterfall plot of Best Overall Response (%)
# adds patient info to tumor data
dat <- get_tumor_best(dta_tumor) %>%
left_join(dta_pts)
# save data to submit with the paper
write.csv(dat, file = "Source_data_figure2a.csv", row.names = F)
# reproducing waterfall plot of best response
wtr1 = ggplot(dat, aes(x = reorder(ID, -Y), y = Y, fill = Subtype)) +
ylab ("Best Overall Response (%)") +
xlab("Patients") +
geom_bar(stat = "identity") + ylim(-100, 100) +
scale_fill_manual(values = subtypeCol) +
theme_bw()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
geom_hline(yintercept = c(-30, 20), linetype = 'dashed') +
geom_text(aes(y=1, label = exceptional_response), size = 6)
print(wtr1)
#===============
# waterfall of months
#==============
dat <- get_tumor_best(dta_tumor) %>%
left_join(dta_pts) %>%
mutate(Months = Days / 30.5) %>% # convert days to months
arrange(Subtype, Months)
# save data to submit with the paper
write.csv(dat, file = "Source_data_figure2b.csv", row.names = F)
# make ID as factor with order organized by type and days.
# otherwise, barplot makes it in alphabetical order
dat$ID = factor(dat$ID, levels = dat$ID)
wtr2 = ggplot(dat, aes(x = Months, y = ID, fill = Subtype)) +
ylab("Patients") +
geom_bar(stat = "identity") +
theme_bw()+
labs(x = "Months")+
scale_fill_manual(values = subtypeCol) +
geom_text(aes(y=ID, x = Months + 1, label = exceptional_response), size = 6)
print(wtr2)
#====================
# spider plot
#====================
# keep only sample from patients with patient info
dta_tumor <- dta_tumor %>% filter(ID %in% dta_pts$ID)
# add patient into to tumor data
dat <- dta_tumor %>%
left_join(dta_pts) %>%
mutate(Days = Days / 30.5,
Y = Y * 100) %>%
arrange(ID, Days)
# save data to submit with the paper
write.csv(dat, file = "Source_data_figure2c.csv", row.names = F)
# add stars
dta_star <- dat %>%
filter(exceptional_response == "*") %>%
group_by(ID) %>%
filter(Days == max(Days)) %>%
mutate(Days = Days,
label = "*") %>%
rbind(dat %>%
filter(exceptional_response == "**") %>%
group_by(ID) %>%
filter(Days == max(Days)) %>%
mutate(Days = Days,
label = "**"))
# make plot
sp1 = ggplot(data = dat, aes(x = Days, y = Y)) +
geom_line(aes(group = ID, col = Subtype), size = 1.5) +
theme_bw() +
labs(x = "Months", y = "Percent Change") +
geom_hline(yintercept = 0) +
geom_hline(yintercept = 30, lty = 2) +
geom_hline(yintercept = -30, lty = 2) +
scale_colour_manual(values = subtypeCol) +
geom_text(data = dta_star,
aes(x = Days, y = Y+1, label = label),size = 6)+
theme(legend.title = element_blank(), legend.position = c(0.5, 0.88))
print(sp1)
```
# Survival analysis
```{r fig.height= 8}
## -------------------------------------------------------------
## Survival
## -------------------------------------------------------------
# save data to submit with the paper
write.csv(dta_pts_20, file = "Source_data_figure3.csv", row.names = F)
# save data to submit with the paper
write.csv(dta_pts, file = "Source_data_EDF1.csv", row.names = F)
pfs <- plot_surv(dta_pts_20, "PFS", "Progression Free Survival", x_6m = 12, xlim = 50, xtext = 35, add6m = T)
os <- plot_surv(dta_pts_20, "OS", "Overall Survival", x_6m = 15, x_12 = 20, add6m = T)
pfs <- plot_surv(dta_pts, "PFS", "Progression Free Survival", x_6m = 12, xlim = 50, xtext = 35)
os <- plot_surv(dta_pts, "OS", "Overall Survival", x_6m = 15, x_12 = 20)
```
```{r}
sessionInfo()
```