library(readr)
df <- read_csv("12-14-2020_PK_His-HSA vs Millipore-HSA.csv")
##
## -- Column specification --------------------------------------------------------
## cols(
## Time = col_double(),
## Conc = col_double(),
## ID = col_double(),
## amt = col_double(),
## weight = col_double()
## )
df
## # A tibble: 44 x 5
## Time Conc ID amt weight
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0 NA 1 139. 27.9
## 2 0.167 39.7 1 NA NA
## 3 0.5 45.6 1 NA NA
## 4 1 38.0 1 NA NA
## 5 2 38.5 1 NA NA
## 6 4 29.7 1 NA NA
## 7 6 28.6 1 NA NA
## 8 24 19.3 1 NA NA
## 9 48 7.01 1 NA NA
## 10 72 3.05 1 NA NA
## # ... with 34 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: 44 x 6
## Time Conc ID amt weight Phase
## <dbl> <dbl> <fct> <dbl> <dbl> <chr>
## 1 0 NA 1 139. 27.9 Distribution
## 2 0.167 39.7 1 NA NA Distribution
## 3 0.5 45.6 1 NA NA Distribution
## 4 1 38.0 1 NA NA Distribution
## 5 2 38.5 1 NA NA Distribution
## 6 4 29.7 1 NA NA Distribution
## 7 6 28.6 1 NA NA Elimination
## 8 24 19.3 1 NA NA Elimination
## 9 48 7.01 1 NA NA Elimination
## 10 72 3.05 1 NA NA Elimination
## # ... with 34 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 4 rows containing non-finite values (stat_smooth).
## Warning: Removed 4 rows containing missing values (geom_point).