Heller title: “PHAR7380-week6_complete” output: word_document Sep 28, 2024

#library

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

#data import (you should have run nonmem models shown in the class already for the codes below to work. Please follow instructions from word document posted for running models.)

oralmd1csim<-read.table("C:\\Heller\\PHAR7380\\Week6\\oralmd1c.res",header=T,skip=1)
oralmd2csim<-read.table("C:\\Heller\\PHAR7380\\Week6\\oralmd.res",header=T,skip=1)

#plot, 1 comp multiple dose simulation done in video

ggplot(data=oralmd1csim,aes(TIME,IPRED))+
geom_line(size=0.5)+
geom_point(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,15), 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.

#plot, 2 comp multiple dose simulation done in video

ggplot(data=oralmd2csim,aes(TIME,IPRED))+
geom_line(size=0.5)+
geom_point(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,15), linetype="dashed", color = "red")

#homework solution

#importing data after simulation
hsc100mdsim<-read.table("C:\\Heller\\PHAR7380\\Week6\\hsc100mdsim.res",header=T,skip=1)
#converting DOSE column into a factor to enable plotting by dose  below
hsc100mdsim$DOSE<-as.factor(hsc100mdsim$DOSE)
#plot of exposure by dose level
ggplot(data=hsc100mdsim,aes(TIME,IPRED,color=DOSE))+
geom_line(size=0.5)+
geom_point(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(250), linetype="dashed", color = "red")

print (hsc100mdsim) hsc100mdsim