Skip to content

Parameter formulas on website#520

Open
Gero1999 wants to merge 26 commits intohumanpred:mainfrom
Gero1999:507-parameters-formulas-website
Open

Parameter formulas on website#520
Gero1999 wants to merge 26 commits intohumanpred:mainfrom
Gero1999:507-parameters-formulas-website

Conversation

@Gero1999
Copy link
Copy Markdown
Contributor

@Gero1999 Gero1999 commented Mar 19, 2026

Closes #507

I needed to think a bit out of the box for this one and implement something semi-automatized.

  • add.interval.col will optionally accept a formula arg in LaTeX
  • the script data_raw/write_parameters-available_md.R generates the website with the table
  • when the site is build the table is included as an article "Parameters Available"

let me know what you think. Also, you have more knowledge so it would be nice if you can do a quick review of the formulas I populated. Although I guess that they can always keep being corrected.

Feel also free to commit/push changes if easier

- R/auciv.R, R/aucint.R, R/sparse.R had no real conflict, just adding content with new line
- R/pk.calc.urine.R (4 conflicts): Kept HEAD's version which had expanded depends = c("ae", "auclast") (adding the AUC dependency) plus formula=. The PKNCA.set.summary() blocks were outside the conflict markers (shared context).
- R/pk.calc.simple.R (26 conflicts): Kept both — the formula= argument from the branch AND the PKNCA.set.summary() blocks from main

Merge remote-tracking branch 'origin/main' into 507-parameters-formulas-website

# Conflicts:
#	R/aucint.R
#	R/auciv.R
#	R/pk.calc.simple.R
#	R/pk.calc.urine.R
#	R/sparse.R
- removed summary definitions
- typpo aumc_integrate instead of auc_integrate
test-001-add.interval.col.R — Added formula=NULL to 3 expected list comparisons. The add.interval.col() function now stores a formula field (10 elements), but the tests expected only 9.

test-pk.calc.all.R — Added 8 sparse-dependent parameters to the exclusion list (sparse_aumclast, sparse_aumc_se, sparse_aumc_df, cl.sparse.last, mrt.sparse.last, vz.sparse.last, vss.sparse.last, kel.sparse.last). These parameters require sparse data which the test doesn't provide — same reason the existing sparse_auclast/sparse_auc_se/sparse_auc_df were already excluded.
@Gero1999 Gero1999 marked this pull request as ready for review March 20, 2026 16:29
Copy link
Copy Markdown
Member

@billdenney billdenney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this work!

This remains a bit complicated. Some of the formula are not easily represented as simple equations.

R/auc.R Outdated
pretty_name="AUClast",
desc="The area under the concentration time curve from the beginning of the interval to the last concentration above the limit of quantification")
desc="The area under the concentration time curve from the beginning of the interval to the last concentration above the limit of quantification",
formula="$AUC_{\\text{last}} = \\int_{0}^{T_{\\text{last}}} C(t) dt$")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integral formulae are technically accurate, but they are not how the formula are actually calculated. The actual calculation is more complex as it depends on the integration method. It's hard to show this (and all AUC calculations) in a single formula as they are more easily described with algorithms. (This will probably take more thought.)

desc="Correlation between time and log-concentration for lambda.z points",
depends="half.life")
depends="half.life",
formula="$\\text{cor}(t, \\log C)$")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, this would have an indicator that it is evaluated from lambda.z time first to lambda.z time last.

R/half.life.R Outdated
desc="The first time point used for the calculation of half-life",
depends="half.life")
depends="half.life",
formula="$t_{\\text{first}}$")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like it needs a formula or if it does have one, perhaps something like:

$\lambda_z t_{first} = \min\left({time}_{\lambda_z}\right)$

R/half.life.R Outdated
desc="The last time point used for the calculation of half-life",
depends="half.life")
depends="half.life",
formula="$t_{\\text{last}}$")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

$\lambda_z t_{last} = \max\left({time}_{\lambda_z}\right)$

R/half.life.R Outdated
desc="The concentration at Tlast as predicted by the half-life",
depends="half.life")
depends="half.life",
formula="$C_{\\text{last,pred}} = e^{a + b t_{\\text{last}}}$")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit complicated because what is a (for clarity, I know what you mean, but it doesn't have a defined PK parameter)? b should be -\lambda_z.

R/sparse.R Outdated
pretty_name="Sparse AUClast",
desc="For sparse PK sampling, the area under the concentration time curve from the beginning of the interval to the last concentration above the limit of quantification"
desc="For sparse PK sampling, the area under the concentration time curve from the beginning of the interval to the last concentration above the limit of quantification",
formula="$AUC_{\\text{sparse}} = \\sum_k \\frac{\\bar{C}_k + \\bar{C}_{k+1}}{2} \\Delta t_k$"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more like the AUC calculation formula, but for non-sparse AUC, it has a different formula for log-down (or generally log-scale sub-intervals). Something to consider for how to best represent it elsewhere.

R/sparse.R Outdated
desc="For sparse PK sampling, the standard error degrees of freedom of the area under the concentration time curve from the beginning of the interval to the last concentration above the limit of quantification",
depends="sparse_auclast"
depends="sparse_auclast",
formula="$df(AUC_{\\text{sparse}})$"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is accurate but not informative.

R/time.above.R Outdated
pretty_name="Time above Concentration",
desc="Time above a given concentration")
desc="Time above a given concentration",
formula="$T_{\\text{above}} = \\sum \\Delta t_{i: C_i > C_{\\text{ref}}}$")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't account for the fact that PKNCA interpolates the starting and ending times and accounts for times when it may go up and down.

@Gero1999 Gero1999 closed this Mar 24, 2026
@Gero1999 Gero1999 reopened this Mar 24, 2026
@Gero1999 Gero1999 requested a review from billdenney March 25, 2026 08:43
@Gero1999
Copy link
Copy Markdown
Contributor Author

Tried to address your comments the best I could! I also added a new column formula_note to point out small things regarding calculations. Feel free to make modifications where needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation request: Formulas on the website

2 participants