API
Main
nca!
MetidaNCA.nca!
— Functionnca!(data::DataSet{Subj}; adm = :ev, calcm = :lint, intpm = nothing, verbose = 0, warn = true, wm::Bool = false, io::IO = stdout, modify! = identity) where Subj <: AbstractSubject
wm
- write output to DataSet metadata (:ncalog
index).
Non-compartmental (NCA) analysis of PK/PD data.
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
- ifKel
calculated used extrapolation orNaN
if noKel
);prtext
- extrapolation rule for partials AUC;verbose
- print toio
, 1: partial areas table, 2: 1, and results;warn
- show warnings;io
- output stream;modify!
- function to modify output paramaters, callmodify!(ncaresult)
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)]
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
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;
nca
MetidaNCA.nca
— Functionnca(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!
.
pkimport
MetidaNCA.pkimport
— Functionpkimport(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
- iftrue
auto range settings, iffalse
usedkelstart
/kelend
fromelimrange
;elimrange
- set elimination range settings;dosetime
- set dose and dose time, by default dosetime = 0, dose isNaN
;limitrule
- apply limitrule to subject;warn
- false for warnings supress.
If time column have non-unique values - last pair time-concentration will be used.
pkimport(data, time, conc;
warn = true,
kwargs...)
Import PK data from tabular data data
, time
- time column, conc
- concentration column.
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
.
upkimport
MetidaNCA.upkimport
— Functionupkimport(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.
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.
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.
pdimport
MetidaNCA.pdimport
— Functionpdimport(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 iffalse
.
pdimport(data, time, obs;
warn = true,
kwargs...)
Import PD data from tabular data data
, time
- time column, obs
- observations column.
pdimport(time, obs;
bl = 0,
th = 0,
id = Dict{Symbol, Any}(),
warn = true)
Import PD data from time vector time
and observations vector obs
.
Types
DoseTime
MetidaNCA.DoseTime
— TypeDoseTime(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.
ElimRange
MetidaNCA.ElimRange
— TypeElimRange(kelstart::Int, kelend::Int, kelexcl::Vector{Int})::ElimRange
Elimination settings for PK subject.
kelstart
- start point;kelend
- end point;kelexcl
- excluded points (not time value).
LimitRule
MetidaNCA.LimitRule
— TypeLimitRule(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 replacingNaN
;rm
- iftrue
, removee allNaN
points.
Rule for PK subject.
- STEP 1 (NaN step): replace all
NaN
andmissing
values with nan keyword value (ifnan
not NaN); - STEP 2 (LLOQ step): replace values below
lloq
withbtmax
value if this value befor Tmax or with atmax if this value after Tmax (iflloq
not NaN); - STEP 3 (remove NaN):
rm
== true, then remove allNaN
andmissing
values.
See also: applylimitrule!
MetidaNCA.PKSubject
MetidaNCA.PKSubject
— TypePKSubject(time::Vector{T}, conc::Vector{O}, kelauto::Bool, kelrange::ElimRange, dosetime::DoseTime, keldata::KelData, id::Dict{Symbol, V} = Dict{Symbol, Any}()) where T <: Number where O <: Union{Number, Missing} where V
Pharmacokinetic subject.
Fields:
- time::Vector{T} - time values;
- obs::Vector{O} - observations;
- kelauto::Bool
- kelrange::ElimRange
- dosetime::DoseTime
- keldata::KelData
- id::Dict{Symbol, V}
MetidaNCA.NCAResult
MetidaNCA.NCAResult
— TypeNCAResult(subject::T, options, result::Dict{Symbol, U}) where T <: AbstractSubject where U
NCA resulst.
Fields:
- data::T
- options::Dict{Symbol}
- result::Dict{Symbol, U}
Functions
applylimitrule!
MetidaNCA.applylimitrule!
— Functionapplylimitrule!(data::Union{PKSubject, PDSubject}, rule::LimitRule)
Apply rule to PK subject .
- STEP 1 (NaN step): replace all
NaN
andmissing
values with nan keyword value (ifnan
not NaN); - STEP 2 (LLOQ step): replace values below
lloq
withbtmax
value if this value befor Tmax or with atmax if this value after Tmax (iflloq
not NaN); - STEP 3 (remove NaN):
rm
== true, then remove allNaN
andmissing
values.
applylimitrule!(f::Function, data::DataSet{T}, rule::LimitRule) where T <: Union{PKSubject, PDSubject}
Apply if f(subj)
return true
.
applylimitrule!(data::DataSet{T}, rule::LimitRule, ind::Int) where T <: Union{PKSubject, PDSubject}
Apply by ind.
applylimitrule!(data::DataSet{T}, rule::LimitRule, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}) where T <: Union{PKSubject, PDSubject}
Apply by inds.
applylimitrule!(data::DataSet{T}, rule::LimitRule) where T <: Union{PKSubject, PDSubject}
Apply to all dataset.
applylimitrule!(data::DataSet{T}, rule::LimitRule, sort::Dict) where T <: PKSubject
applylimitrule!(time, obs, rule::LimitRule)
getbl
MetidaNCA.getbl
— Functiongetbl(data::T) where T <: PDSubject
getdosetime
MetidaNCA.getdosetime
— Functiongetdosetime(data::T) where T <: PKSubject
Return dosetime.
getkelauto
MetidaNCA.getkelauto
— Functiongetkelauto!(data::T) where T <: PKSubject
getkelrange
MetidaNCA.getkelrange
— Functiongetkelrange(data::T) where T <: PKSubject
getkeldata
MetidaNCA.getkeldata
— Functiongetkeldata(data::T) where T <: PKSubject
getkeldata(data::T) where T <: PKSubject
getth
MetidaNCA.getth
— Functiongetth(data::T) where T <: PDSubject
pkplot
MetidaNCA.pkplot
— Functionpkplot(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;drawdt
(false
) - draw drawdose time;
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,
ldict = nothing,
savepath::Union{Nothing, AbstractString} = nothing,
namepref::Union{Nothing, AbstractString} = nothing,
onlyplots = 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;savepath
- path for plot saving;namepref
- name prefix for saving files.onlyplots
- iftrue
return only vetor of plots;
Use pagesort = MetidaNCA.NoPageSort()
to prevent page plotting (return single plot).
Return vector of pairs: Page ID
=> Plot
.
pkplot(data::DataSet{T}; kwargs...) where T <: NCAResult
pkplot(data::NCAResult; kwargs...)
setbl!
MetidaNCA.setbl!
— Functionsetbl!(data::T, bl) where T <: PDSubject
Set baseline
for pd subject data
.
setbl!(data::DataSet{T}, bl, ind::Int) where T <: PDSubject
Set baseline for subject ind
in data
.
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
.
setbl!(data::DataSet{T}, bl) where T <: PDSubject
Set baseline
for all subjects in data
.
setbl!(data::DataSet{T}, bl, sort::Dict) where T <: PDSubject
Set baseline
only for subjects which sort
⊆ id
is true
.
setdosetime!
MetidaNCA.setdosetime!
— Functionsetdosetime!(data::T, dosetime::DoseTime) where T <: AbstractSubject
Set dose time dosetime
for subject data
.
setdosetime!(data::DataSet{T}, dosetime::DoseTime, ind::Int) where T <: AbstractSubject
ind
- index in DataSet.
setdosetime!(data::DataSet{T}, dosetime::DoseTime, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}) where T <: PKSubject
inds
- indexes in DataSet.
setdosetime!(data::DataSet{T}, dosetime::DoseTime) where T <: AbstractSubject
For all subjects in DataSet.
setdosetime!(data::DataSet{T}, dosetime::DoseTime, sort::Dict) where T <: AbstractSubject
Set dose time dosetime
for subjects if sort
⊆ subject's id
.
setkelauto!
MetidaNCA.setkelauto!
— Functionsetkelauto!(data::T, kelauto::Bool) where T <: PKSubject
Set range for elimination parameters calculation for subject.
data
- PK subject;kelauto
- value.
setkelauto!(data::DataSet{T}, kelauto::Bool, ind::Int) where T <: PKSubject
setkelauto!(data::DataSet{T}, kelauto::Bool, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}) where T <: PKSubject
setkelauto!(data::DataSet{T}, kelauto::Bool) where T <: PKSubject
setkelauto!(data::DataSet{T}, kelauto::Bool, sort::Dict) where T <: PKSubject
setkelrange!
MetidaNCA.setkelrange!
— Functionsetkelrange!(data::T, range::ElimRange{:point}; kelauto = false) where T <: PKSubject
Set range
for subject data
. Set kelauto
if possible.
setdosetime!(data::DataSet{T}, dosetime::DoseTime, ind::Int) where T <: PKSubject
setkelrange!(data::DataSet{T}, range::ElimRange{:point}, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}; kelauto = false)
setkelrange!(data::DataSet{T}, range::ElimRange{:point}; kelauto = false) where T <: PKSubject
setkelrange!(data::DataSet{T}, range::ElimRange{:point}, sort::Dict; kelauto = false) where T <: PKSubject
setth!
MetidaNCA.setth!
— Functionsetth!(data::T, th) where T <: PDSubject
Set threshold
for subject data
.
setth!(data::DataSet{T}, th, ind::Int) where T <: PDSubject
setth!(data::DataSet{T}, th, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}})
setth!(data::DataSet{T}, th) where T <: PDSubject
setth!(data::DataSet{T}, th, sort::Dict) where T <: PDSubject
timefilter
MetidaNCA.timefilter
— Functiontimefilter(subj::PKSubject, time::AbstractRange)
Exclude all observation than not in time range.
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.
timefilter(data::DataSet{<: PKSubject}, time)
Make new DataSet with new filtered subjects.
Atomic
auc_sparse
MetidaNCA.auc_sparse
— Functionauc_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.
Warning Atomic functions:
cmax
,tmax
,auc
not exported, useimport MetidaNCA: cmax, tmax, auc;
.
auc
MetidaNCA.auc
— Functionauc(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;
This function doesn't contain NaN
, missing
or dosing time checks.
cmax
MetidaNCA.cmax
— Functioncmax(time::AbstractVector, obs::AbstractVector)
Return Cmax
tmax
MetidaNCA.tmax
— Functiontmax(time::AbstractVector, obs::AbstractVector)
Return Tmax