Skip to content

Commit 5dac893

Browse files
mhovdSielmnneely
authored
paper: Prepare for submission to JOSS (#186)
--------- Co-authored-by: Julián D. Otálvaro <juliandavid347@gmail.com> Co-authored-by: Michael Neely <mneely@usc.edu>
1 parent 5603811 commit 5dac893

File tree

20 files changed

+702
-1064
lines changed

20 files changed

+702
-1064
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/workflows/render.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Draft PDF
2+
on:
3+
push:
4+
branches:
5+
- joss
6+
7+
jobs:
8+
paper:
9+
runs-on: ubuntu-latest
10+
name: Paper Draft
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
- name: Build draft PDF
15+
uses: openjournals/openjournals-draft-action@master
16+
with:
17+
journal: joss
18+
paper-path: joss/paper.md
19+
- name: Upload
20+
uses: actions/upload-artifact@v4
21+
with:
22+
name: paper
23+
path: paper.pdf

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ cargo.lock
33
Cargo.lock
44
/.vscode
55
/.idea
6-
*.pkm
6+
*.pkm
7+
/paper_files
8+
paper.html

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ harness = false
4848
[[bench]]
4949
name = "ode"
5050
harness = false
51+
52+
[[bench]]
53+
name = "analytical_vs_ode"
54+
harness = false

README.md

Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,91 +4,90 @@
44
[![Documentation](https://github.com/LAPKB/pharmsol/actions/workflows/docs.yml/badge.svg)](https://github.com/LAPKB/pharmsol/actions/workflows/docs.yml)
55
[![crates.io](https://img.shields.io/crates/v/pharmsol.svg)](https://crates.io/crates/pharmsol)
66

7-
Simulate PK/PD profiles using ordinary and stochastic differential equations, or analytical models.
7+
A high-performance Rust library for pharmacokinetic/pharmacodynamic (PK/PD) simulation using analytical solutions, ordinary differential equations (ODEs), or stochastic differential equations (SDEs).
88

9-
## Example
9+
## Installation
1010

11-
ODE based model.
11+
Add `pharmsol` to your `Cargo.toml`, either manually or using
1212

13-
```rust
14-
use pharmsol::*;
15-
16-
// Subject data can be generated using the builder pattern
17-
let subject = Subject::builder("id1")
18-
.bolus(0.0, 100.0, 0)
19-
.repeat(2, 0.5)
20-
.observation(0.5, 0.1, 0)
21-
.observation(1.0, 0.4, 0)
22-
.observation(2.0, 1.0, 0)
23-
.observation(2.5, 1.1, 0)
24-
.covariate("wt", 0.0, 80.0)
25-
.covariate("wt", 1.0, 83.0)
26-
.covariate("age", 0.0, 25.0)
27-
.build();
28-
29-
let ode = equation::ODE::new(
30-
|x, p, t, dx, _rateiv, cov| {
31-
// The following are helper functions to fetch parameters and covariates
32-
fetch_cov!(cov, t, _wt, _age);
33-
fetch_params!(p, ka, ke, _tlag, _v);
34-
35-
// The ODEs are defined here
36-
dx[0] = -ka * x[0];
37-
dx[1] = ka * x[0] - ke * x[1];
38-
},
39-
|p| {
40-
fetch_params!(p, _ka, _ke, tlag, _v);
41-
lag! {0=>tlag}
42-
},
43-
|_p, _t, _cov| fa! {},
44-
|_p, _t, _cov, _x| {},
45-
|x, p, _t, _cov, y| {
46-
fetch_params!(p, _ka, _ke, _tlag, v);
47-
// This equation specifies the output, e.g. the measured concentrations
48-
y[0] = x[1] / v;
49-
},
50-
(2, 1),
51-
);
52-
53-
let op = ode.estimate_predictions(&subject, &vec![0.3, 0.5, 0.1, 70.0]);
54-
// println!("{op:#?}");
55-
let _ = op.run();
13+
```bash
14+
cargo add pharmsol
5615
```
5716

58-
Analytic based model.
17+
## Quick Start
5918

6019
```rust
6120
use pharmsol::*;
21+
22+
// Create a subject with an IV infusion and observations
23+
let subject = Subject::builder("patient_001")
24+
.infusion(0.0, 500.0, 0, 0.5) // 500 units over 0.5 hours
25+
.observation(0.5, 1.645, 0)
26+
.observation(1.0, 1.216, 0)
27+
.observation(2.0, 0.462, 0)
28+
.observation(4.0, 0.063, 0)
29+
.build();
30+
31+
// Define parameters: ke (elimination rate), v (volume)
32+
let ke = 1.022;
33+
let v = 194.0;
34+
35+
// Use the built-in one-compartment analytical solution
6236
let analytical = equation::Analytical::new(
63-
one_compartment_with_absorption,
64-
|_p, _cov| {},
65-
|p| {
66-
fetch_params!(p, _ka, _ke, tlag, _v);
67-
lag! {0=>tlag}
68-
},
37+
one_compartment,
38+
|_p, _t, _cov| {},
39+
|_p, _t, _cov| lag! {},
6940
|_p, _t, _cov| fa! {},
7041
|_p, _t, _cov, _x| {},
7142
|x, p, _t, _cov, y| {
72-
fetch_params!(p, _ka, _ke, _tlag, v);
73-
y[0] = x[1] / v;
43+
fetch_params!(p, _ke, v);
44+
y[0] = x[0] / v; // Concentration = Amount / Volume
7445
},
75-
(2, 1),
46+
(1, 1), // (compartments, outputs)
7647
);
77-
let op = analytical.simulate_subject(&subject, &vec![0.3, 0.5, 0.1, 70.0]);
78-
println!("{op:#?}");
48+
49+
// Get predictions
50+
let predictions = analytical.estimate_predictions(&subject, &vec![ke, v]).unwrap();
7951
```
8052

81-
## Supported analytical models
53+
## ODE-Based Models
54+
55+
For custom or complex models, define your own ODEs:
56+
57+
```rust
58+
use pharmsol::*;
59+
60+
let ode = equation::ODE::new(
61+
|x, p, _t, dx, _b, rateiv, _cov| {
62+
fetch_params!(p, ke, _v);
63+
// One-compartment model with IV infusion support
64+
dx[0] = -ke * x[0] + rateiv[0];
65+
},
66+
|_p, _t, _cov| lag! {},
67+
|_p, _t, _cov| fa! {},
68+
|_p, _t, _cov, _x| {},
69+
|x, p, _t, _cov, y| {
70+
fetch_params!(p, _ke, v);
71+
y[0] = x[0] / v;
72+
},
73+
(1, 1),
74+
);
75+
```
8276

83-
We are working to support all the standard analytical models.
77+
## Supported Analytical Models
8478

8579
- [x] One-compartment with IV infusion
8680
- [x] One-compartment with IV infusion and oral absorption
8781
- [x] Two-compartment with IV infusion
8882
- [x] Two-compartment with IV infusion and oral absorption
89-
- [ ] Three-compartmental models
83+
- [x] Three-compartment with IV infusion
84+
- [x] Three-compartment with IV infusion and oral absorption
85+
86+
## Performance
87+
88+
Analytical solutions provide 20-33× speedups compared to equivalent ODE formulations. See [benchmarks](benches/) for details.
9089

91-
# Links
90+
## Documentation
9291

93-
[Documentation](https://lapkb.github.io/pharmsol/pharmsol/)
94-
[Benchmarks](https://lapkb.github.io/pharmsol/dev/bench/)
92+
- [API Documentation](https://lapkb.github.io/pharmsol/pharmsol/)
93+
- [Examples](examples/)

0 commit comments

Comments
 (0)