Heller title: “Phar7380 Wk9 Mult Dose Simulations” output: html_document Oct 17, 2024

#libraries

library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

#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"))}

#multiple dosing, oral dosing, 1 comp population sim

oralmd1c<-read.table("C:\\Heller\\PHAR7380\\week9\\oralmd1c.res",header=F)
names(oralmd1c)<-c("ID","REPI","DAY","NTIME","TIME","DV","IPRED","PRED","CMT")
oralmd1csum<-oralmd1c%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu95=quantile(IPRED,0.975),cu05=quantile(IPRED,0.025))

#multiple dosing, oral dosing, 1 comp plot population sim

#tiff("C:\\Heller\\PHAR7380\\week9\\oralmd1cpop.tiff")
ggplot(data=oralmd1c,aes(TIME,IPRED,group=REPI))+
geom_line(size=0.5)+
scale_x_continuous(limits = c(0,120),breaks = c(0,24,48,72,96,120))+
theme_bw()+
my_theme()+
labs(x="Time after dose (hour)",y="Plasma concentration (ng/ml)")+
geom_hline(yintercept = c(5,30), linetype="dashed", color = "red")
## 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.

#dev.off()
##median and 95% CI
#tiff("C:\\Heller\\PHAR7380\\week9\\oralmd1cpopCI.tiff")
ggplot(data=oralmd1csum,aes(TIME,cmed))+
geom_line(size=0.5)+
geom_point(size=2)+
geom_line(data=oralmd1csum,aes(TIME,cu95),size=0.5,linetype="dashed")+
geom_point(data=oralmd1csum,aes(TIME,cu95),size=2)+
geom_line(data=oralmd1csum,aes(TIME,cu05),size=0.5,linetype="dashed")+
geom_point(data=oralmd1csum,aes(TIME,cu05),size=2)+
scale_x_continuous(limits = c(0,120),breaks = c(0,24,48,72,96,120))+
theme_bw()+
my_theme()+
labs(x="Time after dose (hour)",y="Plasma concentration (ng/ml)")+
geom_hline(yintercept = c(5,30), linetype="dashed", color = "red")

#dev.off()

#multiple dosing, oral dosing, 2 comp population sim

oralmd2c<-read.table ("C:\\Heller\\PHAR7380\\week9\\oralmd2c.res",header=F) #oralmd2c<-read.table oralmd2c<-read.table ("C:\\Heller\\PHAR7380\\week9\\oralmd2c.res",skip=1,header=T)
names(oralmd2c)<-c("ID","REPI","DAY","NTIME","TIME","DV","IPRED","PRED","CMT")
oralmd2csum<-oralmd1c%>%group_by(TIME)%>%summarise(cmed=median(IPRED),cu95=quantile(IPRED,0.975),cu05=quantile(IPRED,0.025))

#multiple dosing, oral dosing, 2 comp plot population sim

#tiff("C:\\Heller\\PHAR7380\\week9\\oralmd2cpop.tiff")
ggplot(data=oralmd2c,aes(TIME,IPRED,group=REPI))+
geom_line(size=0.5)+
scale_x_continuous(limits = c(0,120),breaks = c(0,24,48,72,96,120))+
theme_bw()+
my_theme()+
labs(x="Time after dose (hour)",y="Plasma concentration (ng/ml)")+
geom_hline(yintercept = c(5,30), linetype="dashed", color = "red")

#dev.off()
##median and 95% CI
#tiff("C:\\Heller\\PHAR7380\\week9\\oralmd2cpopCI.tiff")
ggplot(data=oralmd2csum,aes(TIME,cmed))+
geom_line(size=0.5)+
geom_point(size=2)+
geom_line(data=oralmd2csum,aes(TIME,cu95),size=0.5,linetype="dashed")+
geom_point(data=oralmd2csum,aes(TIME,cu95),size=2)+
geom_line(data=oralmd2csum,aes(TIME,cu05),size=0.5,linetype="dashed")+
geom_point(data=oralmd2csum,aes(TIME,cu05),size=2)+
scale_x_continuous(limits = c(0,120),breaks = c(0,24,48,72,96,120))+
theme_bw()+
my_theme()+
labs(x="Time after dose (hour)",y="Plasma concentration (ng/ml)")+
geom_hline(yintercept = c(5,30), linetype="dashed", color = "red")

#dev.off()