Dataverwerking

Laad de paketten

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.2     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(drc)
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## 
## The following object is masked from 'package:dplyr':
## 
##     select
## 
## 
## 'drc' has been loaded.
## 
## Please cite R and 'drc' if used for a publication,
## for references type 'citation()' and 'citation('drc')'.
## 
## 
## Attaching package: 'drc'
## 
## The following objects are masked from 'package:stats':
## 
##     gaussian, getInitial
library(janitor)
## 
## Attaching package: 'janitor'
## 
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(skimr)

Gebruik de set seed functie

set.seed(123)

Bepaal concentraties en bètablokker

concentratie <- c(0, 1, 2, 3, 4, 5)
bètablokker <- "Metoprolol"

Vul de gemiddelde hartslag in bij elk meetpunt

Metoprolol_means <- c(
  "0" = 347,
  "1" = 112,
  "2" = 129,
  "3" = 84,
  "4" = 76,
  "5" = 100
)

Metoprolol_means
##   0   1   2   3   4   5 
## 347 112 129  84  76 100

Maak een dataset

sim_data <- expand.grid(
  Compound = bètablokker,
  Concentration = concentratie,
  Replicate = 1:3,
  stringsAsFactors = FALSE
)

sim_data
##      Compound Concentration Replicate
## 1  Metoprolol             0         1
## 2  Metoprolol             1         1
## 3  Metoprolol             2         1
## 4  Metoprolol             3         1
## 5  Metoprolol             4         1
## 6  Metoprolol             5         1
## 7  Metoprolol             0         2
## 8  Metoprolol             1         2
## 9  Metoprolol             2         2
## 10 Metoprolol             3         2
## 11 Metoprolol             4         2
## 12 Metoprolol             5         2
## 13 Metoprolol             0         3
## 14 Metoprolol             1         3
## 15 Metoprolol             2         3
## 16 Metoprolol             3         3
## 17 Metoprolol             4         3
## 18 Metoprolol             5         3

Sorteer op concentratie

sim_data <- sim_data %>% 
  mutate(
    Concentration = as.numeric(Concentration),
    gemiddelde_hartslag = Metoprolol_means[as.character(Concentration)]
  ) %>% 
  arrange(Concentration)

sim_data
##      Compound Concentration Replicate gemiddelde_hartslag
## 1  Metoprolol             0         1                 347
## 2  Metoprolol             0         2                 347
## 3  Metoprolol             0         3                 347
## 4  Metoprolol             1         1                 112
## 5  Metoprolol             1         2                 112
## 6  Metoprolol             1         3                 112
## 7  Metoprolol             2         1                 129
## 8  Metoprolol             2         2                 129
## 9  Metoprolol             2         3                 129
## 10 Metoprolol             3         1                  84
## 11 Metoprolol             3         2                  84
## 12 Metoprolol             3         3                  84
## 13 Metoprolol             4         1                  76
## 14 Metoprolol             4         2                  76
## 15 Metoprolol             4         3                  76
## 16 Metoprolol             5         1                 100
## 17 Metoprolol             5         2                 100
## 18 Metoprolol             5         3                 100

Bereken gesimuleerde hartslag

sim_data <- sim_data %>% 
  mutate(
    Heart_Rate = round(
      rnorm(nrow(.), mean = as.numeric(gemiddelde_hartslag), sd = 3),
      1
    )
  )

sim_data
##      Compound Concentration Replicate gemiddelde_hartslag Heart_Rate
## 1  Metoprolol             0         1                 347      345.3
## 2  Metoprolol             0         2                 347      346.3
## 3  Metoprolol             0         3                 347      351.7
## 4  Metoprolol             1         1                 112      112.2
## 5  Metoprolol             1         2                 112      112.4
## 6  Metoprolol             1         3                 112      117.1
## 7  Metoprolol             2         1                 129      130.4
## 8  Metoprolol             2         2                 129      125.2
## 9  Metoprolol             2         3                 129      126.9
## 10 Metoprolol             3         1                  84       82.7
## 11 Metoprolol             3         2                  84       87.7
## 12 Metoprolol             3         3                  84       85.1
## 13 Metoprolol             4         1                  76       77.2
## 14 Metoprolol             4         2                  76       76.3
## 15 Metoprolol             4         3                  76       74.3
## 16 Metoprolol             5         1                 100      105.4
## 17 Metoprolol             5         2                 100      101.5
## 18 Metoprolol             5         3                 100       94.1

Behoud de definitieve kolommen in de dataframe

sim_data <- sim_data %>% 
  dplyr::select(Compound, Concentration, Replicate, Heart_Rate)

sim_data
##      Compound Concentration Replicate Heart_Rate
## 1  Metoprolol             0         1      345.3
## 2  Metoprolol             0         2      346.3
## 3  Metoprolol             0         3      351.7
## 4  Metoprolol             1         1      112.2
## 5  Metoprolol             1         2      112.4
## 6  Metoprolol             1         3      117.1
## 7  Metoprolol             2         1      130.4
## 8  Metoprolol             2         2      125.2
## 9  Metoprolol             2         3      126.9
## 10 Metoprolol             3         1       82.7
## 11 Metoprolol             3         2       87.7
## 12 Metoprolol             3         3       85.1
## 13 Metoprolol             4         1       77.2
## 14 Metoprolol             4         2       76.3
## 15 Metoprolol             4         3       74.3
## 16 Metoprolol             5         1      105.4
## 17 Metoprolol             5         2      101.5
## 18 Metoprolol             5         3       94.1

Gebruik de ‘janitor’ functie

data_clean <- sim_data |>
  janitor::clean_names() ## remove capitals etc.

Voor

names(sim_data)
## [1] "Compound"      "Concentration" "Replicate"     "Heart_Rate"

Na

names(data_clean)
## [1] "compound"      "concentration" "replicate"     "heart_rate"

Analyseer de data

sim_data |>
  skimr::skim()
Data summary
Name sim_data
Number of rows 18
Number of columns 4
_______________________
Column type frequency:
character 1
numeric 3
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Compound 0 1 10 10 0 1 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Concentration 0 1 2.50 1.76 0.0 1.00 2.5 4.00 5.0 ▇▃▃▃▃
Replicate 0 1 2.00 0.84 1.0 1.00 2.0 3.00 3.0 ▇▁▇▁▇
Heart_Rate 0 1 141.77 96.45 74.3 85.75 108.8 126.48 351.7 ▇▁▁▁▂

Maak een scatterplot om de trend in de data waar te nemen

scatterplot_metoprolol <- data_clean |>
  ggplot(aes(
    x = concentration,
    y = heart_rate
  )) + 
  geom_point(aes(colour = compound), position = "jitter") +
  theme_bw() +
  labs(
    title = "Scatterplot hartslag per minuut tegen metoprolol concentratie",
    x = "Hartslag per minuut",
    y = "Concentratie metoprolol (mg/ml)"
  )

scatterplot_metoprolol

Figuur 1: scatterplot data.

Maken dose-response curve

Geef een dosis-response model vorm

model_metoprolol <- drm(
  heart_rate ~ concentration,
  data = data_clean,
  fct = LL.4()
)

Ontwerp een vloeiende lijn voor de curve

newdata <- data.frame(
  concentration = seq(0, 5, length.out = 100)
)

Bereken voorspelde hartslagwaarden o.b.v. het model

predictions <- tibble(
  concentration = newdata$concentration,
  heart_rate = predict(model_metoprolol, newdata = newdata)
  )

predictions
## # A tibble: 100 × 2
##    concentration heart_rate
##            <dbl>      <dbl>
##  1        0            348.
##  2        0.0505       181.
##  3        0.101        167.
##  4        0.152        159.
##  5        0.202        153.
##  6        0.253        149.
##  7        0.303        145.
##  8        0.354        142.
##  9        0.404        139.
## 10        0.455        136.
## # ℹ 90 more rows

Resultaten

Plot de dosis-response curve

dosis_response_curve <- ggplot() +
  geom_point(
    data = data_clean,
    aes(x = concentration, y = heart_rate),
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_line(
    data = predictions,
    aes(x = concentration, y = heart_rate),
    linewidth = 1
  ) +
  theme_bw() +
  labs(
    title = "Dosis-response curve voor Metoprol",
    x = "Concentratie Metoprolol (mg/mL)",
    y = "Hartslag per minuut",
  )

dosis_response_curve

Figuur 2: dosis-response curve Metoprolol. Curve heeft een L-vorm. Sterke daling bij 1 mg/ml metoprolol, gevolgd door een afvlakking.

Conclusie

Het metoprolol gaat bij lage concentraties al sterk in effect. Bij het bepalen van het maximumeffect was dit echter alleen van toepassing bij hogere concentraties. Het metoprolol werkt dus wel, maar werkt niet consistent wanneer ze over dagdelen worden vergeleken. Bij 5 mg/ml Metoprolol trad een bijwerking op: de hartslag was erg inconsistent waardoor het van snel naar langzaam versprong binnen een korte tijd.