Skip to content

Loads ONE pharmacokinetic data file (XPT, XLSX, XLS, CSV, TXT, SAS7BDAT) - #635

Open
PavanLomati wants to merge 2 commits into
humanpred:mainfrom
PavanLomati:read_pk_file
Open

PavanLomati wants to merge 2 commits into
humanpred:mainfrom
PavanLomati:read_pk_file

Conversation

@PavanLomati

Copy link
Copy Markdown
Contributor

that may contain concentration data, dose data, or both (a "combined"
file), and returns the matching PKNCA object:

both conc + dose columns present -> a PKNCAdata object
only conc columns present -> a PKNCAconc object
only dose columns present -> a PKNCAdose object

 that may contain concentration data, dose data, or both (a "combined"
 file), and returns the matching PKNCA object:

   both conc + dose columns present -> a PKNCAdata object
   only conc columns present        -> a PKNCAconc object
   only dose columns present        -> a PKNCAdose object
Comment thread R/read_pk_file.R Outdated
"\\b(ng|mg|ug)[^a-z0-9]{0,3}ml\\b" # ng/mL, mg/mL, ug/mL, or with _ . space as separator (e.g. "(ng/mL)" -> "..ng.mL.")
),
dose = c(
"^dose$", "^amount$", "^exdose$", "^amt$",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also include "^ecdose$"

Comment thread R/read_pk_file.R Outdated
),
dose = c(
"^dose$", "^amount$", "^exdose$", "^amt$",
"^dose\\b", # starts with "dose" (e.g. R-mangled "Dose..mg.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not guess on mangled column names. Cleaning up column names should be done before input.

Comment thread R/read_pk_file.R Outdated
"^dose\\b", # starts with "dose" (e.g. R-mangled "Dose..mg.")
"^dose_", # dose_ prefix
"_dose$", # _dose suffix
"\\b(mg|ug)[^a-z0-9]*$" # mg or ug, optionally with trailing punctuation (e.g. "..mg.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not guess that mg or ug is a dose as it could be something else. The column should must be clearly named with the correct name.

Comment thread R/read_pk_file.R Outdated
subject = c(
"^usubjid$", "^id$", "^subject$", "^subjectid$", "^ptno$",
"^subj$", "^subj_id$", "^subject_id$",
"^subject\\b", # starts with "subject" (e.g. R-mangled "Subject.ID.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not accept these starts with variants because it could be something else. We should be strict on the column naming so that we don't accidentally guess at something incorrect.

Comment thread R/read_pk_file.R Outdated
time = c(
"^time$", "^pctptnum$", "^atptn$", "^tad$", "^tafd$", "^hr$",
"^hours$", "^time_h$", "^time_hr$",
"^time\\b", # starts with "time" (e.g. R-mangled "Time..hr.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about starting with the values: please exclude those.

Comment thread R/read_pk_file.R Outdated
#' present (intervals are auto-derived from dose times as usual).
#' @param conc_options Optional named list of extra arguments passed on to
#' \code{PKNCAconc()} (e.g. \code{list(exclude = "excl", sparse = TRUE)}).
#' @param dose_options Optional named list of extra arguments passed on to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to dose_args since "options" has specific meaning for a different argument.

Comment thread R/read_pk_file.R Outdated
#' @param verbose Logical. Print progress messages? Default \code{TRUE}.
#'
#' @return A \code{PKNCAdata}, \code{PKNCAconc}, or \code{PKNCAdose} object,
#' depending on what was found in the file (and whether \code{intervals}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the note about intervals here

Comment thread R/read_pk_file.R
role <- detect_role(path, patterns = patterns, verbose = verbose)

if (role == "unknown") {
rlang::abort(sprintf(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this error above (you will need to pass the path into detect_role())

Comment thread R/read_pk_file.R Outdated
if (verbose) rlang::inform(sprintf(" \u2022 Auto-built conc_formula: %s", deparse(conc_formula)))
}

o_conc <- do.call(PKNCA::PKNCAconc, c(list(data = df, formula = conc_formula), conc_options))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the PKNCA:: since it's in the package. Please apply throughout.

Comment thread DESCRIPTION Outdated
rlang,
stats,
rio,
janitor,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we should need janitor after all edits are made.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants