API

Main

nca!

MetidaNCA.nca!Function
nca!(data::DataSet{Subj}; adm = :ev, calcm = :lint, intpm = nothing, verbose = 0, warn = true, io::IO = stdout, modify! = identity) where Subj <: AbstractSubject

Non-compartmental (NCA) analysis of PK/PD data.

source
nca!(data::PKSubject{T,O}; adm = :ev, calcm = :lint, intpm = nothing,  partials = nothing, prtext = :err, verbose = 0, warn = true, io::IO = stdout, modify! = nothing) where T where O
  • adm - administration:
    • :ev - extra vascular;
    • :iv - intravascular bolus;
  • calcm - AUC/AUMC calculation method:
    • :lint - linear trapezoidal;
    • :luld - linear up log down;
    • :luldt - linear up log down after Tmax;
    • :logt - log-trapezoidal after Tmax (Not Recommended);
  • intpm - interpolation method:
    • :lint - linear trapezoidal;
    • :luld - linear up log down;
    • :luldt - linear up log down after Tmax;
    • :logt - log-trapezoidal after Tmax;
  • partials - calculate partial AUC vor vector of time intervals (:err (default) - throw error if end time > last oservation time; :last - no extrapolation; :extr - if Kel calculated used extrapolation or NaN if no Kel);
  • prtext - extrapolation rule for partials AUC;
  • verbose - print to io, 1: partial areas table, 2: 1, and results;
  • warn - show warnings;
  • io - output stream;
  • modify! - function to modify output paramaters, call modify!(data, result) if difined.

Results:

  • Cmax
  • Tmax
  • Cdose
  • Tlag
  • Clast
  • AUClast
  • AUMClast
  • AUCall
  • Rsq
  • ARsq
  • Kel
  • HL
  • LZint
  • NpLZ
  • Clast_pred
  • AUCinf
  • AUCinf_pred
  • AUMCinf
  • AUMCinf_pred
  • AUCpct
  • MRTlast
  • MRTinf
  • MRTinf_pred
  • Cllast
  • Clinf
  • Vzlast
  • Vzinf
  • Vssinf

Steady-state parameters (tau used):

  • AUCtau
  • AUMCtau
  • Ctau
  • Cavg
  • Ctaumin
  • Accind
  • Fluc
  • Fluctau
  • Swing
  • Swingtau
  • MRTtauinf
  • Cltau
  • Vztau

partials is a vector of vectors, tuples or pairs. Example: partials = [(1,2), (3,4)], partials = [[1,2], (3,4)]

source
nca!(data::UPKSubject{T, O, VOL, V}; adm = :ev, calcm = :lint, intpm = nothing, verbose = 0, warn = true, io::IO = stdout, modify! = identity) where T where O where VOL where V

Non-compartmental (NCA) analysis of pharmacokinetic for urine data.

Results:

  • AUCall
  • AUClast
  • Rlast
  • Maxrate
  • Tmax
  • AR
  • Vol
  • Prec
  • ARsq
  • Rsq
  • Kel
  • LZ
  • LZint
  • Rsqn
  • HL
  • AUCinf
source
nca!(data::PDSubject{T,O}; calcm = :lint, intpm = nothing, verbose = 0, warn = true, io::IO = stdout, modify! = identity, kwargs...) where T where O

Non-compartmental (NCA) analysis of pharmacodynamic data.

Results:

  • Rmax - max responce;
  • Tmax - time for maximum responce;
  • AUCABL - AUC above baseline;
  • AUCBBL - AUC below baseline;
  • AUCATH - AUC above threshold;
  • AUCBTH - AUC below threshold;
  • AUCNETB - AUCABL - AUCBBL;
  • AUCNETT - AUCATH - AUCBTH;
  • TABL - time above baseline;
  • TBBL - time below baseline;
  • TATH - time above threshold;
  • TBTH - time below threshold;
  • AUCBTW - AUC between baseline and threshold;
source

nca

MetidaNCA.ncaFunction
nca(args...; kelauto = true,  elimrange = ElimRange(), dosetime = DoseTime(), kwargs...)

nca(data, time, conc, sort; kelauto = true,  elimrange = ElimRange(), dosetime = DoseTime(), kwargs...)

nca(data, time, conc; kelauto = true,  elimrange = ElimRange(), dosetime = DoseTime(), kwargs...)

nca(time, conc; kelauto = true,  elimrange = ElimRange(), dosetime = DoseTime(), kwargs...)

Import data and perform NCA analysis.

Syntax simillar to pkimport

Applicable kwargs see nca!.

source

pkimport

MetidaNCA.pkimportFunction
pkimport(data, time, conc, sort;
    kelauto = true,
    elimrange = ElimRange(),
    dosetime = DoseTime(),
    limitrule::Union{Nothing, LimitRule} = nothing,
    warn = true,
    kwargs...)

Import PK data from table data.

  • time - time column;
  • conc - concentration column;
  • sort - subject sorting columns.

keywords:

  • kelauto - if true auto range settings, if false used kelstart/kelend from elimrange;
  • elimrange - set elimination range settings;
  • dosetime - set dose and dose time, by default dosetime = 0, dose is NaN;
  • limitrule - apply limitrule to subject;
  • warn - false for warnings supress.
Note

If time column have non-unique values - last pair time-concentration will be used.

source
pkimport(data, time, conc;
    warn = true,
    kwargs...)

Import PK data from tabular data data, time - time column, conc - concentration column.

source
pkimport(time, conc;
    kelauto = true,
    elimrange = ElimRange(),
    dosetime = DoseTime(),
    id = Dict{Symbol, Any}(),
    limitrule::Union{Nothing, LimitRule} = nothing,
    warn = true,
    kwargs...)

Import PK data from time vector time and concentration vector conc.

source

upkimport

MetidaNCA.upkimportFunction
upkimport(data, stime, etime, conc, vol, sort; kelauto = true,  elimrange = ElimRange(), dosetime = DoseTime())

Import urine PK data from table data.

  • stime - start time column;
  • etime - end time column;
  • conc - concentration column;
  • vol - volume column;
  • sort - subject sorting columns.
source
upkimport(data, stime, etime, conc, vol; kelauto = true,  elimrange = ElimRange(), dosetime = DoseTime())

Import single urine PK data from table data.

  • stime - start time column;
  • etime - end time column;
  • conc - concentration column;
  • vol - volume column.
source
upkimport(stime, etime, conc, vol; kelauto = true,  elimrange = ElimRange(), dosetime = DoseTime())

Import urine PK data from time vectors:

  • stime - start times;
  • etime - end times;
  • conc - concentrations;
  • vol - volumes.
source

pdimport

MetidaNCA.pdimportFunction
pdimport(data, time, obs, sort;
    bl = 0,
    th = 0,
    limitrule::Union{Nothing, LimitRule} = nothing,
    warn = true)

Import pharmackodynamic data from table:

  • data - data table;
  • time - observation time;
  • obs - observation value;
  • sort - sorting columns.

Keywords:

  • bl - baseline;
  • th - threshold;
  • limitrule - limit rule;
  • warn - warning supress if false.
source
pdimport(data, time, obs;
    warn = true,
    kwargs...)

Import PD data from tabular data data, time - time column, obs - observations column.

source
pdimport(time, obs;
    bl = 0,
    th = 0,
    id = Dict{Symbol, Any}(),
    warn = true)

Import PD data from time vector time and observations vector obs.

source

Types

DoseTime

MetidaNCA.DoseTimeType
DoseTime(dose::D, time::T, tau::TAU) where D <: Number where T <: Number where TAU <: Number

Dose settings.

  • dose - dose;
  • time - dose time;
  • tau - tau (τ);

Dose time set 0 by default.

source

ElimRange

MetidaNCA.ElimRangeType
ElimRange(kelstart::Int, kelend::Int, kelexcl::Vector{Int})::ElimRange

Elimination settings for PK subject.

  • kelstart - start point;
  • kelend - end point;
  • kelexcl - excluded points.
source

LimitRule

MetidaNCA.LimitRuleType
LimitRule(lloq::T, btmax, atmax, nan, rm::Bool) where T <: Real

LimitRule(;lloq = NaN, btmax = NaN, atmax = NaN, nan = NaN, rm::Bool = false)
  • lloq - LLOQ - low limit of quantification;
  • btmax - value for points before Tmax;
  • atmat - values for points after Tmax;
  • nan - values for replacing NaN;
  • rm - if true, removee all NaN points.

Rule for PK subject.

  • STEP 1 (NaN step): replace all NaN and missing values with nan keyword value (if nan not NaN);
  • STEP 2 (LLOQ step): replace values below lloq with btmax value if this value befor Tmax or with atmax if this value after Tmax (if lloq not NaN);
  • STEP 3 (remove NaN): rm == true, then remove all NaN and missing values.
source

Functions

applylimitrule!

MetidaNCA.applylimitrule!Function
applylimitrule!(data::Union{PKSubject, PDSubject}, rule::LimitRule)

Apply rule to PK subject .

  • STEP 1 (NaN step): replace all NaN and missing values with nan keyword value (if nan not NaN);
  • STEP 2 (LLOQ step): replace values below lloq with btmax value if this value befor Tmax or with atmax if this value after Tmax (if lloq not NaN);
  • STEP 3 (remove NaN): rm == true, then remove all NaN and missing values.
source
applylimitrule!(f::Function, data::DataSet{T}, rule::LimitRule) where T <: Union{PKSubject, PDSubject}

Apply if f(subj) return true.

source
applylimitrule!(data::DataSet{T}, rule::LimitRule, ind::Int) where T <: Union{PKSubject, PDSubject}

Apply by ind.

source
applylimitrule!(data::DataSet{T}, rule::LimitRule, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}) where T <: Union{PKSubject, PDSubject}

Apply by inds.

source
applylimitrule!(data::DataSet{T}, rule::LimitRule) where T <: Union{PKSubject, PDSubject}

Apply to all dataset.

source
applylimitrule!(data::DataSet{T}, rule::LimitRule, sort::Dict) where T <: PKSubject
source
applylimitrule!(time, obs, rule::LimitRule)
source

getbl

getdosetime

getkelauto

getkelrange

getkeldata

getth

pkplot

MetidaNCA.pkplotFunction
pkplot(subj; ls = false, elim = false, xticksn = :auto, yticksn = :auto, kwargs...)

Plot for subject

  • ls - concentration in log scale;
  • elim - draw elimination curve;
  • xticksn - number of ticks on x axis;
  • yticksn - number of ticks on y axis;

Other keywords:

  • plotstyle - predefined plot style from PKPLOTSTYLE;
  • drawbl (false) - draw baseline, only for PDSubject;
  • drawth (false) - draw threshold, only for PDSubject;
source
pkplot(data::DataSet{T};
typesort::Union{Nothing, Symbol, AbstractVector{Symbol}} = nothing,
pagesort::Union{Nothing, Symbol, AbstractVector{Symbol}, NoPageSort} = nothing,
filter::Union{Nothing, Dict{Symbol}} = nothing,
uylims::Bool = false,
kwargs...) where T <: AbstractSubject

PK plot for subject set.

  • typesort - sort on page by this id key;
  • pagesort - different pages by this id key;
  • filter - use only subjects if filter ⊆ subject id;
  • uylims - same ylims for all dataset;
  • ldict - Dict with labels for replace.

Use pagesort = MetidaNCA.NoPageSort() to prevent page plotting.

source
pkplot(data::DataSet{T}; kwargs...) where T <: NCAResult
source
pkplot(data::NCAResult; kwargs...)
source

setbl!

MetidaNCA.setbl!Function
setbl!(data::T, bl) where T <: PDSubject

Set baseline for pd subject data.

source
setbl!(data::DataSet{T}, bl, ind::Int) where T <: PDSubject

Set baseline for subject ind in data.

source
setbl!(data::DataSet{T}, bl, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}})

Set baseline for all subjects in range or vector ind in data.

source
setbl!(data::DataSet{T}, bl) where T <: PDSubject

Set baseline for all subjects in data.

source
setbl!(data::DataSet{T}, bl, sort::Dict) where T <: PDSubject

Set baseline only for subjects which sortid is true.

source

setdosetime!

MetidaNCA.setdosetime!Function
setdosetime!(data::T, dosetime::DoseTime) where T <: PKSubject

Set dose time dosetime for subject data.

source
setdosetime!(data::DataSet{T}, dosetime::DoseTime, ind::Int) where T <: PKSubject
  • ind - index in DataSet.
source
setdosetime!(data::DataSet{T}, dosetime::DoseTime, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}) where T <: PKSubject
  • inds - indexes in DataSet.
source
setdosetime!(data::DataSet{T}, dosetime::DoseTime) where T <: PKSubject

For all subjects in DataSet.

source
setdosetime!(data::DataSet{T}, dosetime::DoseTime, sort::Dict) where T <: PKSubject

Set dose time dosetime for subjects if sort ⊆ subject's id.

source

setkelauto!

MetidaNCA.setkelauto!Function
setkelauto!(data::T, kelauto::Bool) where T <: PKSubject

Set range for elimination parameters calculation for subject.

  • data - PK subject;
  • kelauto - value.
source
setkelauto!(data::DataSet{T}, kelauto::Bool, ind::Int) where T <: PKSubject
source
setkelauto!(data::DataSet{T}, kelauto::Bool, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}) where T <: PKSubject
source
setkelauto!(data::DataSet{T}, kelauto::Bool) where T <: PKSubject
source
setkelauto!(data::DataSet{T}, kelauto::Bool, sort::Dict) where T <: PKSubject
source

setkelrange!

MetidaNCA.setkelrange!Function
setkelrange!(data::T, range::ElimRange{:point}; kelauto = false) where T <: PKSubject

Set range for subject data. Set kelauto if possible.

source
setdosetime!(data::DataSet{T}, dosetime::DoseTime, ind::Int) where T <: PKSubject
source
setkelrange!(data::DataSet{T}, range::ElimRange{:point}, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}; kelauto = false)
source
setkelrange!(data::DataSet{T}, range::ElimRange{:point}; kelauto = false) where T <: PKSubject
source
setkelrange!(data::DataSet{T}, range::ElimRange{:point}, sort::Dict; kelauto = false) where T <: PKSubject
source

setth!

MetidaNCA.setth!Function
setth!(data::T, th) where T <: PDSubject

Set threshold for subject data.

source
setth!(data::DataSet{T}, th, ind::Int) where T <: PDSubject
source
setth!(data::DataSet{T}, th, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}})
source
setth!(data::DataSet{T}, th) where T <: PDSubject
source
setth!(data::DataSet{T}, th, sort::Dict) where T <: PDSubject
source

timefilter

MetidaNCA.timefilterFunction
timefilter(subj::PKSubject, time::AbstractRange)

Exclude all observation than not in time range.

source
timefilter(subj::PKSubject, time::Tuple{<:Number, <:Number})

Make deepcopy of subj and remove all observations < time[1] or > time[2]. Then resize keldata to 0.

If any of points in elimination rage not in min/max time, then elimination settings reset.

source
timefilter(data::DataSet{<: PKSubject}, time)

Make new DataSet with new filtered subjects.

source

Atomic

auc_sparse

MetidaNCA.auc_sparseFunction
auc_sparse(time, obs)

AUC for sparse data.

\[w_1 = (t_2 - t_1) / 2\]

\[w_j = (t_{j+1} - t_{j-1}) / 2 (2 \leq j \leq J - 1)\]

\[w_J = (t_J - t_{J-1}) / 2\]

\[AUC = \sum_{j=1}^J \mu_j w_j\]

where math \mu_j is the mean drug concentration at time t.

source

Warning Atomic functions: cmax, tmax, auc not exported, use import MetidaNCA: cmax, tmax, auc;.

auc

MetidaNCA.aucFunction
auc(time::AbstractVector, obs::AbstractVector;  calcm = :lint)

Return AUC. All concentration points included in calculation.

  • calcm - AUC/AUMC calculation method:
    • :lint - linear trapezoidal;
    • :logt - log-trapezoidal after Tmax;
    • :luld - linar up log down;
    • :luldt - linear up log down after Tmax;
Note

This function doesn't contain NaN, missing or dosing time checks.

source

cmax

tmax