diff --git a/articles/biokinetics.html b/articles/biokinetics.html index d9c719a..cc3f4d5 100644 --- a/articles/biokinetics.html +++ b/articles/biokinetics.html @@ -105,7 +105,9 @@
dat <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
-mod <- epikinetics::biokinetics$new(data = dat, covariate_formula = ~0 + infection_history)
+mod <- epikinetics::biokinetics$new(data = dat,
+ lower_censoring_limit = 40,
+ covariate_formula = ~0 + infection_history)
delta <- mod$fit(parallel_chains = 4,
iter_warmup = 50,
iter_sampling = 200,
@@ -120,26 +122,18 @@ Figure 2
res <- mod$simulate_population_trajectories()
-#> INFO [2024-11-15 12:08:43] Summarising fits
-#> INFO [2024-11-15 12:08:47] Adjusting by regression coefficients
-#> INFO [2024-11-15 12:08:49] Summarising into quantiles
+#> INFO [2024-11-19 13:53:20] Summarising fits
+#> INFO [2024-11-19 13:53:24] Adjusting by regression coefficients
+#> INFO [2024-11-19 13:53:26] Summarising into quantiles
head(res)
-#> time_since_last_exp me lo hi titre_type
-#> <int> <num> <num> <num> <char>
-#> 1: 0 85.03283 61.79873 113.4266 Ancestral
-#> 2: 1 117.52245 87.99594 151.6198 Ancestral
-#> 3: 2 161.60170 124.69805 203.8376 Ancestral
-#> 4: 3 221.98993 173.94588 277.0610 Ancestral
-#> 5: 4 302.97036 238.14148 381.2043 Ancestral
-#> 6: 5 417.55537 325.74862 544.8846 Ancestral
-#> infection_history
-#> <char>
-#> 1: Infection naive
-#> 2: Infection naive
-#> 3: Infection naive
-#> 4: Infection naive
-#> 5: Infection naive
-#> 6: Infection naive
+#> time_since_last_exp me lo hi titre_type infection_history
+#> <int> <num> <num> <num> <char> <char>
+#> 1: 0 112.6822 84.4386 143.8971 Ancestral Infection naive
+#> 2: 1 142.5849 110.8551 176.8130 Ancestral Infection naive
+#> 3: 2 180.8341 145.1370 219.0680 Ancestral Infection naive
+#> 4: 3 228.8394 188.6540 274.4430 Ancestral Infection naive
+#> 5: 4 290.0701 242.2203 346.9681 Ancestral Infection naive
+#> 6: 5 367.5040 308.0682 451.2246 Ancestral Infection naive
See data for the definition of the returned columns.
Using ggplot2
:
res <- mod$population_stationary_points(n_draws = 2000)
-#> INFO [2024-11-15 12:08:50] Extracting parameters
-#> INFO [2024-11-15 12:08:51] Adjusting by covariates
-#> INFO [2024-11-15 12:08:51] Calculating peak and switch titre values
-#> INFO [2024-11-15 12:08:51] Recovering covariate names
-#> INFO [2024-11-15 12:08:51] Calculating medians
+#> INFO [2024-11-19 13:53:27] Extracting parameters
+#> INFO [2024-11-19 13:53:27] Adjusting by covariates
+#> INFO [2024-11-19 13:53:27] Calculating peak and switch titre values
+#> INFO [2024-11-19 13:53:28] Recovering covariate names
+#> INFO [2024-11-19 13:53:28] Calculating medians
head(res)
-#> infection_history titre_type mu_p mu_s rel_drop_me mu_p_me mu_s_me
-#> <char> <char> <num> <num> <num> <num> <num>
-#> 1: Infection naive Ancestral 1343.598 246.5053 0.1734832 1315.809 228.7876
-#> 2: Infection naive Ancestral 1218.834 253.4858 0.1734832 1315.809 228.7876
-#> 3: Infection naive Ancestral 1236.706 242.7546 0.1734832 1315.809 228.7876
-#> 4: Infection naive Ancestral 1241.937 218.3664 0.1734832 1315.809 228.7876
-#> 5: Infection naive Ancestral 1339.590 205.4437 0.1734832 1315.809 228.7876
-#> 6: Infection naive Ancestral 1602.548 232.3682 0.1734832 1315.809 228.7876
The values we’re going to plot are the mean peak titre values
(mu_p
) and mean set point titre values (mu_s
),
for different titre types and infection histories. See data for a full definition of all the returned
@@ -271,24 +263,24 @@
res <- mod$simulate_individual_trajectories(n_draws = 250)
-#> INFO [2024-11-15 12:08:52] Extracting parameters
-#> INFO [2024-11-15 12:08:56] Simulating individual trajectories
-#> INFO [2024-11-15 12:09:00] Recovering covariate names
-#> INFO [2024-11-15 12:09:00] Calculating exposure days. Adjusting exposures by 0 days
-#> INFO [2024-11-15 12:09:03] Resampling
+#> INFO [2024-11-19 13:53:29] Extracting parameters
+#> INFO [2024-11-19 13:53:32] Simulating individual trajectories
+#> INFO [2024-11-19 13:53:36] Recovering covariate names
+#> INFO [2024-11-19 13:53:37] Calculating exposure days. Adjusting exposures by 0 days
+#> INFO [2024-11-19 13:53:40] Resampling
#> Registered S3 method overwritten by 'mosaic':
#> method from
#> fortify.SpatialPolygonsDataFrame ggplot2
-#> INFO [2024-11-15 12:09:14] Summarising into population quantiles
+#> INFO [2024-11-19 13:53:50] Summarising into population quantiles
head(res)
#> calendar_day titre_type me lo hi time_shift
#> <IDat> <char> <num> <num> <num> <num>
-#> 1: 2021-03-08 Ancestral 1122.561 899.7913 1474.929 0
-#> 2: 2021-03-09 Ancestral 1114.609 882.1468 1450.662 0
-#> 3: 2021-03-10 Ancestral 1150.423 911.1426 1530.973 0
-#> 4: 2021-03-11 Ancestral 1121.402 878.6975 1447.972 0
-#> 5: 2021-03-12 Ancestral 1115.039 851.9412 1443.723 0
-#> 6: 2021-03-13 Ancestral 1150.059 900.9269 1520.740 0
See data for a definition of all the returned columns. Figure 5 A plots the derived population trajectories. Here we replicate a portion of the graph from the paper, from the minimum date @@ -358,72 +350,72 @@
Plotting the median values:
diff --git a/articles/biokinetics_files/figure-html/unnamed-chunk-10-1.png b/articles/biokinetics_files/figure-html/unnamed-chunk-10-1.png index ffe6d53..dddfd67 100644 Binary files a/articles/biokinetics_files/figure-html/unnamed-chunk-10-1.png and b/articles/biokinetics_files/figure-html/unnamed-chunk-10-1.png differ diff --git a/articles/biokinetics_files/figure-html/unnamed-chunk-4-1.png b/articles/biokinetics_files/figure-html/unnamed-chunk-4-1.png index 4a19ef5..4842f38 100644 Binary files a/articles/biokinetics_files/figure-html/unnamed-chunk-4-1.png and b/articles/biokinetics_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/articles/biokinetics_files/figure-html/unnamed-chunk-6-1.png b/articles/biokinetics_files/figure-html/unnamed-chunk-6-1.png index 6291ace..dee4fd7 100644 Binary files a/articles/biokinetics_files/figure-html/unnamed-chunk-6-1.png and b/articles/biokinetics_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/articles/biokinetics_files/figure-html/unnamed-chunk-8-1.png b/articles/biokinetics_files/figure-html/unnamed-chunk-8-1.png index 8edee61..d9b2f22 100644 Binary files a/articles/biokinetics_files/figure-html/unnamed-chunk-8-1.png and b/articles/biokinetics_files/figure-html/unnamed-chunk-8-1.png differ diff --git a/articles/data.html b/articles/data.html index dc54022..cf9e58e 100644 --- a/articles/data.html +++ b/articles/data.html @@ -95,55 +95,41 @@
dat <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
head(dat)
-#> pid day last_exp_day titre_type value censored infection_history
-#> <int> <IDat> <IDat> <char> <num> <int> <char>
-#> 1: 1 2021-03-10 2021-03-08 Ancestral 175.9350 0 Infection naive
-#> 2: 1 2021-04-15 2021-03-08 Ancestral 607.5750 0 Infection naive
-#> 3: 1 2021-07-08 2021-03-08 Ancestral 179.0463 0 Infection naive
-#> 4: 1 2021-03-10 2021-03-08 Alpha 5.0000 -1 Infection naive
-#> 5: 1 2021-04-15 2021-03-08 Alpha 416.7905 0 Infection naive
-#> 6: 1 2021-07-08 2021-03-08 Alpha 103.5274 0 Infection naive
+#> pid day last_exp_day titre_type value infection_history
+#> <int> <IDat> <IDat> <char> <num> <char>
+#> 1: 1 2021-03-10 2021-03-08 Ancestral 175.9350 Infection naive
+#> 2: 1 2021-04-15 2021-03-08 Ancestral 607.5750 Infection naive
+#> 3: 1 2021-07-08 2021-03-08 Ancestral 179.0463 Infection naive
+#> 4: 1 2021-03-10 2021-03-08 Alpha 5.0000 Infection naive
+#> 5: 1 2021-04-15 2021-03-08 Alpha 416.7905 Infection naive
+#> 6: 1 2021-07-08 2021-03-08 Alpha 103.5274 Infection naive
#> last_vax_type exp_num
#> <char> <int>
#> 1: BNT162b2 2
@@ -185,7 +171,7 @@ Example
After fitting a model, a CmdStanMCMC object is returned. This means that users who are already familiar with diff --git a/pkgdown.yml b/pkgdown.yml index e2ec282..42078ed 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -5,4 +5,4 @@ articles: biokinetics: biokinetics.html data: data.html model: model.html -last_built: 2024-11-15T12:04Z +last_built: 2024-11-19T13:48Z diff --git a/reference/biokinetics.html b/reference/biokinetics.html index 456b7c4..ef689b7 100644 --- a/reference/biokinetics.html +++ b/reference/biokinetics.html @@ -89,7 +89,11 @@
plot_model_inputs()
Plot model input data with a smoothing function. Note that -this plot is on a log scale, regardless of whether data was provided on a -log or a natural scale.
...
Named arguments to the sample()
method of CmdStan model.
objects: https://mc-stan.org/cmdstanr/reference/model-method-sample.html
summarise
Boolean. If TRUE, average the individual trajectories to get lo, me and hi values for the population, disaggregated by titre type. If FALSE return the indidivudal trajectories. diff --git a/reference/convert_log2_scale.html b/reference/convert_log2_scale.html new file mode 100644 index 0000000..c1277df --- /dev/null +++ b/reference/convert_log2_scale.html @@ -0,0 +1,113 @@ + +
convert_log2_scale.Rd
Natural scale data is converted to a base 2 log scale before model fitting. +This function does not modify the provided data.table in-place, but returns a transformed copy.
+convert_log2_scale(dt_in, smallest_value, vars_to_transform = "value")
A data.table, identical to the input data but with specified columns transformed.
+convert_log2_scale_inverse(dt_in, vars_to_transform)
convert_log2_scale_inverse(dt_in, vars_to_transform, smallest_value)
Names of columns to apply the transformation to.
The lowest value in the original dataset.
biokinetics_priors()
Construct priors for the biomarker model.
Base 2 log scale conversion
plot(<biokinetics_priors>)
Simulate biomarker kinetics predicted by the given biokinetics priors and optionally compare to a dataset.
Plot serological data
Optional data.frame with columns time_since_last_exp and value. The raw data to compare to.
Optional upper detection limit.
Optional lower detection limit.
plot_sero_data.Rd
Plot serological data in the format provided to the biokinetics +model, with a smoothing function fitted.
+plot_sero_data(
+ data,
+ tmax = 150,
+ covariates = character(0),
+ upper_censoring_limit = NULL,
+ lower_censoring_limit = NULL
+)
A data.table with required columns time_since_last_exp, value and titre_type.
Integer. The number of time points in each simulated trajectory. Default 150.
Optional vector of covariate names to facet by (these must correspond to columns in the data.table)
Optional upper detection limit.
Optional lower detection limit.
A ggplot2 object.
+