library(readr)
df <- read_csv("~/Juvena/PK/data/PK09 - Final_data.csv")
##
## -- Column specification --------------------------------------------------------
## cols(
## Time = col_double(),
## Conc = col_double(),
## ID = col_double(),
## amt = col_double(),
## Type = col_character()
## )
df
## # A tibble: 56 x 5
## Time Conc ID amt Type
## <dbl> <dbl> <dbl> <dbl> <chr>
## 1 0 NA 1 309 Albumin-Elisa
## 2 0.05 58.7 1 NA Albumin-Elisa
## 3 0.167 51.3 1 NA Albumin-Elisa
## 4 0.333 48.2 1 NA Albumin-Elisa
## 5 0.5 NA 1 NA Albumin-Elisa
## 6 1 39.1 1 NA Albumin-Elisa
## 7 2 28.9 1 NA Albumin-Elisa
## 8 4 21.1 1 NA Albumin-Elisa
## 9 6 17.0 1 NA Albumin-Elisa
## 10 10 8.72 1 NA Albumin-Elisa
## # ... with 46 more rows
Distribution: < 6 hrs Elimination >= 6 hrs
df$Phase = ""
df[which(df$Time < 6), 6] = "Distribution"
df[which(df$Time >= 6), 6] = "Elimination"
df$ID = factor(df$ID)
df
## # A tibble: 56 x 6
## Time Conc ID amt Type Phase
## <dbl> <dbl> <fct> <dbl> <chr> <chr>
## 1 0 NA 1 309 Albumin-Elisa Distribution
## 2 0.05 58.7 1 NA Albumin-Elisa Distribution
## 3 0.167 51.3 1 NA Albumin-Elisa Distribution
## 4 0.333 48.2 1 NA Albumin-Elisa Distribution
## 5 0.5 NA 1 NA Albumin-Elisa Distribution
## 6 1 39.1 1 NA Albumin-Elisa Distribution
## 7 2 28.9 1 NA Albumin-Elisa Distribution
## 8 4 21.1 1 NA Albumin-Elisa Distribution
## 9 6 17.0 1 NA Albumin-Elisa Elimination
## 10 10 8.72 1 NA Albumin-Elisa Elimination
## # ... with 46 more rows
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:readr':
##
## col_factor
library(ggplot2)
p <- ggplot(df, aes(x=Time, y=Conc, color=ID, group=Phase)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, size = 2) +
scale_y_continuous(expand = expansion(mult = c(0,0.05)),
trans='log10', breaks=trans_breaks('log10', function(x) 10^x),
labels=trans_format('log10', math_format(10^.x))) +
xlab("Time (h)") +
ylab(c("Serum Concetration (log)\n(ng/ml)")) +
scale_x_continuous(breaks=seq(0, 150, 25)) +
theme_classic() +
theme(text = element_text(size=20),
legend.justification=c(0,0),
legend.position=c(0.05,0),
# legend.title = element_blank(),
legend.text = element_text( size = 12))
p
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 9 rows containing non-finite values (stat_smooth).
## Warning: Removed 9 rows containing missing values (geom_point).