Giter Site home page Giter Site logo

billdenney / pknca Goto Github PK

View Code? Open in Web Editor NEW
65.0 14.0 23.0 23.32 MB

An R package is designed to perform all noncompartmental analysis (NCA) calculations for pharmacokinetic (PK) data.

Home Page: http://billdenney.github.io/pknca/

License: GNU Affero General Public License v3.0

R 59.22% HTML 40.78%
noncompartmental-analysis cran r nca pharmacokinetics

pknca's Introduction

CRAN_Status_Badge R-CMD-check Code_Coverage_Badge CodeFactor CII Best Practices

The PKNCA R Package

The PKNCA R package is designed to perform all noncompartmental analysis (NCA) calculations for pharmacokinetic (PK) data. The package is broadly separated into two parts (calculation and summary) with some additional housekeeping functions.

The primary and secondary goals of the PKNCA package are to 1) only give correct answers to the specific questions being asked and 2) automate as much as possible to simplify the task of the analyst. When automation would leave ambiguity or make a choice that the analyst may have an alternate preference for, it is either not used or is possible to override.

Note that backward compatibility will not be guaranteed until version 1.0. Argument and function changes will continue until then. These will be especially noticeable around the inclusion of IV NCA parameters and additional specifications of the dosing including dose amount and route.

Citation

Citation information for the PKNCA package is available with a call to citation(package="PKNCA"). The preferred citation until publication of version 1.0 is below:

Denney W, Duvvuri S and Buckeridge C (2015). "Simple, Automatic Noncompartmental Analysis: The PKNCA R Package." Journal of Pharmacokinetics and Pharmacodynamics, 42(1), pp. 11-107,S65. ISSN 1573-8744, doi: 10.1007/s10928-015-9432-2, <URL: https://github.com/billdenney/pknca>.

Installation

From CRAN

The current stable version of PKNCA is available on CRAN. You can install it and its dependencies using the following command:

install.packages("PKNCA")

From GitHub

To install the development version from GitHub, type the following commands:

install.packages("remotes")
remotes::install_github("billdenney/pknca")

Calculating parameters

# Load the package
library(PKNCA)
# Set the business rule options with the PKNCA.options() function
# Load your concentration-time data
conc_raw <- read.csv("myconc.csv", stringsAsFactors=FALSE)
# Load your dose data
dose_raw <- read.csv("mydose.csv", stringsAsFactors=FALSE)
# Put your concentration data into a PKNCAconc object
o_conc <- PKNCAconc(data=conc_raw,
                    formula=conc~time|treatment+subject/analyte)
# Put your dose data into a PKNCAdose object
o_dose <- PKNCAdose(data=dose_raw,
                    formula=dose~time|treatment+subject)
# Combine the two (and automatically determine the intervals of
# interest
o_data <- PKNCAdata(o_conc, o_dose)
# Compute the NCA parameters
o_results <- pk.nca(o_data)
# Summarize the results
summary(o_results)

More help is available in the function help files, and be sure to look at the PKNCA.options function for many choices to make PKNCA conform to your company's business rules for calculations and summarization.

Feature requests

Please use the github issues page (https://github.com/billdenney/pknca/issues) to make feature requests and bug reports.

pknca's People

Contributors

billdenney avatar fabern avatar hadley avatar nanhung avatar wsloand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pknca's Issues

summary output request

Hi Bill,
Could you add 'N' (number of subjects) per group or period, as a default output from the summary.PKNCAresults? Also, is it posible to use "-" instead of "," for 'range' outputs, such as Tmax?
"." camma causes problems when I export the output to csv file. For example, I would like to see N for each TREATXT, and Tmax will be [1.00-6.00] etc. below.

start end TREATXT DOSE auclast cmax tmax half.life aucinf

#0 Inf 15 mg Fed 15 1200 [19.5] 187 [23.4] 2.00 [1.00, 6.00] 12.2 [2.65] 1220 [19.2]
#0 Inf 15 mg Fasted 15 1310 [20.6] 271 [24.4] 1.00 [1.00, 3.00] 12.3 [3.28] 1330 [20.5]

Plot points used in Lz determination

Would be nice to have a (plot.Lz.points) function to visualize those points (and associated regression line) associated with determining Lz slope.

Option Help

It would be nice to have more, and better, examples of how to use the various options with this package.

Figure: Mean group concentration-time plot

Plot the group mean (by selectable central tendency statistic at minimum arithmetic mean, geometric mean, and median)

  • Optionally with variability (selectable by at least stdev, SE, and CI)

Individualised intervals for NCA

Dear Bill

Some subjects in my dataset have (after iv bolus at t=0) a first observation at 0.08 h, some have it at 0.15 h.

If I want to use an automated approach, I would need to adjust the intervals for AUC calculation per individual, as the package does not allow me to put c(0, Inf) as integration interval.

Can you please advise me how I can resolve this issue?

Thanks a lot!
Huybrecht

Steady-State NCA parameters error

When calculating steady state parameters, cav and ctrough using the following interval, error messages appear.

my.intervals <- data.frame(start=0,
end=Inf,
cmax=TRUE,
tmax=TRUE,
aucinf=TRUE,
auclast=TRUE,
aucall=TRUE,
aumcinf=TRUE,
aumclast=TRUE,
aumcall=TRUE,
cl=TRUE,
aucpext=TRUE,
vss=FALSE, ptr=TRUE, ctrough=TRUE)

Error in pk.nca.interval(conc = tmpconcdata[, col.conc], time = tmpconcdata[, :
Cannot find argument 'start' for NCA function 'pk.calc.cav'

Error in pk.nca.interval(conc = tmpconcdata[, col.conc], time = tmpconcdata[, :
Cannot find argument 'start' for NCA function 'pk.calc.ctrough'

How to work with data with concentration and time but not dose?

Hi all,

I want to conduct a regular NCA analysis to generate AUC and Cmax. However, for part of my dataset from a few subjects, there was no dose information, but only concentrations and times (up 24 hrs after the dose). Can the package PKNCA be used to work on the data I have?

Thanks!

Add IV Parameters

C0 - initial concentration (extrapolated to time 0)
Vd,initial - initial volume of distribution

wide format output

You may add an augment to pk.nca function to let users choose long or wide format output. The default is the long format but wide format might be more intuitive for visual inspection and subsequent manipulation. Right now, I am using the tidyr::spread to reshape the result manually, like final.result[[1]] %>% spread(PPTESTCD,PPORRES)

Introduction-and-Usage.Rmd not executable

Hi Bill,

I think the best way to learn the package is to run it on a local computer. However, some blocks in the Introduction-and-Usage.Rmd is not executable. For example, if I force to run the ## Summarization Options block , I got error message. Is it possible for you to show a real running example and how you get that step?

Thank you,

Sibo

conflict with tbl_df class from dplyr

After calling PKNCAdose and PKNCAconc to d.dose and d.conc data frames which are also of the tbl_df class because I created them through dplyr, I run into an error when calling PKNCAdata:

Error in `$<-.data.frame`(`*tmp*`, "start", value = list(tsld = 0)) : 
  replacement has 1 row, data has 2

It works if I coerce d.dose and d.conc to a data frame (removing the tbl_df class) using the code below:

nca.conc <- PKNCAconc(data.frame(d.conc),
                     conc~tsld|group+id)

nca.dose <- PKNCAdose(data.frame(d.dose),
                     ~tsld|group+id)

We can provide a reproducible example if necessary.

[Feature Request] checkpoint for numeric data - easy to fix

I found the PKNCAdata (conc,dose) will accept the data, even the column type of concentration is character. Then, it will run into error when NCA is performed. However, the error message below is not informative as respect to the root of the problem.
It would be helpful to have a checkpoint for the data type before the NCA is run. In this way, it ensure all the input data are numeric.

> my.data <- PKNCAdata (conc,dose) %>% pk.nca (.)
Error in conc.2 + conc.1 :
Error with interval ID=1, start=0, end=24: non-numeric argument to binary operator

Vz and Vd

Hi Bill,
I am having trouble getting PKNCA to calculate Vz. My code is as follows for interval specifications.

my.intervals <- data.frame(start=0,
end=inf,
cmax=TRUE,
tmax=TRUE,
aucinf=TRUE,
auclast=TRUE,
aucall=TRUE,
aumcinf=TRUE,
aumclast=TRUE,
aumcall=TRUE,
cl=TRUE,
aucpext=TRUE,
vz=TRUE)

Error in pk.nca.interval(conc = tmpconcdata[, col.conc], time = tmpconcdata[, :
Cannot find argument 'auc' for NCA function 'pk.calc.mrt'

In your manual, pk.calc.vd(dose, aucinf, lambda.z) and pk.calc.vz(dose, auc, kel, unitconv). Is the formula in PKNCA for Vz=Dose/(AUC x Kel) whereas Vd=Dose/(AUCinf x lambda z)? It seems like this is different from what I know, where Vz=Dose/(AUCinf x lambda z).

Thank you!

Dose-normalized values and more lambda z specification possibilities...

Hi Bill,

As discussed in a previous e-mail, it would be great if there could be the possibility for dose-normalized parameters (calculating them individually isn't an issue, but it would be nice to have them then also included in the summary table). As well, being able to have additional flexibility on the restrictions for the number of lambda z points (e.g. for comparing with other analyses, etc., that may have a specific number of lambda z points), would be great. I'm guessing this could be handled with something like a max.hl.points? or something where one can just straight out specify the number of desired points?

Thanks so much for this package and for incorporating all our requests :) !

Failures with dplyr update

CRAN is seeing a segfault with the current release candidate of dplyr (in tidyverse/dplyr#3060), but we're unable to replicate it:

Package: PKNCA crashed in

    *** caught segfault ***
   address (nil), cause 'memory not mapped'

   Traceback:
    1: .Call(`_dplyr_bind_rows_`, dots, id)
    2: bind_rows_(x, .id)
    3: dplyr::bind_rows(tmp.results)
...

on Debian during revdepo checks...

Could you please take a look? Install with devtools::install("tidyverse/dplyr#3060") .

CC @hadley.

Figure: Group concentration-time plots

Show the group concentration-time plots (as spaghetti plots)

  • One line per subject
  • Ensure separation of the same subject in case a subject is re-challenged with the same treatment/PKNCA grouping.

max.aucinf.pext

For this argument in PKNCA.options(), by setting a value, will PKNCA automatically exclude any parameters with aucinf that are greater than this value? When I leave it as the default setting (20), I'm getting the parameters with max.aucinf.pext>20%.

Feature Request: max.hl.points

From #41: As well, being able to have additional flexibility on the restrictions for the number of lambda z points (e.g. for comparing with other analyses, etc., that may have a specific number of lambda z points), would be great. I'm guessing this could be handled with something like a max.hl.points? or something where one can just straight out specify the number of desired points?

calculation of Vss for multiple-dose PK

Bill,

Can you confirm that the formulas used for calculating MRT and Vss for intravascular dosing accounts for differences between single-dose PK and multiple-dose PK?

single-dose PK:
MRTsd = AUMCinf/AUCinf - infusion duration/2
Vss = CLinfMRTsd
multiple dose PK, including washout data after last dose (to calculate AUCinf after last dose):
MRTmd = AUMCtau/AUCtau + (TAU * (AUCinf - AUCTAU ) / AUCTAU - infusion duration/2
Vss = CLtau
MRTmd

Thanks.

Figure: Individual concentration-time

  • Plot the individual concentration-time profile for a single subject
  • Optionally display excluded points differently than included points
  • Optionally include lambda.z-determination within the figure

Ref also issue #14.

Error with PKNCAdose: "The formula must be one-sided"

Hi Bill,
I am running into the following error while using

PKNCAdose

Error in PKNCAdose(d.dose, Dose ~ Time | Subject) :
The formula must be one-sided

I tried to recreate the theophylline example and get the same error message as above.

library(PKNCA)
library(knitr)

##clear workspace
rm(list = ls())
my.conc <- PKNCAconc(as.data.frame(datasets::Theoph), conc ~ Time|Subject)
d.dose <- unique(datasets::Theoph[datasets::Theoph$Time == 0,
                                  c("Dose", "Time", "Subject")])
my.dose <- PKNCAdose(d.dose, Dose~Time|Subject)

Any help or reference to an existing solution would be helpful.

Thanks,
Anson

Multiple Dose PK Times Don't Align

When calculating multiple dose PK parameters, AUC intervals after time 0 do not align the time correctly.

Warning in pk.calc.auxc(conc = conc, time = time, ..., options = options,  :
  Requesting an AUC range starting (0) before the first measurement (312) is not allowed

Cast summary(PKNCAresults)

It would be nice to have a "cast.PKNCAresult" to create exportable file with NCA results in column form (not list form).

Predicted parameters based on predicted lambda z

It would be nice to have predicted parameters on top of the observed parameters as we often report predicted parameters, eg. AUCinf_pred, AUC_%extrap_pred, Vz_pred, Cl_pred, AUMCinf_pred, MRTinf_pred

Multiple columns of groups caused error in merge.splitByData

When creating two groups as follows, the error below occurs.

myconc <- PKNCAconc(data=myrawconcdata ,formula= conc~time|subject/analyte)
# Put your dose data into a PKNCAdose object
mydose <- PKNCAdose(data=myrawdosedata ,formula= ~time|subject)
# Combine the two (and automatically determine the intervals of
# interest
mydata <- PKNCAdata(myconc, mydose)

Error in FUN(X[[1L]], ...) (from merge.splitByData.R#25) : 
  2 arguments passed to 'names' which requires 1

IV infusion

It would be nice if there is option to input infusion length and MRT is calculated accordingly.

Older Other Package Versions Do Not Work with PKNCA

Older versions of one or more of the dependency packages cause an error with PKNCA. A relevant error code is:

5: stop("exclude column must be character vector or something convertable to character without loss of information.")
4: setExcludeColumn(ret, exclude = exclude, dataname = "result")
3: PKNCAresults(result = results, data = data, exclude = "exclude")
2: pk.nca(mydata)

calculation of Cav

The formula for Cav
Cav = auc.last / (end - start)
depends on the value of "end".

"end" needs to be set t >= the largest value of t.last in the observed data in order for that time/concentration pair to be included in the calculation of auc.last. (Subject 1 in the PKNCA theophylline dataset is an example. His/her last time/concentration pair is (24.37, 3.28). "end" has to be set >= 24.37 in order for (24.37, 3.28) to be included in the calculation of auc.last for that subject). Setting "end" to be >= all observed t.last values means Cav will be underestimated for all subjects except those for whom observed t.last = "end".

If it is desired to calculate Cav based on observed data, the formula should be
Cav = auc.last / (t.last - start)
for auc.last and t.last as found in the parameter interval.

If it is desired to calculate Cav based on a stipulated length of the dosing interval, the formula could be
Cav = auc.tau / (tau - start)
where auc.tau is an interpolated/extrapolated auc value and tau is set by the analyst.

Thanks,
Dennis

lambda z and AUCinf

Hi Bill,
I have a question regarding the lambda z and AUC_inf.
Would you please share how the current version of PKNCA package calculate the lambda z and AUC (tlast-inf)? If I set the ending time to inf, the package will calculate the AUC (tlast to inf) based on the last sampling point and the lambda z? Then the AUC (0-tlast) and AUC (tlast-inf) are summed up to get the AUC_inf? Instead, if I set the ending time to 24 hours for a 36 hours dataset, the AUCinf will be calculated as the sum of the AUC (0-24) and AUC (24-inf)?

Thank you,

Sibo

Make PKNCA_CRAM.pdf more informative

Hi Bill,

I found that a lot of functions in the PKNCA_CRAM manual do not include examples of their usages. For example, there is only a general usage for the function pk.calc.tmax. To make the manual more informative, you may want to add a real dataset example to show people how to use it. In the meantime, to list all the functions in alphabetical order make the manual less readable. It is appreciated if you can develop another textbook version.

Thank you,

Sibo

mrt cannot be calculated

mrt cannot be calculated when manual interval is specified as follows,

my.intervals <- data.frame(start=0,
end=inf,
cmax=TRUE,
tmax=TRUE,
auclast=TRUE,
aucinf=TRUE,
aumclast=TRUE,
aumcinf=TRUE,
aucall=TRUE,
aumcall=TRUE,
mrt=TRUE)

Error message:

Error in pk.nca.interval(conc = tmpconcdata[, col.conc], time = tmpconcdata[, :
Cannot find argument 'auc' for NCA function 'pk.calc.mrt'

Table: Mean parameter table

A table listing all calculated NCA parameters with a set of summary statistics

  • Option: The summary statistics may be the same across all parameters (e.g. arithmetic mean, standard deviation, etc.) or they may be different by parameter (e.g. geometric mean for Cmax and median for Tmax).

Pre-treatment of data

It would be nice if data are checked and corrected before nca run. For example, insertion of initial time points if there is none for non-steady state extravascular and infusion data and set C0=Cmin for steady-state data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.