API
Main
nca!
MetidaNCA.nca! — Functionnca!(data::DataSet{Subj}, obs::Union{Symbol, Nothing} = nothing; adm = :ev, calcm = :lint, intpm = nothing, verbose = 0, warn = true, wm::Bool = false, io::IO = stdout, modify! = identity) where Subj <: AbstractSubjectNon-compartmental (NCA) analysis of PK/PD data.
Arguments
- data - DataSet to analyze;
- obs - observation to use as a PK metric (by default used first observations vector).
Keywords
wm- write output to DataSet metadata (:ncalogindex).
Other keywords is the same as in nca! method for PKSubject.
nca!(data::PKSubject{T,O}, obs::Union{Symbol, Nothing} = nothing; adm = :ev, calcm = :lint, usedose::Int = 0, intpm = nothing, partials = nothing, prtext = :err, verbose = 0, warn = true, io::IO = stdout, modify! = nothing) where T where OArguments
- data - PK Subject to analyze;
- obs - observation to use as a PK metric (by default used first observations vector).
Keywords
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);
usedose- number of dose used for calculation; ifusedose = 0(by default) - last dose used.intpm- interpolation method::lint- linear trapezoidal;:luld- linear up log down;:luldt- linear up log down after Tmax;:logt- log-trapezoidal after Tmax;:calcm- same ascalcm;
partials- calculate partial AUC vor vector of time intervals (:err(default) - throw error if end time > last oservation time;:last- no extrapolation;:extr- ifKelcalculated used extrapolation orNaNif 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
- Ctaumax
- Ctaumin
- Accind
- Fluc
- Fluctau
- Swing
- Swingtau
- MRTtauinf
- MRTtauinf_pred
- 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 VNon-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 ONon-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, obs, sort; kelauto = true, elimrange = ElimRange(), dosetime = DoseTime(), kwargs...)
nca(data, time, obs; kelauto = true, elimrange = ElimRange(), dosetime = DoseTime(), kwargs...)
nca(time, obs; 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, obs, sort;
kelauto = true,
elimrange = ElimRange(),
dosetime = DoseTime(),
limitrule::Union{Nothing, LimitRule} = nothing,
warn = true,
kwargs...)Import PK data from table data.
time- time column;obs- concentration column;sort- subject sorting columns.
keywords:
kelauto- iftrueauto range settings, iffalseusedkelstart/kelendfromelimrange;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;- checktime (true) - check uniqueness of time values;
- nutcfunk (last) - function used to chose concentration value for identical time (if checktime ==
true).
pkimport(data, time, obs;
warn = true,
kwargs...)Import PK data from tabular data data, time - time column, obs - concentration column.
pkimport(time, obs;
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 obs.
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 <: NumberDose settings.
dose- dose;time- dose time;tau- tau (τ);
Dose time set 0 by default.
ElimRange
MetidaNCA.ElimRange — TypeElimRange(kelstart::T, kelend::T, kelexcl::Vector{T}; time = false)Elimination settings for PK subject.
kelstart- start time;kelend- end time;kelexcl- excluded values.
if keyword time == false (by default) - means that the time point number is used to specify start point, end point and excluded values; time == true - real time values will be used to declare range and exluded values.
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 allNaNpoints.
Rule for PK subject.
- STEP 1 (NaN step): replace all
NaNandmissingvalues with nan keyword value (ifnannot NaN); - STEP 2 (LLOQ step): replace values below
lloqwithbtmaxvalue if this value befor Tmax or with atmax if this value after Tmax (iflloqnot NaN); - STEP 3 (remove NaN):
rm== true, then remove allNaNandmissingvalues.
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 VPharmacokinetic subject.
Fields:
- time::Vector{T} - time values;
- obs::Vector{O} - observations;
- kelauto::Bool
- kelrange::ElimRange
- dosetime::DoseTime
- keldata::KelData
- id::Dict{Symbol, V}
- ncaresobs::Symbol
MetidaNCA.NCAResult
MetidaNCA.NCAResult — TypeNCAResult(subject::T, options, obsname::Symbol, keldata::KD, result::Dict{Symbol, U}) where T <: AbstractSubject where KD where UNCA resulst.
Fields:
- data::T
- options::Dict{Symbol}
- obsname::Symbol
- keldata::Union{KelData, Nothing}
- 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
NaNandmissingvalues with nan keyword value (ifnannot NaN); - STEP 2 (LLOQ step): replace values below
lloqwithbtmaxvalue if this value befor Tmax or with atmax if this value after Tmax (iflloqnot NaN); - STEP 3 (remove NaN):
rm== true, then remove allNaNandmissingvalues.
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 <: PKSubjectapplylimitrule!(time, obs, rule::LimitRule)getbl
MetidaNCA.getbl — Functiongetbl(data::T) where T <: PDSubjectgetdosetime
MetidaNCA.getdosetime — Functiongetdosetime(data::T) where T <: PKSubjectReturn dosetime.
getkelauto
MetidaNCA.getkelauto — Functiongetkelauto!(data::T) where T <: PKSubjectgetkelrange
MetidaNCA.getkelrange — Functiongetkelrange(data::T) where T <: PKSubjectgetkeldata
MetidaNCA.getkeldata — Functiongetkeldata(data::T) where T <: PKSubjectgetth
MetidaNCA.getth — Functiongetth(data::T) where T <: PDSubjectpkplot
MetidaNCA.pkplot — Functionpkplot(subj::AbstractSubject; ls = false, elim = false, xticksn = :auto, yticksn = :auto, obsname = nothing, kwargs...)Plot for subject
ls- concentration in log scale;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 <: AbstractSubjectPK 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- iftruereturn 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}; elim = false, kelexcl = true, kelpoints = true, kwargs...) where T <: NCAResultpkplot(data::NCAResult; elim = false, kelexcl = true, kelpoints = true, kwargs...)Plot PK profile with elmination results.
elim- draw elimination curve;kelexcl- draw exclusions;kelpoints- draw points for elimination calculation;
vpcplot
MetidaNCA.vpcplot — Functionvpcplot(data::DataSet{T}; timef = identity, meanf = mean, intf = x->qf(x, 0.05), kwargs...) where T <: Union{PKSubject, PDSubject}Plot means in each time point with 0.05 - 0.95 quantile area.
timef - Function, can be used to transform time points.
meanf - mean by default, any other statistic function can be used.
intf - function to calculate upper and lower bounds for each time point, by default used:
qf(x, alpha) = (quantile(x, alpha), quantile(x, 1-alpha))Any other keywords pass to plot function.
setbl!
MetidaNCA.setbl! — Functionsetbl!(data::T, bl) where T <: PDSubjectSet baseline for pd subject data.
setbl!(data::DataSet{T}, bl, ind::Int) where T <: PDSubjectSet 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 <: PDSubjectSet baseline for all subjects in data.
setbl!(data::DataSet{T}, bl, sort::Dict) where T <: PDSubjectSet baseline only for subjects which sort ⊆ id is true.
setdosetime!
MetidaNCA.setdosetime! — Functionsetdosetime!(data::AbstractSubject, dosetime)Set dose time dosetime for subject data.
setdosetime!(data::PKSubject, dosetime::AbstractVector{<:DoseTime})Set dose time dosetime for subject data.
setdosetime!(data::PKSubject, dosetime::DoseTime)Set dose time dosetime for subject data.
setdosetime!(data::DataSet{T}, dosetime::DoseTime, ind::Int) where T <: AbstractSubjectind- index in DataSet.
setdosetime!(data::DataSet{T}, dosetime::DoseTime, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}) where T <: PKSubjectinds- indexes in DataSet.
setdosetime!(data::DataSet{T}, dosetime::DoseTime) where T <: AbstractSubjectFor all subjects in DataSet.
setdosetime!(data::DataSet{T}, dosetime::DoseTime, sort::Dict) where T <: AbstractSubjectSet dose time dosetime for subjects if sort ⊆ subject's id.
setkelauto!
MetidaNCA.setkelauto! — Functionsetkelauto!(data::T, kelauto::Bool) where T <: PKSubjectSet range for elimination parameters calculation for subject.
data- PK subject;kelauto- value.
setkelauto!(data::DataSet{T}, kelauto::Bool, ind::Int) where T <: PKSubjectsetkelauto!(data::DataSet{T}, kelauto::Bool, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}) where T <: PKSubjectsetkelauto!(data::DataSet{T}, kelauto::Bool) where T <: PKSubjectsetkelauto!(data::DataSet{T}, kelauto::Bool, sort::Dict) where T <: PKSubjectsetkelrange!
MetidaNCA.setkelrange! — Functionsetkelrange!(data::T, range::ElimRange; kelauto = false) where T <: PKSubjectSet range for subject data. Set kelauto if possible.
setkelrange!(data::DataSet{T}, range::ElimRange, ind::Int; kelauto = false) where T <: PKSubjectsetkelrange!(data::DataSet{T}, range::ElimRange, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}}; kelauto = false)setkelrange!(data::DataSet{T}, range::ElimRange; kelauto = false) where T <: PKSubjectsetkelrange!(data::DataSet{T}, range::ElimRange, sort::Dict; kelauto = false) where T <: PKSubjectsetth!
MetidaNCA.setth! — Functionsetth!(data::T, th) where T <: PDSubjectSet threshold for subject data.
setth!(data::DataSet{T}, th, ind::Int) where T <: PDSubjectsetth!(data::DataSet{T}, th, inds::Union{Vector{Int}, UnitRange{Int}, Tuple{Vararg{Int}}})setth!(data::DataSet{T}, th) where T <: PDSubjectsetth!(data::DataSet{T}, th, sort::Dict) where T <: PDSubjecttimefilter
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,aucnot 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;
cmax
MetidaNCA.cmax — Functioncmax(time::AbstractVector, obs::AbstractVector)Return Cmax
tmax
MetidaNCA.tmax — Functiontmax(time::AbstractVector, obs::AbstractVector)Return Tmax