# Non-compartment analysis

See MetidaNCA.jl. MetidaNCA.jl will replace CTU in plans.

NCA analysis based on following steps:

2. Constructing subjects list with pkimport/pdimport;
3. Run NCA;
4. Exporting to DataFrame;
5. Descriptive statistics / HTML export.

### Description

include("ncatable.jl")

#### AUC

$$$AUC = \sum_{n=1}^N AUC_{n}$$$

Where AUCn - partial AUC.

Linear trapezoidal rule

$$$AUC\mid_{t_1}^{t_2} = \delta t \times \frac{C_1 + C_2}{2} AUMC\mid_{t_1}^{t_2} = \delta t \times \frac{t_1 \times C_1 + t_2 \times C_2}{2}$$$

Logarithmic trapezoidal rule

$$$AUC\mid_{t_1}^{t_2} = \delta t \times \frac{ C_2 - C_1}{ln(C_2/C_1)} AUMC\mid_{t_1}^{t_2} = \delta t \times \frac{t_2 \times C_2 - t_1 \times C_1}{ln(C_2/C_1)} - \delta t^2 \times \frac{ C_2 - C_1}{ln(C_2/C_1)^2}$$$

Linear interpolation rule

$$$C_x = C_1 + \frac{(t_x-t_1)\times(C_2 - C_1)}{t_2 - t_1}$$$

Logarithmic interpolation rule

$$$C_x = exp\left(ln(C_1) + \frac{(t_x-t_1)\times(ln(C_2) - ln(C_1))}{t_2 - t_1}\right)$$$

#### MRTlast

$$$MRTlast = AUMClast / AUClast$$$

#### HL

$$$HL = ln(2) / \lambda_z$$$

#### AUCinf

$$$AUCinf = AUClast + \frac{Clast}{\lambda_z}$$$

#### AUMCinf

$$$AUMCinf = AUMClast + \frac{tlast\times Clast}{\lambda_z} + \frac{Clast}{\lambda_z^2}$$$

#### AUCpct

$$$AUCpct = (AUCinf - AUClast) / AUCinf * 100.0%$$$

#### Accumulation index

$$$Accind = \frac{1}{1 - exp(-\lambda_z \tau)}$$$

### nca!

ClinicalTrialUtilities.nca!Function
nca!(data::PKSubject; adm = :ev, calcm = :lint, intp = :lint,
verbose = false, warn = true, io::IO = stdout)

Pharmacokinetics non-compartment analysis for one PK subject.

adm - administration:

• :ev - extravascular;
• :iv - intra vascular bolus;

calcm - calculation method;

• :lint - Linear trapezoidal everywhere;
• :logt - Log-trapezoidat rule after Tmax if c₁ > 0 and c₂ > 0, else Linear trapezoidal used;
• :luld - Linear Up - Log Down everywhere if c₁ > c₂ > 0, else Linear trapezoidal used;
• :luldt - Linear Up - Log Down after Tmax if c₁ > c₂ > 0, else Linear trapezoidal used;

intp - interpolation rule;

• :lint - linear interpolation;

verbose - print to out stream if "true";

• true;
• false.

warn - warnings enabled;

io - out stream (stdout by default).

nca!(data::DataSet{PKSubject}; adm = :ev, calcm = :lint, intp = :lint,
verbose = false, warn = true, io::IO = stdout, sort = nothing)
• sort - only for this type of subjects.

Pharmacokinetics non-compartment analysis for PK subjects DataSet.

nca!(data::PDSubject; verbose = false, io::IO = stdout)::PKPDProfile{PDSubject}

Pharmacodynamics non-compartment analysis for one PD subject.

nca!(data::PDSubject; verbose = false, io::IO = stdout)::PKPDProfile{PDSubject}

Pharmacodynamics non-compartment analysis for PD subjects set.

nca!(data::UPKSubject; verbose = false, io::IO = stdout)::PKPDProfile{UPKSubject}

Pharmacodynamics non-compartment analysis for urine data.

nca!(data::DataSet{UPKSubject}; verbose = false, io::IO = stdout)

Pharmacodynamics non-compartment analysis for PD subjects set.

### Scenario

using CSV, DataFrames, ClinicalTrialUtilities
pkdata2 = CSV.File("pkdata.csv") |> DataFrame

2 Subject list

  pkds = pkimport(pkdata2, [:Subject, :Formulation]; time = :Time, conc = :Concentration)

3 NCA analysis with default settings

  pk   = nca!(pkds)

4 Exporting

  ncadf   = DataFrame(pk; unst = true)

5 Descriptive statistics

  ds   = ClinicalTrialUtilities.descriptive(ncadf, stats = [:n, :mean, :sd], sort = [:Formulation])

6 Exporting

  dsdf   = ClinicalTrialUtilities.DataFrame(ds; unst = true)