-
Notifications
You must be signed in to change notification settings - Fork 1
/
radfunc.R
521 lines (437 loc) · 19.4 KB
/
radfunc.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
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
library(ape)
library(picante)
library(tidyverse)
library(phytools)
library(caper)
library(ggrepel)
library(cowplot)
library(ggsci)
library(patchwork)
library(rr2)
modPgls.SEy = function (model, data, corClass = corBrownian, tree, se = NULL,
method = c("REML", "ML"), interval = c(0, 1000), corClassValue=1, sig2e=NULL, ...)
{
Call <- match.call()
corfunc <- corClass
spp <- rownames(data)
data <- cbind(data, spp)
if (is.null(se))
se <- setNames(rep(0, Ntip(tree)), tree$tip.label)[spp]
else se <- se[spp]
lk <- function(sig2e, data, tree, model, ve, corfunc, spp) {
tree$edge.length <- tree$edge.length * sig2e
ii <- sapply(1:Ntip(tree), function(x, e) which(e ==
x), e = tree$edge[, 2])
tree$edge.length[ii] <- tree$edge.length[ii] + ve[tree$tip.label]
vf <- diag(vcv(tree))[spp]
w <- varFixed(~vf)
COR <- corfunc(corClassValue, tree, form = ~spp, ...)
fit <- gls(model, data = cbind(data, vf), correlation = COR,
method = method, weights = w)
-logLik(fit)
}
if (is.null(sig2e)) {
fit <- optimize(lk, interval = interval, data = data, tree = tree,
model = model, ve = se^2, corfunc = corfunc, spp = spp)
sig2e=fit$minimum
}
tree$edge.length <- tree$edge.length * sig2e
ii <- sapply(1:Ntip(tree), function(x, e) which(e == x),
e = tree$edge[, 2])
tree$edge.length[ii] <- tree$edge.length[ii] + se[tree$tip.label]^2
vf <- diag(vcv(tree))[spp]
w <- varFixed(~vf)
obj <- gls(model, data = cbind(data, vf), correlation = corfunc(corClassValue,
tree, form = ~spp, ...), weights = w, method = method)
obj$call <- Call
obj$sig2e <- sig2e
obj
}
#Internal function
pglsSEyPagelToOptimizeLambda=function(lambda,model,data,tree,...) {
-logLik(modPgls.SEy(model=model,data=data,tree=tree,corClassValue=lambda,corClass=corPagel,fixed=T,...)) #Returns -logLikelihood of the pgls.SEy model with lambda fixed to the value of the lambda argument. sig2e will be optimized within modPgls.SEy unless given as an argument here
}
#Function intended for users
pglsSEyPagel=function(model, data, tree, lambdaInterval=c(0,1),...){
optimizedModel=optimize(pglsSEyPagelToOptimizeLambda,lambdaInterval,model=model,data=data,tree=tree,...) #Optimizes lambda in the lambdaInterval using the pglsSEyPagelToOptimizeLambda function
return(modPgls.SEy(model=model,data=data,tree=tree,corClass=corPagel,fixed=T,corClassValue=optimizedModel$minimum,...)) #Returns the final model fit
}
#read and clean up csv
min1<-read.csv(file="min1.csv")
radData<-read.csv(file="radUpdate.csv")
min10<-filter(min1, RecordsWithDenominators >= 10)
Data<-left_join(radData, min10, by = "common_name")
Data <- Data[,c(1,2,3,4,13,14,16,20,30),drop=FALSE]
Data<-na.omit(Data)
#read tree
tree<-read.tree(file="min10radtree.nwk")
#cut tree and data
Data$Species <- gsub(" ", "_", Data$Species)
includedSpecies <- Data$Species
pruned.tree<-drop.tip(
tree, setdiff(
tree$tip.label, includedSpecies))
length(pruned.tree$tip.label)
pruned.tree <- keep.tip(pruned.tree,pruned.tree$tip.label)
Data$Keep <- Data$Species %in% pruned.tree$tip.label
Data <- Data[!(Data$Keep==FALSE),]
rownames(Data)<-Data$Species
SE<-setNames(Data$SE,Data$Species)[rownames(Data)]
##Model
AUC.10.GY <- pglsSEyPagel(NeoplasiaPrevalence~log10(AUC10Gy), data=Data,
tree=pruned.tree,method="ML",se=SE)
summary(AUC.10.GY)
auc<-lm(NeoplasiaPrevalence~log10(AUC10Gy), data=Data)
summary(auc)$r.squared
#grab r squared, p value, and lambda from summary
r.AUC.10.GY <- R2(phy = pruned.tree,AUC.10.GY)
r.AUC.10.GY <- format(r.AUC.10.GY[3])
r.AUC.10.GY <-signif(as.numeric(r.AUC.10.GY), digits = 2)
ld.v.AUC.10.GY<- summary(AUC.10.GY)$modelStruct$corStruct
ld.v.AUC.10.GY <- signif(ld.v.AUC.10.GY[1], digits =2)
p.v.AUC.10.GY<-summary(AUC.10.GY)$tTable
p.v.AUC.10.GY<-signif(p.v.AUC.10.GY[2,4], digits = 2)
#plot
ggplot(Data, aes(y=NeoplasiaPrevalence*100, x=log10(AUC10Gy))) +
scale_color_manual(values=c("#631879FF"))+
scale_x_continuous(
limits = c(1.3,2),
breaks = c(1.3,1.6,1.8,1.90309,2),
labels = c(20,40,60,80,100)
)+
geom_abline(intercept = coef(AUC.10.GY)[1]*100, slope = coef(AUC.10.GY)[2]*100,
color = 'grey',size = 1.2) +
theme_cowplot(12)+
theme(axis.title = element_text(size = 18))+
ylab("Neoplasia Prevalence (%)") +
xlab("(log 10) Cell Count AUC % of Untreated Control \n 10Gy Radiation") +
geom_point(aes(colour= Keep, size = RecordsWithDenominators)) +
geom_text_repel(aes(label=common_name))+
scale_size(name = "Total Necropsies",
breaks = c(10,20,50,100),
labels = c(10,20,50,100))+
theme(
plot.title = element_text(size = 20, face = "bold")) +
theme(legend.position = "bottom")+
labs(title = "A")+
guides(col=FALSE)
ggsave(filename='S40RADAUC10.pdf', width=9.5, height=7, limitsize=FALSE,bg="white")
#AUC 2
##Model
AUC.2.GY <- pglsSEyPagel(NeoplasiaPrevalence~log10(AUC2Gy), data=Data,
tree=pruned.tree,method="ML",se=SE)
#grab r squared, p value, and lambda from summary
r.AUC.2.GY <- R2(phy = pruned.tree,AUC.2.GY)
r.AUC.2.GY <- format(r.AUC.2.GY[3])
r.AUC.2.GY <-signif(as.numeric(r.AUC.2.GY), digits = 2)
ld.v.AUC.2.GY<- summary(AUC.2.GY)$modelStruct$corStruct
ld.v.AUC.2.GY <- signif(ld.v.AUC.2.GY[1], digits = 2)
p.v.AUC.2.GY<-summary(AUC.2.GY)$tTable
p.v.AUC.2.GY<-signif(p.v.AUC.2.GY[2,4], digits = 2)
#plot
ggplot(Data, aes(y=NeoplasiaPrevalence*100, x=log10(AUC2Gy))) +
scale_color_manual(values=c("#631879FF"))+
scale_x_continuous(
limits = c(1.69897,2.04),
breaks = c(1.69897,1.90309,2.04),
labels = c(50,80,110)
)+
geom_abline(intercept = coef(AUC.2.GY)[1]*100, slope = coef(AUC.2.GY)[2]*100,
color = 'grey',size = 1.2) +
theme_cowplot(12)+
theme(axis.title = element_text(size = 18))+
ylab("Neoplasia Prevalence (%)") +
xlab("(log 10) Cell Count AUC % of Untreated Control \n 2Gy Radiation") +
geom_point(aes(colour= Keep, size = TotalRecords)) +
geom_text_repel(aes(label=common_name))+
scale_size(name = "Total Necropsies",
breaks = c(20,150,250,394),
labels = c(20,150,250,394))+
theme(
plot.title = element_text(size = 20, face = "bold")) +
theme(legend.position = "bottom")+
labs(title = "Neoplasia vs. AUC 2GY Radiation",
subtitle =bquote(p-value:.(p.v.AUC.2.GY)~R^2:.(r.AUC.2.GY)~Lambda:.(ld.v.AUC.2.GY)))+
guides(col=FALSE)
ggsave(filename='S41RADAUC2.pdf', width=9.5, height=7, limitsize=FALSE,bg="white")
#AUC .4
##Model
AUC.04.GY <- pglsSEyPagel(NeoplasiaPrevalence~log10(AUC04Gy), data=Data,
tree=pruned.tree,method="ML",se=SE)
#grab r squared, p value, and lambda from summary
r.AUC.04.GY <- R2(phy = pruned.tree,AUC.04.GY)
r.AUC.04.GY <- format(r.AUC.04.GY[3])
r.AUC.04.GY <-signif(as.numeric(r.AUC.04.GY), digits = 2)
ld.v.AUC.04.GY<- summary(AUC.04.GY)$modelStruct$corStruct
ld.v.AUC.04.GY <- signif(ld.v.AUC.04.GY[1], digits = 2)
p.v.AUC.04.GY<-summary(AUC.04.GY)$tTable
p.v.AUC.04.GY<-signif(p.v.AUC.04.GY[2,4], digits = 2)
ggplot(Data, aes(y=NeoplasiaPrevalence*100, x=log10(AUC04Gy))) +
scale_color_manual(values=c("#631879FF"))+
scale_x_continuous(
limits = c(1.87506,2.04),
breaks = c(1.8750,1.95424,2.04),
labels = c(75,90,110)
)+
geom_abline(intercept = coef(AUC.04.GY)[1]*100, slope = coef(AUC.04.GY)[2]*100,
color = 'grey',size = 1.2) +
theme_cowplot(12)+
theme(axis.title = element_text(size = 18))+
ylab("Neoplasia Prevalence (%)") +
xlab("(log 10) Cell Count AUC of Untreated Control \n 0.4Gy Radiation") +
geom_point(aes(colour= Keep, size = TotalRecords)) +
geom_text_repel(aes(label=common_name))+
scale_size(name = "Total Necropsies",
breaks = c(20,150,250,394),
labels = c(20,150,250,394))+
theme(
plot.title = element_text(size = 20, face = "bold")) +
theme(legend.position = "bottom")+
labs(title = "Neoplasia vs. AUC 0.4Gy Radiation",
subtitle =bquote(p-value:.(p.v.AUC.04.GY)~R^2:.(r.AUC.04.GY)~Lambda:.(ld.v.AUC.04.GY)))+
guides(col=FALSE)
ggsave(filename='S42RADAUC04.pdf', width=9.5, height=7, limitsize=FALSE,bg="white")
##CHANGE
#read csv
#read and clean up csv
min1<-read.csv(file="min1.csv")
radData<-read.csv(file="changeRad.csv")
min10<-filter(min1, RecordsWithDenominators >= 10)
Data<-left_join(radData, min10, by = "common_name")
Data <- Data[,c(1,2,3,4,13,14,16,20,30),drop=FALSE]
Data<-na.omit(Data)
tree<-read.tree("min10change.nwk")
#prune tree and data
Data$Species <- gsub(" ", "_", Data$Species)
includedSpecies <- Data$Species
pruned.tree<-drop.tip(
tree, setdiff(
tree$tip.label, includedSpecies))
length(pruned.tree$tip.label)
pruned.tree <- keep.tip(pruned.tree,pruned.tree$tip.label)
Data$Keep <- Data$Species %in% pruned.tree$tip.label
Data <- Data[!(Data$Keep==FALSE),]
rownames(Data)<-Data$Species
SE<-setNames(Data$SE,Data$Species)[rownames(Data)]
#10GY Change
Change.10.GY <- pglsSEyPagel(NeoplasiaPrevalence~(Change.10.GY), data=Data,
tree=pruned.tree,method="ML",se=SE)
#grab r squared, p value, and lambda from summary
r.Change.10.GY <- R2(phy = pruned.tree,Change.10.GY)
r.Change.10.GY <- format(r.Change.10.GY[3])
r.Change.10.GY <-signif(as.numeric(r.Change.10.GY), digits = 2)
ld.v.Change.10.GY<- summary(Change.10.GY)$modelStruct$corStruct
ld.v.Change.10.GY <- signif(ld.v.Change.10.GY[1], digits =2)
p.v.Change.10.GY<-summary(Change.10.GY)$tTable
p.v.Change.10.GY<-signif(p.v.Change.10.GY[2,4], digits = 2)
#plot
ggplot(Data, aes(y=NeoplasiaPrevalence*100, x=(Change.10.GY))) +
scale_color_manual(values=c("#631879FF"))+
geom_abline(intercept = coef(Change.10.GY)[1]*100, slope = coef(Change.10.GY)[2]*100,
color = 'grey',size = 1.2) +
theme_cowplot(12)+
theme(axis.title = element_text(size = 18))+
ylab("Neoplasia Prevalence (%)") +
xlab("% Cell Growth Over Time [AUC] Relative to Untreated at 10 Gy of Radiation") +
geom_point(aes(colour= Keep, size = RecordsWithDenominators)) +
labs(title = "A")+
geom_text_repel(aes(label=common_name))+
scale_size(name = "Total Necropsies",
breaks = c(10,20,50,150),
labels = c(10,20,50,150))+
theme(
plot.title = element_text(size = 20, face = "bold")) +
theme(legend.position = "bottom")+
##labs(title = "Neoplasia vs. AUC Area Change From UT 10Gy Radiation")+
guides(col=FALSE)
ggsave(filename='S43RADChange10.pdf', width=9.5, height=7, limitsize=FALSE,bg="white")
#Change 2
##Model
Change.2.GY <- pglsSEyPagel(NeoplasiaPrevalence~log10(Change2Gy), data=Data,
tree=pruned.tree,method="ML",se=SE)
#grab r squared, p value, and lambda from summary
r.Change.2.GY <- R2(phy = pruned.tree,Change.2.GY)
r.Change.2.GY <- format(r.Change.2.GY[3])
r.Change.2.GY <-signif(as.numeric(r.Change.2.GY), digits = 2)
ld.v.Change.2.GY<- summary(Change.2.GY)$modelStruct$corStruct
ld.v.Change.2.GY <- signif(ld.v.Change.2.GY[1], digits = 2)
p.v.Change.2.GY<-summary(Change.2.GY)$tTable
p.v.Change.2.GY<-signif(p.v.Change.2.GY[2,4], digits = 2)
#plot
ggplot(Data, aes(y=NeoplasiaPrevalence*100, x=log10(Change2Gy))) +
scale_color_manual(values=c("#631879FF"))+
scale_x_continuous(
limits = c(1.69897,2.04),
breaks = c(1.69897,1.90309,2.04),
labels = c(50,80,110)
)+
geom_abline(intercept = coef(Change.2.GY)[1]*100, slope = coef(Change.2.GY)[2]*100,
color = 'grey',size = 1.2) +
theme_cowplot(12)+
theme(axis.title = element_text(size = 18))+
ylab("Neoplasia Prevalence (%)") +
xlab("% Cell Growth Over Time [AUC] Relative to Untreated at 2 Gy of Radiation") +
geom_point(aes(colour= Keep, size = TotalRecords)) +
geom_text_repel(aes(label=common_name))+
scale_size(name = "Total Necropsies",
breaks = c(20,150,250,394),
labels = c(20,150,250,394))+
theme(
plot.title = element_text(size = 20, face = "bold")) +
theme(legend.position = "bottom")+
labs(title = "Neoplasia vs. AUC Area Change From UT 2Gy Radiation",
subtitle =bquote(p-value:.(p.v.Change.2.GY)~R^2:.(r.Change.2.GY)~Lambda:.(ld.v.Change.2.GY)))+
guides(col=FALSE)
ggsave(filename='S44RADChange2.pdf', width=9.5, height=7, limitsize=FALSE,bg="white")
#Change .4
##Model
Change.04.GY <- pglsSEyPagel(NeoplasiaPrevalence~log10(Change04Gy), data=Data,
tree=pruned.tree,method="ML",se=SE)
#grab r squared, p value, and lambda from summary
r.Change.04.GY <- R2(phy = pruned.tree,Change.04.GY)
r.Change.04.GY <- format(r.Change.04.GY[3])
r.Change.04.GY <-signif(as.numeric(r.Change.04.GY), digits = 3)
ld.v.Change.04.GY<- summary(Change.04.GY)$modelStruct$corStruct
ld.v.Change.04.GY <- signif(ld.v.Change.04.GY[1], digits = 2)
p.v.Change.04.GY<-summary(Change.04.GY)$tTable
p.v.Change.04.GY<-signif(p.v.Change.04.GY[2,4], digits = 2)
#plot
ggplot(Data, aes(y=NeoplasiaPrevalence*100, x=log10(Change04Gy))) +
scale_color_manual(values=c("#631879FF"))+
scale_x_continuous(
limits = c(1.87506,2.04),
breaks = c(1.8750,1.95424,2.04),
labels = c(75,90,110)
)+
geom_abline(intercept = coef(Change.04.GY)[1]*100, slope = coef(Change.04.GY)[2]*100,
color = 'grey',size = 1.2) +
theme_cowplot(12)+
theme(axis.title = element_text(size = 18))+
ylab("Neoplasia Prevalence (%)") +
xlab("% Cell Growth Over Time [AUC] Relative to Untreated at 0.4 Gy of Radiation") +
geom_point(aes(colour= Keep, size = TotalRecords)) +
geom_text_repel(aes(label=common_name))+
scale_size(name = "Total Necropsies",
breaks = c(20,150,250,394),
labels = c(20,150,250,394))+
theme(
plot.title = element_text(size = 20, face = "bold")) +
theme(legend.position = "bottom")+
labs(title = "Neoplasia vs. AUC Area Change From UT .4Gy Radiation",
subtitle =bquote(p-value:.(p.v.Change.04.GY)~R^2:.(r.Change.04.GY)~Lambda:.(ld.v.Change.04.GY)))+
guides(col=FALSE)
ggsave(filename='S45RADChange04.pdf', width=9.5, height=7, limitsize=FALSE,bg="white")
#malignancy
#10GY Change
Change.10.GY.mal <- pglsSEyPagel(MalignancyPrevalence~log10(Change10Gy), data=Data,
tree=pruned.tree,method="ML",se=SE)
#grab r squared, p value, and lambda from summary
r.Change.10.GY.mal <- R2(phy = pruned.tree,Change.10.GY.mal)
r.Change.10.GY.mal <- format(r.Change.10.GY.mal[3])
r.Change.10.GY.mal <-signif(as.numeric(r.Change.10.GY.mal), digits = 2)
ld.v.Change.10.GY.mal<- summary(Change.10.GY.mal)$modelStruct$corStruct
ld.v.Change.10.GY.mal <- signif(ld.v.Change.10.GY.mal[1], digits =2)
p.v.Change.10.GY.mal<-summary(Change.10.GY.mal)$tTable
p.v.Change.10.GY.mal<-signif(p.v.Change.10.GY.mal[2,4], digits = 2)
#plot
ggplot(Data, aes(y=MalignancyPrevalence*100, x=log10(Change10Gy))) +
scale_color_manual(values=c("#631879FF"))+
scale_x_continuous(
limits = c(1.3,2),
breaks = c(1.3,1.6,1.8,1.90309,2),
labels = c(20,40,60,80,100)
)+
geom_abline(intercept = coef(Change.10.GY.mal)[1]*100, slope = coef(Change.10.GY.mal)[2]*100,
color = 'grey',size = 1.2) +
theme_cowplot(12)+
theme(axis.title = element_text(size = 18))+
ylab("Malignancy Prevalence (%)") +
xlab("% Cell Growth Over Time [AUC] Relative to Untreated at 10 Gy of Radiation") +
geom_point(aes(colour= Keep, size = TotalRecords)) +
geom_text_repel(aes(label=common_name))+
scale_size(name = "Total Necropsies",
breaks = c(20,150,250,394),
labels = c(20,150,250,394))+
theme(
plot.title = element_text(size = 20, face = "bold")) +
theme(legend.position = "bottom")+
labs(title = "Malignancy vs. AUC Area Change From UT 10Gy Radiation",
subtitle =bquote(p-value:.(p.v.Change.10.GY.mal)~R^2:.(r.Change.10.GY.mal)~Lambda:.(ld.v.Change.10.GY.mal)))+
guides(col=FALSE)
ggsave(filename='S46RADChange10mal.pdf', width=9.5, height=7, limitsize=FALSE,bg="white")
#Change 2
##Model
Change.2.GY.mal <- pglsSEyPagel(MalignancyPrevalence~log10(Change2Gy), data=Data,
tree=pruned.tree,method="ML",se=SE)
#grab r squared, p value, and lambda from summary
r.Change.2.GY.mal <- R2(phy = pruned.tree,Change.2.GY.mal)
r.Change.2.GY.mal <- format(r.Change.2.GY.mal[3])
r.Change.2.GY.mal <-signif(as.numeric(r.Change.2.GY.mal), digits = 2)
ld.v.Change.2.GY.mal<- summary(Change.2.GY.mal)$modelStruct$corStruct
ld.v.Change.2.GY.mal <- signif(ld.v.Change.2.GY.mal[1], digits = 2)
p.v.Change.2.GY.mal<-summary(Change.2.GY.mal)$tTable
p.v.Change.2.GY.mal<-signif(p.v.Change.2.GY.mal[2,4], digits = 2)
#plot
ggplot(Data, aes(y=MalignancyPrevalence*100, x=log10(Change2Gy))) +
scale_color_manual(values=c("#631879FF"))+
scale_x_continuous(
limits = c(1.69897,2.04),
breaks = c(1.69897,1.90309,2.04),
labels = c(50,80,110)
)+
geom_abline(intercept = coef(Change.2.GY.mal)[1]*100, slope = coef(Change.2.GY.mal)[2]*100,
color = 'grey',size = 1.2) +
theme_cowplot(12)+
theme(axis.title = element_text(size = 18))+
ylab("Malignancy Prevalence (%)") +
xlab("% Cell Growth Over Time [AUC] Relative to Untreated at 2 Gy of Radiation") +
geom_point(aes(colour= Keep, size = TotalRecords)) +
geom_text_repel(aes(label=common_name))+
scale_size(name = "Total Necropsies",
breaks = c(20,150,250,394),
labels = c(20,150,250,394))+
theme(
plot.title = element_text(size = 20, face = "bold")) +
theme(legend.position = "bottom")+
labs(title = "Malignancy vs. AUC Area Change From UT 2Gy Radiation",
subtitle =bquote(p-value:.(p.v.Change.2.GY.mal)~R^2:.(r.Change.2.GY.mal)~Lambda:.(ld.v.Change.2.GY.mal)))+
guides(col=FALSE)
ggsave(filename='S47RADChange2mal.pdf', width=9.5, height=7, limitsize=FALSE,bg="white")
#Change .4
##Model
Change.04.GY.mal <- pglsSEyPagel(MalignancyPrevalence~log10(Change04Gy), data=Data,
tree=pruned.tree,method="ML",se=SE)
#grab r squared, p value, and lambda from summary
r.Change.04.GY.mal <- R2(phy = pruned.tree,Change.04.GY.mal)
r.Change.04.GY.mal <- format(r.Change.04.GY.mal[3])
r.Change.04.GY.mal <-signif(as.numeric(r.Change.04.GY.mal), digits = 2)
ld.v.Change.04.GY.mal<- summary(Change.04.GY.mal)$modelStruct$corStruct
ld.v.Change.04.GY.mal <- signif(ld.v.Change.04.GY.mal[1], digits = 2)
p.v.Change.04.GY.mal<-summary(Change.04.GY.mal)$tTable
p.v.Change.04.GY.mal<-signif(p.v.Change.04.GY.mal[2,4], digits = 2)
#plot
ggplot(Data, aes(y=MalignancyPrevalence*100, x=log10(Change04Gy))) +
scale_color_manual(values=c("#631879FF"))+
scale_x_continuous(
limits = c(1.87506,2.04),
breaks = c(1.8750,1.95424,2.04),
labels = c(75,90,110)
)+
geom_abline(intercept = coef(Change.04.GY.mal)[1]*100, slope = coef(Change.04.GY.mal)[2]*100,
color = 'grey',size = 1.2) +
theme_cowplot(12)+
theme(axis.title = element_text(size = 18))+
ylab("Malignancy Prevalence (%)") +
xlab("% Cell Growth Over Time [AUC] Relative to Untreated at 0.4 Gy of Radiation") +
geom_point(aes(colour= Keep, size = TotalRecords)) +
geom_text_repel(aes(label=common_name))+
scale_size(name = "Total Necropsies",
breaks = c(20,150,250,394),
labels = c(20,150,250,394))+
theme(
plot.title = element_text(size = 20, face = "bold")) +
theme(legend.position = "bottom")+
labs(title = "Malignancy vs. AUC Area Change From UT .4Gy Radiation",
subtitle =bquote(p-value:.(p.v.Change.04.GY.mal)~R^2:.(r.Change.04.GY.mal)~Lambda:.(ld.v.Change.04.GY.mal)))+
guides(col=FALSE)
ggsave(filename='S48RADChange04mal.pdf', width=9.5, height=7, limitsize=FALSE,bg="white")