Hello. I am going through a project systematically to learn Pumas.
This is the dataprep step. As part of the dataprep step, I would like to run the read_nca, read_pumas to ensure data is properly formatted. read_nca runs fine. However I encounter an error with read_pumas. I am unable to decipher the following error. I am providing the code and the data link below. Any help is greatly appreciated.
Bob
###############################
"ERROR: LoadError: MethodError: no method matching preprocess_data(::DataFrame, ::Symbol, ::Symbol, ::Nothing, ::Symbol, ::Bool)
Closest candidates are:
preprocess_data(::AbstractDataFrame, ::Vector{Symbol}, ::Symbol, ::Union{Nothing, Symbol}, ::Union{Nothing, Symbol}, ::Bool) at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/HDuXQ/src/data_parsing/io.jl:1182
Stacktrace:
[1] read_pumas(df::DataFrame; observations::Symbol, covariates::Vector{Symbol}, id::Symbol, time::Symbol, evid::Symbol, amt::Symbol, addl::Symbol, ii::Symbol, cmt::Symbol, rate::Symbol, ss::Symbol, route::Symbol, mdv::Nothing, event_data::Bool, covariates_direction::Symbol, check::Bool, adjust_evid34::Bool)
@ Pumas /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/HDuXQ/src/data_parsing/io.jl:1131
[2] top-level scope
@ ~/data/code/practice/nibr/data/dataprep.jl:57"
The code is here:
using Random
using CSV
using Pumas
using PumasUtilities
using Chain
using CategoricalArrays
using StatsBase
using Bioequivalence.GLM: lm, @formula
using DataFramesMeta
############################
#Data specifications
##Column name Description
##ID Unique subject id (numeric)
##TIME Time relative to first drug administration
##NOMTIME Nominal time
##TIMEUNIT unit of TIME
##AMT Dosing amount (for dosing events) in mg (numeric)
##LIDV Observation on a linear scale (Observation type determined by CMT),
##EVENTU Units (numeric)
##CMT Compartment number (determines observation type) (integer)
##CMT 1 Dosing event
##CMT 2 PK concentration
##NAME description of event
##EVENTU unit for observation
##CENS censored values (0 = not censored, 1 = censored) (integer)
##EVID event ID (0 = observation, 1 = dosing event) (integer)
##WEIGHTB baseline bodyweight (kg)
##SEX sex
##TRTACT Treatment group label (string)
##DOSE randomized dose in mg (numeric)
#Data Source https://opensource.nibr.com/xgx/Data/Single_Ascending_Dose_Dataset2.csv
#Details https://opensource.nibr.com/xgx/Datasets.html#single_ascending_dose_dataset2
###########################
pkdata = CSV.File("../code/practice/nibr/data/Single_Ascending_Dose_Dataset2.csv"; header=1, missingstring="NA") |> DataFrame
pkdata[!,:ROUTE] .= "ev"
pkdata[!,:AMT_UG] .= pkdata.AMT .* 1000
pkdata = @chain pkdata begin
@select :ID :TIME :NOMTIME :AMT_UG :CMT :EVID :LIDV :ROUTE :WEIGHTB :SEX :DOSE
@subset :TIME .>= 0
end
###### NCA ########
pop_nca = read_nca(pkdata;
observations = :LIDV,
id = :ID,
time = :TIME,
route = :ROUTE,
amt = :AMT_UG,
covariates = [:WEIGHTB, :SEX, :DOSE]
)
###################
pop_nmle = read_pumas(pkdata;
observations = :LIDV,
id = :ID,
time = :TIME,
route = :ROUTE,
amt = :AMT_UG,
cmt = :CMT,
evid = :EVID,
covariates = [:WEIGHTB, :SEX, :DOSE]
)
#############