Heller Phar7383 Wk4 tdscase 02_16_25 title: “Individual approach tds case” output: html_document —
#libraries
rm(list=ls())
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
library(PKNCA)
## Warning: package 'PKNCA' was built under R version 4.4.2
##
## Attaching package: 'PKNCA'
## The following object is masked from 'package:stats':
##
## filter
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"))}
#data import and analysis
wk4_tds<-read.csv("C:\\Heller\\PHAR7383\\week4\\tdscase\\tdsnmdt.csv",stringsAsFactors = F)
#wk4_tds<-read.csv("/work/ac0837/PHAR7383/wk4-indapproach/tds/tdsnmdt.csv",stringsAsFactors = F)
wk4_tds_sum<-wk4_tds%>%group_by(TIME)%>%summarise(cmean=mean(CONC),stdev=sd(CONC))
#plot
#Population Plot
ggplot(data=wk4_tds,aes(TIME,CONC,group=ID))+
geom_line(size=0.5)+
geom_point(size=1)+
scale_x_continuous(limits = c(0,144),breaks = c(0,1,2,4,6,8,12,24,48,82,96,120,144))+
theme_bw()+
my_theme()+
labs(x="Time after dose (hour)",y="Plasma concentration (ng/ml)")
## 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.
#average plot with standard deviation (+/-1SD)
ggplot(data=wk4_tds_sum,aes(TIME,cmean))+
geom_line(size=0.5)+
geom_point(size=2)+
scale_x_continuous(limits = c(0,144),breaks = c(0,1,2,4,6,8,12,24,48,82,96,120,144))+
geom_errorbar(aes(ymin=cmean-stdev, ymax=cmean+stdev), width=.2)+
theme_bw()+
my_theme()+
labs(x="Time after dose (hour)",y="Plasma concentration (ng/ml)")
#model building #batch processing
onecompres<-list()
for (i in 1:12){
onecompres[[i]]<-read.table(paste("/Heller/PHAR7383/week4/tdscase/id",i,"onecmp.res",sep=""),skip=1,header=T)}
onecompresdf<-do.call("rbind",onecompres)%>%
mutate(model="onecomp")
twocompres<-list()
for (i in 1:12){
twocompres[[i]]<-read.table(paste("/Heller/PHAR7383/week4/tdscase/id",i,"twocmp.res",sep=""),skip=1,header=T)}
twocompresdf<-do.call("rbind",twocompres)%>%
mutate(model="twocomp")
modelcomb<-rbind(onecompresdf,twocompresdf)
#Plotting ID 1
#Time versus oberved and predicted
ggplot(data=modelcomb%>%filter(ID==1),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==1),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==1),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 2
#Time versus oberved and predicted
ggplot(data=modelcomb%>%filter(ID==2),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==2),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==2),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 3
#Time versus oberved and predicted
ggplot(data=modelcomb%>%filter(ID==3),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==3),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==3),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 4
#Time versus oberved and predicted
ggplot(data=modelcomb%>%filter(ID==4),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==4),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==4),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 5
ggplot(data=modelcomb%>%filter(ID==5),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==5),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==5),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 6
ggplot(data=modelcomb%>%filter(ID==6),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==6),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==6),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 7
ggplot(data=modelcomb%>%filter(ID==7),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==7),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==7),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 8
ggplot(data=modelcomb%>%filter(ID==8),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==8),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==8),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 9
ggplot(data=modelcomb%>%filter(ID==9),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==9),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==9),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 10
ggplot(data=modelcomb%>%filter(ID==10),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==10),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==10),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 11
ggplot(data=modelcomb%>%filter(ID==11),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==11),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==11),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Plotting ID 12
ggplot(data=modelcomb%>%filter(ID==12),aes(TIME,CONC))+
geom_point(size=3) +
geom_line(aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
labs(x="Time (hour)",y="Concentration (ug/L)")+
facet_wrap(vars(model))
#TIME versus WRES plot
ggplot(data=modelcomb%>%filter(ID==12),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))
#Predictions versus WRES plot
ggplot(data=modelcomb%>%filter(ID==12),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (WRES)")+
facet_wrap(vars(model))