Heller title: “Phar7380 PD Project” Dec 8, 2024 output: html_document: default pdf_document: default word_document: default — #libraries

library(ggplot2)
library(dplyr)
library(knitr)

#theme

my_theme<-function(x){theme_bw()+
    theme(text = element_text(size=20))+
    theme(axis.line.y = element_line(size = 2.0))+
    theme(axis.line.x = element_line(size = 2.0))+
    theme(axis.ticks = element_line(size = 1.5,colour="black"))+
    theme(axis.ticks.length=  unit(0.45, "cm"))+
    theme(axis.title.y =element_text(vjust=1.2))+
    theme(axis.title.x =element_text(vjust=-0.2))+
    theme(axis.text=element_text(colour="black"))+
    theme(panel.background = element_rect(fill ="white"))}

#40 mg dose 10 subjects IDs 1 through 10

Read res file

sim40_10n<-read.table("C:\\Heller\\PHAR7380\\sandbox\\q2w40mg_10n.res",skip=1,header=T)


#PK Profile
ggplot(data=sim40_10n%>%filter(CMT==2),aes(TIME/7,IPRED,group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## i Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
## i Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

#PD Profile
ggplot(data=sim40_10n%>%filter(CMT==3),aes(TIME/7,IPRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP (mg/L)")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#Create summary files for PK and PD 10 subjects IDs 1 through 10

sim40_10nsum2<-sim40_10n%>%filter(CMT==2)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))
sim40_10nsum3<-sim40_10n%>%filter(CMT==3)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))

#plots for 40mg dose PK using sim40_10n

ggplot(data=sim40_10n%>%filter(CMT==2),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_10nsum2
ggplot(data=sim40_10nsum2,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim40_10nsum2,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim40_10nsum2,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc(mg/L)ah")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#plots for 40mg dose CRP using sim40_10n

ggplot(data=sim40_10n%>%filter(CMT==3),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CD4 count/mL")
#labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)a")+
    #scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))
labs(x="Time after dose (week)",y="CRP (mg/L)")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_10nsum3
ggplot(data=sim40_10nsum3,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim40_10nsum3,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim40_10nsum3,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CRP (mg/L)")
labs(x="Time after dose (week)",y="CRP (mg/L)")+geom_hline(yintercept=8, linetype="dashed", color = "red")+scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#8040 dose n=10

sim8040_10n<-read.table("C:\\Heller\\PHAR7380\\sandbox\\ld80mgq2w40_n10.res",skip=1,header=T)

#PK Profile
ggplot(data=sim8040_10n%>%filter(CMT==2),aes(TIME/7,IPRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim8040_10n%>%filter(CMT==3),aes(TIME/7,IPRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP (mg/L)")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

Plots with CI for 8040 Dose

#PK Profile
ggplot(data=sim8040_10n%>%filter(CMT==2),aes(TIME/7,IPRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim8040_10n%>%filter(CMT==3),aes(TIME/7,IPRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP (mg/L)")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

sim8040_10nsum2<-sim8040_10n%>%filter(CMT==2)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))
sim8040_10nsum3<-sim8040_10n%>%filter(CMT==3)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))

#plots 8040 dose n=10

ggplot(data=sim8040_10n%>%filter(CMT==3),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CD4 count/mL")
#labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)a")+
    #scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))
labs(x="Time after dose (week)",y="CRP (mg/L)")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_10nsum3
ggplot(data=sim8040_10nsum3,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim40_10nsum3,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim40_10nsum3,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CRP (mg/L)")
labs(x="Time after dose (week)",y="CRP (mg/L)")+geom_hline(yintercept=8, linetype="dashed", color = "red")+scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#40 mg dose n=100 subjects IDs 1 through 100, Populatio

sim40_100n<-read.table("C:\\Heller\\PHAR7380\\sandbox\\q2w40mg_100n.res",skip=1,header=T)


#PK Profile
ggplot(data=sim40_100n%>%filter(CMT==2),aes(TIME/7,PRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc (mg/L) 40q2w")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim40_100n%>%filter(CMT==3),aes(TIME/7,PRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP (mg/L) 40q2w")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

Read res file 40mg q2w individual

sim40_100n<-read.table("C:\\Heller\\PHAR7380\\sandbox\\q2w40mg_100n.res",skip=1,header=T)


#PK Profile
ggplot(data=sim40_100n%>%filter(CMT==2),aes(TIME/7,IPRED,group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc (mg/L) 40q2w")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim40_100n%>%filter(CMT==3),aes(TIME/7,IPRED,group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP (mg/L) 40q2w")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#Create summary files for PK and PD 100 subjects IDs 1 through 100

sim40_100nsum2<-sim40_100n%>%filter(CMT==2)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))
sim40_100nsum3<-sim40_10n%>%filter(CMT==3)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))

#plots for 40mg dose PK using sim40_100n

ggplot(data=sim40_100n%>%filter(CMT==2),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_10nsum2
ggplot(data=sim40_100nsum2,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim40_100nsum2,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim40_100nsum2,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc(mg/L)ah")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#plots for 40mg dose CRP using sim40_100n

ggplot(data=sim40_100n%>%filter(CMT==3),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CD4 count/mL")
#labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)a")+
    #scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))
labs(x="Time after dose (week)",y="CRP (mg/L)")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_100nsum3
ggplot(data=sim40_100nsum3,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim40_100nsum3,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim40_100nsum3,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CRP (mg/L)")
labs(x="Time after dose (week)",y="CRP (mg/L)")+geom_hline(yintercept=8, linetype="dashed", color = "red")+scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#8040 mg dose n=100 subjects IDs 1 through 100

Read res file

sim8040_100n<-read.table("C:\\Heller\\PHAR7380\\sandbox\\ld80mgq2w40_n100.res",skip=1,header=T)


#PK Profile
ggplot(data=sim8040_100n%>%filter(CMT==2),aes(TIME/7,IPRED,group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNTConc(mg/L)8040")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim8040_100n%>%filter(CMT==3),aes(TIME/7,IPRED, group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP(mg/L) 8040")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#Create summary files for 8040 PK and PD 100 subjects IDs 1 through 100

sim8040_100nsum2<-sim8040_100n%>%filter(CMT==2)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))
sim8040_100nsum3<-sim8040_10n%>%filter(CMT==3)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))

#plots for 8040mg dose PK using sim8040_100n

ggplot(data=sim8040_100n%>%filter(CMT==2),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_10nsum2
ggplot(data=sim8040_100nsum2,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim8040_100nsum2,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim8040_100nsum2,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc(mg/L)ah")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#plots for 8040mg dose CRP using sim8040_100n

ggplot(data=sim8040_100n%>%filter(CMT==3),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CD4 count/mL")
#labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)a")+
    #scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))
labs(x="Time after dose (week)",y="CRP (mg/L)")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_100nsum3
ggplot(data=sim8040_100nsum3,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim8040_100nsum3,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim8040_100nsum3,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CRP (mg/L)")
labs(x="Time after dose (week)",y="CRP (mg/L)")+geom_hline(yintercept=8, linetype="dashed", color = "red")+scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#16040 mg dose n=100 subjects IDs 1 through 100

Read res file

sim16040_100n<-read.table("C:\\Heller\\PHAR7380\\sandbox\\ld160mgq2w40_n100.res",skip=1,header=T)


#PK Profile
ggplot(data=sim16040_100n%>%filter(CMT==2),aes(TIME/7,IPRED,group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNTConc(mg/L) 16040")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim16040_100n%>%filter(CMT==3),aes(TIME/7,IPRED, group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP(mg/L) 16040")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#Create summary files for 16040 PK and PD 100 subjects IDs 1 through 100

sim16040_100nsum2<-sim16040_100n%>%filter(CMT==2)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))
sim16040_100nsum3<-sim16040_100n%>%filter(CMT==3)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))

#plots for 16040mg dose PK using sim16040_100n

ggplot(data=sim16040_100n%>%filter(CMT==2),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_10nsum2
ggplot(data=sim16040_100nsum2,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim16040_100nsum2,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim16040_100nsum2,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc(mg/L)ah")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#plots for 8040mg dose CRP using sim8040_100n

ggplot(data=sim16040_100n%>%filter(CMT==3),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CD4 count/mL")
#labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)a")+
    #scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))
labs(x="Time after dose (week)",y="CRP (mg/L)")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_100nsum3
ggplot(data=sim16040_100nsum3,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim16040_100nsum3,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim16040_100nsum3,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CRP (mg/L)")
labs(x="Time after dose (week)",y="CRP (mg/L)")+geom_hline(yintercept=8, linetype="dashed", color = "red")+scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#32040 mg dose n=100 subjects IDs 1 through 100

Read res file 32040

sim32040_100n<-read.table("C:\\Heller\\PHAR7380\\sandbox\\ld320mgq2w40_n100.res",skip=1,header=T)


#PK Profile
ggplot(data=sim32040_100n%>%filter(CMT==2),aes(TIME/7,IPRED,group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNTConc(mg/L)32040")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim32040_100n%>%filter(CMT==3),aes(TIME/7,IPRED, group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP(mg/L) 32040")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#Create summary files for 32040 PK and PD 100 subjects IDs 1 through 100

sim32040_100nsum2<-sim32040_100n%>%filter(CMT==2)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))
sim32040_100nsum3<-sim32040_100n%>%filter(CMT==3)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))

#plots for 32040mg dose PK using sim32040_100n

ggplot(data=sim32040_100n%>%filter(CMT==2),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_10nsum2
ggplot(data=sim32040_100nsum2,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim32040_100nsum2,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim32040_100nsum2,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc(mg/L)")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#plots for 8040mg dose CRP using sim8040_100n

ggplot(data=sim32040_100n%>%filter(CMT==3),aes(TIME/7,PRED))+
geom_line(size=0.5)+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CD4 count/mL")
#labs(x="Time after dose (week)",y="UNT763 Concentration (mg/L)a")+
    #scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))
labs(x="Time after dose (week)",y="CRP (mg/L)")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#median and 95% CI using sim40_100nsum3
ggplot(data=sim32040_100nsum3,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim32040_100nsum3,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim32040_100nsum3,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CRP (mg/L)")
labs(x="Time after dose (week)",y="CRP (mg/L)")+geom_hline(yintercept=8, linetype="dashed", color = "red")+scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

Read res file 32080 and pop plots

sim32080_100n<-read.table("C:\\Heller\\PHAR7380\\sandbox\\ld320mgq2w80_n100.res",skip=1,header=T)


#PK Profile
ggplot(data=sim32080_100n%>%filter(CMT==2),aes(TIME/7,PRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc(mg/L) 32080")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim32080_100n%>%filter(CMT==3),aes(TIME/7,PRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP(mg/L) 32080")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PK Profile
ggplot(data=sim32080_100n%>%filter(CMT==2),aes(TIME/7,IPRED, group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc(mg/L) 32080")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim32080_100n%>%filter(CMT==3),aes(TIME/7,IPRED, group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP(mg/L) 32080")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#create 95 CI summary tables for 32080

sim32080_100nsum2<-sim32080_100n%>%filter(CMT==2)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))
sim32080_100nsum3<-sim32080_100n%>%filter(CMT==3)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))

#32080 plots median 95 CI

#PK median and 95% CI 
ggplot(data=sim32080_100nsum2,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim32080_100nsum2,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim32080_100nsum2,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNTConc(mg/L) 32080")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#32080 plots median 95 CI

ggplot(data=sim32080_100nsum3,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim32080_100nsum3,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim32080_100nsum3,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CRP (mg/L)")
labs(x="Time after dose (week)",y="CRP(mg/L) 32080")+geom_hline(yintercept=8, linetype="dashed", color = "red")+scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#read file 320160 and population plots

sim320160_100n<-read.table("C:\\Heller\\PHAR7380\\sandbox\\ld320mgq2w160_n100.res",skip=1,header=T)


#PK Profile
ggplot(data=sim320160_100n%>%filter(CMT==2),aes(TIME/7,PRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc(mg/L) 320160")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim32080_100n%>%filter(CMT==3),aes(TIME/7,PRED))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP(mg/L) 320160")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#individual predictions 320160

#PK Profile
ggplot(data=sim320160_100n%>%filter(CMT==2),aes(TIME/7,IPRED,group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNT763 Conc(mg/L) 320160")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#PD Profile
ggplot(data=sim32080_100n%>%filter(CMT==3),aes(TIME/7,IPRED,group=ID))+
geom_line(size=0.5)+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="CRP(mg/L) 320160")+
geom_hline(yintercept=8, linetype="dashed", color = "red")+
scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#create 95ci summary files for 320160

sim320160_100nsum2<-sim320160_100n%>%filter(CMT==2)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))
sim320160_100nsum3<-sim320160_100n%>%filter(CMT==3)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu975=quantile(IPRED,0.975),cu025=quantile(IPRED,0.025))

#95 ci for PK and CRP for 320160

ggplot(data=sim320160_100nsum2,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim320160_100nsum2,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim320160_100nsum2,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
labs(x="Time after dose (week)",y="UNTConc(mg/L)320160")+
    scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

ggplot(data=sim320160_100nsum3,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim320160_100nsum3,aes((TIME/7),cu975),size=0.5,linetype="dashed")+
geom_line(data=sim320160_100nsum3,aes((TIME/7),cu025),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CRP (mg/L)")
labs(x="Time after dose (week)",y="CRP (mg/L)320160")+geom_hline(yintercept=8, linetype="dashed", color = "red")+scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

#table for 320160

sim320160_100n%>%
    select(ID,TIME,CMT,IPRED)%>%
    group_by(TIME)%>%
    filter(CMT==3)%>%
    #mutate(suppression=(IPRED)%>%
    filter(IPRED>=8)%>%
    summarise(number=n_distinct(ID))%>%kable
TIME number
1 99
2 83
3 46
4 23
5 15
6 9
7 7
8 6
9 4
10 4
11 4
12 4
13 4
14 4
15 3
16 3
17 3
18 3
19 3
20 3
21 2
22 2
23 2
24 2
25 2
26 2
27 2
28 2
29 2
30 2
31 2
32 2
33 2
34 2
35 2
36 2
37 2
38 2
39 2
40 2
41 2
42 2
43 2
44 2
45 2
46 2
47 2
48 2
49 2
50 2
51 2
52 2
53 2
54 2
55 2
56 2
57 2
58 2
59 2
60 2
61 2
62 2
63 2
64 2
65 2
66 2
67 2
68 2
69 2
70 2
71 2
72 2
73 2
74 2
75 2
76 2
77 2
78 2
79 2
80 2
81 2
82 2
83 2
84 2
85 2
86 2
87 2
88 2
89 2
90 2
91 2
92 2
93 2
94 2
95 2
96 2
97 2
98 2
99 2
100 2
101 2
102 2
103 2
104 1
105 2

#table for 32080

sim32080_100n%>%
    select(ID,TIME,CMT,IPRED)%>%
    group_by(TIME)%>%
    filter(CMT==3)%>%
    #mutate(suppression=(IPRED)%>%
    filter(IPRED>=8)%>%
    summarise(number=n_distinct(ID))%>%kable
TIME number
1 99
2 83
3 46
4 23
5 15
6 9
7 7
8 6
9 4
10 4
11 4
12 4
13 4
14 4
15 3
16 3
17 3
18 3
19 3
20 3
21 3
22 3
23 3
24 3
25 3
26 3
27 3
28 5
29 5
30 3
31 3
32 3
33 3
34 3
35 3
36 3
37 3
38 4
39 5
40 6
41 7
42 8
43 8
44 6
45 6
46 4
47 4
48 4
49 4
50 5
51 5
52 6
53 8
54 8
55 8
56 8
57 8
58 8
59 7
60 6
61 6
62 5
63 5
64 6
65 7
66 8
67 8
68 8
69 8
70 9
71 9
72 8
73 8
74 7
75 7
76 7
77 7
78 7
79 8
80 8
81 8
82 8
83 9
84 9
85 9
86 8
87 8
88 8
89 7
90 7
91 7
92 8
93 8
94 8
95 8
96 8
97 9
98 9
99 9
100 8
101 8
102 8
103 8
104 8
105 8

#16040

sim16040_100n%>%
    select(ID,TIME,CMT,IPRED)%>%
    group_by(TIME)%>%
    filter(CMT==3)%>%
    #mutate(suppression=(IPRED)%>%
    filter(IPRED>=8)%>%
    summarise(number=n_distinct(ID))%>%kable
TIME number
1 99
2 92
3 79
4 62
5 44
6 36
7 31
8 29
9 27
10 25
11 26
12 27
13 27
14 28
15 27
16 26
17 24
18 23
19 23
20 23
21 23
22 23
23 25
24 25
25 26
26 27
27 28
28 29
29 29
30 28
31 27
32 27
33 26
34 26
35 26
36 28
37 28
38 28
39 28
40 31
41 33
42 35
43 35
44 32
45 28
46 28
47 28
48 28
49 28
50 28
51 29
52 31
53 33
54 37
55 37
56 38
57 37
58 36
59 35
60 31
61 29
62 29
63 30
64 31
65 33
66 35
67 37
68 37
69 37
70 43
71 42
72 37
73 36
74 35
75 31
76 31
77 31
78 35
79 35
80 36
81 37
82 37
83 43
84 44
85 44
86 39
87 36
88 35
89 34
90 34
91 34
92 35
93 35
94 37
95 37
96 40
97 44
98 45
99 44
100 40
101 36
102 36
103 35
104 34
105 35
sim32040_100n%>%
    select(ID,TIME,CMT,IPRED)%>%
    group_by(TIME)%>%
    filter(CMT==3)%>%
    #mutate(suppression=(IPRED)%>%
    filter(IPRED>=8)%>%
    summarise(number=n_distinct(ID))%>%kable
TIME number
1 99
2 84
3 46
4 23
5 15
6 9
7 7
8 6
9 4
10 4
11 4
12 4
13 4
14 4
15 4
16 3
17 3
18 3
19 3
20 3
21 4
22 4
23 5
24 5
25 8
26 8
27 9
28 9
29 9
30 9
31 9
32 9
33 9
34 9
35 9
36 9
37 9
38 10
39 10
40 10
41 12
42 14
43 14
44 13
45 11
46 11
47 11
48 12
49 12
50 13
51 16
52 17
53 19
54 20
55 22
56 25
57 25
58 23
59 21
60 21
61 20
62 21
63 21
64 22
65 23
66 24
67 26
68 28
69 28
70 31
71 30
72 28
73 26
74 25
75 25
76 24
77 25
78 25
79 27
80 29
81 30
82 31
83 31
84 33
85 33
86 31
87 30
88 29
89 27
90 28
91 28
92 29
93 30
94 31
95 33
96 33
97 33
98 35
99 35
100 33
101 32
102 31
103 30
104 29
105 30

#table for 16040

sim16040_100n%>%
    select(ID,TIME,CMT,IPRED)%>%
    group_by(TIME)%>%
    filter(CMT==3)%>%
    #mutate(suppression=(IPRED)%>%
    filter(IPRED>=8)%>%
    summarise(number=n_distinct(ID))%>%kable
TIME number
1 99
2 92
3 79
4 62
5 44
6 36
7 31
8 29
9 27
10 25
11 26
12 27
13 27
14 28
15 27
16 26
17 24
18 23
19 23
20 23
21 23
22 23
23 25
24 25
25 26
26 27
27 28
28 29
29 29
30 28
31 27
32 27
33 26
34 26
35 26
36 28
37 28
38 28
39 28
40 31
41 33
42 35
43 35
44 32
45 28
46 28
47 28
48 28
49 28
50 28
51 29
52 31
53 33
54 37
55 37
56 38
57 37
58 36
59 35
60 31
61 29
62 29
63 30
64 31
65 33
66 35
67 37
68 37
69 37
70 43
71 42
72 37
73 36
74 35
75 31
76 31
77 31
78 35
79 35
80 36
81 37
82 37
83 43
84 44
85 44
86 39
87 36
88 35
89 34
90 34
91 34
92 35
93 35
94 37
95 37
96 40
97 44
98 45
99 44
100 40
101 36
102 36
103 35
104 34
105 35

#Create 90CI summary files for 32040 PK and PD 100 subjects IDs 1 through 100 - named 2A, 3A

sim32040_100nsum2A<-sim32040_100n%>%filter(CMT==2)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu95=quantile(IPRED,0.95),cu05=quantile(IPRED,0.05))
sim32040_100nsum3A<-sim32040_100n%>%filter(CMT==3)%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu95=quantile(IPRED,0.95),cu05=quantile(IPRED,0.05))

#Try using a wider confidence interval for 320, ie 90% (950 and 050)

#median and 90% CI using sim16040_100nsum3A
ggplot(data=sim32040_100nsum3A,aes((TIME/7),cmed*1))+
geom_line(size=0.5)+
geom_line(data=sim32040_100nsum3A,aes((TIME/7),cu95),size=0.5,linetype="dashed")+
geom_line(data=sim32040_100nsum3A,aes((TIME/7),cu05),size=0.5,linetype="dashed")+
#scale_x_continuous(limits = c(0,6))+
theme_bw()+
my_theme()+
#labs(x="Time after dose (week)",y="CRP (mg/L)")
labs(x="Time after dose (week)",y="CRP (mg/L),90CI")+geom_hline(yintercept=8, linetype="dashed", color = "red")+scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16),limits = c(0,16))

table for 32040

    sim32040_100n%>%
    select(ID,TIME,CMT,IPRED)%>%
    group_by(TIME)%>%
    filter(CMT==3)%>%
    #mutate(suppression=(IPRED)%>%
    filter(IPRED>=8)%>%
    summarise(number=n_distinct(ID))%>%kable
TIME number
1 99
2 84
3 46
4 23
5 15
6 9
7 7
8 6
9 4
10 4
11 4
12 4
13 4
14 4
15 4
16 3
17 3
18 3
19 3
20 3
21 4
22 4
23 5
24 5
25 8
26 8
27 9
28 9
29 9
30 9
31 9
32 9
33 9
34 9
35 9
36 9
37 9
38 10
39 10
40 10
41 12
42 14
43 14
44 13
45 11
46 11
47 11
48 12
49 12
50 13
51 16
52 17
53 19
54 20
55 22
56 25
57 25
58 23
59 21
60 21
61 20
62 21
63 21
64 22
65 23
66 24
67 26
68 28
69 28
70 31
71 30
72 28
73 26
74 25
75 25
76 24
77 25
78 25
79 27
80 29
81 30
82 31
83 31
84 33
85 33
86 31
87 30
88 29
89 27
90 28
91 28
92 29
93 30
94 31
95 33
96 33
97 33
98 35
99 35
100 33
101 32
102 31
103 30
104 29
105 30

```