| Title: | Pharmacokinetic Bioanalysis Experiments Design and Exploration |
|---|---|
| Description: | Automate pharmacokinetic/pharmacodynamic bioanalytical procedures based on best practices and regulatory recommendations. The package impose regulatory constrains and sanity checking for common bioanalytical procedures. Additionally, 'PKbioanalysis' provides a relational infrastructure for plate management and injection sequence. |
| Authors: | Omar Elashkar [aut, cre] (ORCID: <https://orcid.org/0000-0002-5505-778X>) |
| Maintainer: | Omar Elashkar <[email protected]> |
| License: | AGPL (>= 3) |
| Version: | 0.5.0 |
| Built: | 2026-05-23 15:15:29 UTC |
| Source: | https://github.com/cran/PKbioanalysis |
Subsetting method for MultiPlate
## S4 method for signature 'MultiPlate' x[[i, j, ...]]## S4 method for signature 'MultiPlate' x[[i, j, ...]]
x |
MultiPlate object |
i |
index |
j |
index |
... |
additional arguments |
PlateObj object
Add blank to the plate Can be either double blank (DB), CS0IS+ or CS+IS0
add_blank(plate, IS = TRUE, analyte = FALSE, analytical = FALSE, group = NA)add_blank(plate, IS = TRUE, analyte = FALSE, analytical = FALSE, group = NA)
plate |
PlateObj object |
IS |
logical. If TRUE, add IS to the well. |
analyte |
logical. If TRUE, add analyte to the well. |
analytical |
logical. If FALSE, the blank is analytical, if TRUE it is bioanalytical. |
group |
A string for bioanalytical group. |
PlateObj
Add calibration curve to the plate
add_cs_curve(plate, plate_std, rep = 1, group = NA)add_cs_curve(plate, plate_std, rep = 1, group = NA)
plate |
PlateObj |
plate_std |
character |
rep |
numeric. Number of technical replicates. Default is 1. |
group |
A string for bioanalytical group. |
PlateObj
plate <- generate_96() |> add_cs_curve(c(1, 3, 5, 10, 50, 100, 200)) plot(plate)plate <- generate_96() |> add_cs_curve(c(1, 3, 5, 10, 50, 100, 200)) plot(plate)
Add double blank (DB) to a plate
add_DB(plate, analytical = FALSE, group = NA)add_DB(plate, analytical = FALSE, group = NA)
plate |
PlateObj object |
analytical |
logical. If TRUE, the blank is bioanalytical, if FALSE it is analytical. |
group |
A string for bioanalytical group. |
PlateObj
plate <- generate_96() |> add_DB()plate <- generate_96() |> add_DB()
Add dilution quality control (DQC) to the plate
add_DQC(plate, conc, fac, rep = 5, group = NA)add_DQC(plate, conc, fac, rep = 5, group = NA)
plate |
PlateObj object |
conc |
numeric. Concentration of the DQC well. |
fac |
numeric. Factor of the DQC well. |
rep |
numeric. Number of replicates. Default is 5. |
group |
A string for bioanalytical group. The current implementation does not check ULOQ or LLOQ boundaries. |
A function to add QCs to plate. This function assumes adherence to ICH guideline M10 on bioanalytical method validation and study sample analysis Geneva, Switzerland (2022). If you are not following this guideline, you can set 'reg = TRUE' to ignore the restrictions.
add_QC( plate, lqc_conc, mqc_conc, hqc_conc, extra = NULL, n_qc = 3, qc_serial = TRUE, reg = TRUE, group = NA )add_QC( plate, lqc_conc, mqc_conc, hqc_conc, extra = NULL, n_qc = 3, qc_serial = TRUE, reg = TRUE, group = NA )
plate |
PlateObj object |
lqc_conc |
low quality control concentration |
mqc_conc |
medium quality control concentration |
hqc_conc |
high quality control concentration |
extra |
numeric vector of extra QC concentrations. |
n_qc |
number of QC sets. Default is 3 |
qc_serial |
logical. If TRUE, QCs are placed serially |
reg |
logical. Indicates if restrictions should not be applied to the QC samples. Default is TRUE |
group |
A string for bioanalytical group. |
PlateObj
Add samples to plate with pharmacokinetic attributes
add_samples(plate, samples, prefix = NA, dil = NA, group = NA, rep = 1)add_samples(plate, samples, prefix = NA, dil = NA, group = NA, rep = 1)
plate |
PlateObj |
samples |
A vector representing samples names. Must be unique. |
prefix |
A prefix to be added before samples names. Default is "Sub". |
dil |
A vector representing samples' dilution factor. Must be same length as samples. |
group |
A vector representing samples' bioanalytical group. Must be same length as samples. |
rep |
Number of technical replicates for each combination. Default is 1. |
final name will be of form. Prefix-SampleName-Time-Concentration-Factor samples must be a unique vector and did not exist in the plate before. Time is either a vector or a single value. If it is a vector, it will be repeated for each sample. Conc, dil, factor and dose are either a vector or a single value. If it is a vector, it must be the corrosponding length of samples.
Allowed routes are "IV", "IM", "IP", "SC", "PO", "INH" which are short for Intravenous, Intramuscular, Intraperitoneal, Subcutaneous, Per Os (oral), Inhalation.
Factor is an arbitrary factor used in the design like food vs fasted, healthy vs diseased, positive genotype ... etc.
PlateObj
plate <- generate_96() |> add_samples(paste0("T", 1:12))plate <- generate_96() |> add_samples(paste0("T", 1:12))
Add samples from the sample log to the plate
add_samples_db(plate, logIds, dil = 1, namestyle = 1, group = NA)add_samples_db(plate, logIds, dil = 1, namestyle = 1, group = NA)
plate |
PlateObj |
logIds |
A vector of log IDs from the sample log. |
dil |
A vector with length corresponding number of logIds. See details. |
namestyle |
A numeric value indicating the naming style. 1 for long names, 2 for short names. |
group |
A string for bioanalytical group. |
This function will retrieve sample information from the sample log database using the provided log IDs. It constructs sample names based on the specified naming style and adds them to the plate. The 'dil' parameter allows specifying dilution factors for each sample, which will be appended to the sample names. If a single dilution factor is provided, it will be applied to all samples.
PlateObj
Add samples from the sample log to the plate with multiplication
add_samples_db2(plate, logIds, dil = c(1, 1), namestyle = 1, group = NA)add_samples_db2(plate, logIds, dil = c(1, 1), namestyle = 1, group = NA)
plate |
PlateObj |
logIds |
A vector of log IDs from the sample log. |
dil |
A vector with length corresponding number of repeats. See details. |
namestyle |
A numeric value indicating the naming style. 1 for long names, 2 for short names. |
group |
A string for bioanalytical group. |
This function is wrapper around 'add_samples_db()' that allows for quick replication of samples by dilution factor vector. For instance, it dil = c(1,10), the samples will repeated twice with one fold and 10 fold dilution factor each time.
Add suitability sample to the plate
add_suitability(plate, conc, label = "suitability", group = NA)add_suitability(plate, conc, label = "suitability", group = NA)
plate |
PlateObj object. |
conc |
numeric. Concentration of the suitability well. |
label |
character. Label for the suitability well. Default is "suitability". |
group |
A string for bioanalytical group. |
PlateObj
gt table of areas
area_report.PeakRes( peaks_res, normalize = TRUE, blanks = TRUE, analytes = TRUE, standards = TRUE, QCs = TRUE, compounds = NULL )area_report.PeakRes( peaks_res, normalize = TRUE, blanks = TRUE, analytes = TRUE, standards = TRUE, QCs = TRUE, compounds = NULL )
peaks_res |
PeakRes object |
normalize |
logical. If TRUE, normalize the peak area by the IS area. |
blanks |
logical. If TRUE, include blanks |
analytes |
logical. If TRUE, include analytes |
standards |
logical. If TRUE, include standards |
QCs |
logical. If TRUE, include QCs |
compounds |
numeric vector of compound numbers to include. If NULL, include all compounds |
Calculate Summary Statistics for Each Concentration Level For Either Concentration, Area, or Area Ratio
calc_var_summary( df, col = "conc", acc_cutoff = 0.2, dev_cutoff = 0.2, type = "QC" )calc_var_summary( df, col = "conc", acc_cutoff = 0.2, dev_cutoff = 0.2, type = "QC" )
df |
Data frame with columns: stdconc (standardized concentration), conc (concentration), area (peak area), area_ratio (area ratio) |
col |
Column to calculate summary for ("conc", "area", or "area_ratio") |
acc_cutoff |
Accuracy threshold (default is 20%) for concentration vs standard concentration |
dev_cutoff |
Deviation threshold (default is 20%) for concentration vs standard concentration |
type |
Type of samples to include ("Standard", "QC", "DQC") |
Omar I. Elashkar
Check Matching of Compound and Transitions in chrom_res and method database
check_chrom_cmpds(chrom_res, method_id)check_chrom_cmpds(chrom_res, method_id)
chrom_res |
ChromRes object |
method_id |
Method ID in the method database This is important to give no error before merging quantification results to ensure consistency. |
TRUE if all compounds and transitions match, otherwise FALSE
This function creates a shiny app for peak integration.
chrom_app()chrom_app()
Create Sample List with rigorous design
combine_injec_lists( sample_lists, n_equi = 10, equi_pos, equi_prefix = Sys.Date(), equi_suffix = "equi", equi_injec_vol = 0.5 )combine_injec_lists( sample_lists, n_equi = 10, equi_pos, equi_prefix = Sys.Date(), equi_suffix = "equi", equi_injec_vol = 0.5 )
sample_lists |
a list of sample lists |
n_equi |
number of equilibriation injections |
equi_pos |
position of equilibriation injections. For format check details |
equi_prefix |
prefix for equilibriation injections |
equi_suffix |
suffix for equilibriation injections |
equi_injec_vol |
volume of equilibriation injection |
The equi_pos format will be Row:Column format. E.g: "A,1"
InjecListObj object
Combine plates in MultiPlate object
combine_plates(plates)combine_plates(plates)
plates |
list of PlateObj objects |
MultiPlate object
Configure suitability runs by specifying vial position and range of runs to include.
config_suitability(quantres, vial_pos, start = NULL, end = NULL)config_suitability(quantres, vial_pos, start = NULL, end = NULL)
quantres |
QuantRes object |
vial_pos |
Vial position to use for suitability (e.g., "2:H,9") |
start |
Start position (1-based index) of runs to include. If NULL, starts from the first run. |
end |
End position (1-based index) of runs to include. If NULL, ends at the last run. |
Updated QuantRes object with suitability configuration.
Create a new study in the database
create_new_study(df)create_new_study(df)
df |
A data frame with one row containing study details: type, title, description, pkstudy (logical), subject_type |
A data frame with the created study details including generated id, start_date, and status
Calculate Coefficient of variation
cv(x, percent = TRUE)cv(x, percent = TRUE)
x |
vector |
percent |
To return the value as percentage |
A simple calculation of the coefficient of variation (CV) is done as the standard deviation divided by the mean. By default, the result is in percentage.
numeric
Download sample list from database to local spreadsheet with vendor specific format
download_sample_list(sample_list, vendor)download_sample_list(sample_list, vendor)
sample_list |
dataframe of sample list either from db or from write_injec_seq |
vendor |
currently only 'masslynx', 'masshunter' and 'analyst' are supported |
For all current vendors, the exported format will be in csv format, compatible with the respective software.
dataframe
Estimate Dilution Limit Based on Additive and Proportional Errors and LLOQ
estim_dil_limit(add_err, prop_err, lloq)estim_dil_limit(add_err, prop_err, lloq)
add_err |
Additive error (constant) |
prop_err |
Proportional error (CV) |
lloq |
Lower limit of quantification |
Omar I. Elashkar
estim_dil_limit(add_err=0.1, prop_err=0.1, lloq=1) estim_dil_limit(add_err=1, prop_err=0.1, lloq=55)estim_dil_limit(add_err=0.1, prop_err=0.1, lloq=1) estim_dil_limit(add_err=1, prop_err=0.1, lloq=55)
Estimate LLOQ From Existing Additive and Proportional errors
estim_lloq(add_err = 0.04, prop_err = 0.05, cv_lloq = 0.2, cv_lqc = 0.15)estim_lloq(add_err = 0.04, prop_err = 0.05, cv_lloq = 0.2, cv_lqc = 0.15)
add_err |
Additive error (constant) |
prop_err |
Proportional error (CV) |
cv_lloq |
Maximum coefficient of variation at LLOQ |
cv_lqc |
Maximum coefficient of variation at LQC A method to estimate LLOQ from existing additive and proportional errors. The function does inequality constrained optimization to find the LLOQ. |
Omar I. Elashkar
Export expected RT values for each peak in the chromatogram.
export_integration(chrom_res, path)export_integration(chrom_res, path)
chrom_res |
ChromRes object |
path |
Path to save the file |
Export PK profiles for a given compound in a specified format Currently supports "nonmem" format. The exported file will include a CSV with the PK data and an Excel file with the codebook.
export_pk_profiles(x, compound_id, format = "NONMEM", filename = "data.zip")export_pk_profiles(x, compound_id, format = "NONMEM", filename = "data.zip")
x |
QuantRes object |
compound_id |
Compound ID for which to export PK profiles |
format |
Format to export (currently only "NONMEM" supported) |
filename |
Name of the output zip file (default: "data.zip") |
Omar I. Elashkar
Export run
export_run(peaks_res, path)export_run(peaks_res, path)
peaks_res |
PeakRes object |
path |
path to save csv |
Extract peak boundaries for all samples for a given compound ID
extract_peak_bounds(chrom_res, compound_id, samples_ids = NULL)extract_peak_bounds(chrom_res, compound_id, samples_ids = NULL)
chrom_res |
ChromRes object |
compound_id |
Compound ID |
samples_ids |
Sample IDs. If NULL, all samples will be used The function automatically priortizes observed peak boundaries (manual integration) over expected ones. If observed boundaries are not available, it falls back to expected boundaries. |
Dataframe with compound_id, min, max
This function sets the filling scheme of the plate. The filling scheme is used to determine the order in which the samples are filled in the plate. The default filling scheme is horizontal, which means that the samples are filled from left to right and top to bottom. The vertical filling scheme means that the samples are filled from top to bottom and left to right.
fill_scheme( plate, fill = "h", tbound = "A", bbound = "H", lbound = 1, rbound = 12 )fill_scheme( plate, fill = "h", tbound = "A", bbound = "H", lbound = 1, rbound = 12 )
plate |
PlateObj |
fill |
character. Filling scheme. Either "h" for horizontal, "v" for vertical. |
tbound |
character. Top bound of the filling scheme. Default is "A" |
bbound |
character. Bottom bound of the filling scheme. Default is "H" |
lbound |
numeric. Left bound of the filling scheme. Default is 1 |
rbound |
numeric. Right bound of the filling scheme. Default is 12 |
PlateObj
This function filters chromatogram peaks based on transition ID and sample ID.
filter_chrom( chrom_res, transitions_ids = NULL, samples_id = NULL, cmpd_ids = NULL )filter_chrom( chrom_res, transitions_ids = NULL, samples_id = NULL, cmpd_ids = NULL )
chrom_res |
ChromRes object |
transitions_ids |
Vector of transition IDs to filter. If NULL, all transitions are returned. |
samples_id |
Sample ID to filter. |
cmpd_ids |
Compound ID to filter. It must be numeric. If NULL, all compounds are returned. |
Estimate Additive and proportional errors from calibration data
fit_var( data, level = 0.95, method = "nlminb", bootstrap = FALSE, n_boot = 1000 )fit_var( data, level = 0.95, method = "nlminb", bootstrap = FALSE, n_boot = 1000 )
data |
Data frame with columns: conc (concentration), stdconc (standardized concentration, e.g. conc/LLOQ) |
level |
Confidence level for the CI (default is 0.95) |
method |
Optimization method (default is "nlminb") |
bootstrap |
Logical indicating whether to perform bootstrap (default is TRUE) |
n_boot |
Number of bootstrap samples (default is 1000) |
Omar I. Elashkar
Format and print the results of fit_var
formated_print(x, digits = 3)formated_print(x, digits = 3)
x |
Data frame with results |
digits |
Number of digits to display |
Omar I. Elashkar
Generate 96 well plate
generate_96(descr = "", start_row = "A", start_col = 1)generate_96(descr = "", start_row = "A", start_col = 1)
descr |
plate description. |
start_row |
A letter corresponding to empty rows in a 96 well plate. Default is A. |
start_col |
A number indicating a column number to start with, given the start row. Default is 1. Generate a typical 96 well plate. User need to specify the empty rows which a going to be used across the experiment. |
PlateObj
plate <- generate_96() plot(plate) plate <- generate_96("calibration", start_row = "C", start_col = 11) plot(plate)plate <- generate_96() plot(plate) plate <- generate_96("calibration", start_row = "C", start_col = 11) plot(plate)
This function returns the compound ID
get_compound_ID(chrom_res, compound_name)get_compound_ID(chrom_res, compound_name)
chrom_res |
ChromRes object |
compound_name |
Compound Name |
This function returns the sample ID
get_sample_ID(chrom_res, sample_name)get_sample_ID(chrom_res, sample_name)
chrom_res |
ChromRes object |
sample_name |
Sample Name |
Find sample names for all samples
get_sample_names(chrom_res)get_sample_names(chrom_res)
chrom_res |
ChromRes object |
data.frame with sample and sample_id
check if default expected RT is set for a compound
has_default_bounds(chrom_res, compound_id)has_default_bounds(chrom_res, compound_id)
chrom_res |
ChromRes object |
compound_id |
Compound ID |
Install Python dependencies for PKbioanalysis
install_py_dep(..., envname = "PKbioanalysis")install_py_dep(..., envname = "PKbioanalysis")
... |
Additional arguments passed to reticulate::py_install |
envname |
Name of the virtual environment to create/use. Default is "PKbioanalysis" |
None
integrate Peak with trapzoid method given start and end
integrate(chrom_res, compound_id, samples_ids, smoothed = TRUE)integrate(chrom_res, compound_id, samples_ids, smoothed = TRUE)
chrom_res |
ChromRes object. Must have observed RT values |
compound_id |
Compound ID |
samples_ids |
Sample ID. If NULL, all samples will be used |
smoothed |
Logical. If TRUE, use smoothed chromatogram. Default is TRUE |
Check if peak was integrated for a specific compound
is_integrated(chrom_res, compound_id, sample_id = NULL) ## S4 method for signature 'ChromRes' is_integrated(chrom_res, compound_id, sample_id = NULL) ## S4 method for signature 'ChromResBase' is_integrated(chrom_res, compound_id, sample_id = NULL)is_integrated(chrom_res, compound_id, sample_id = NULL) ## S4 method for signature 'ChromRes' is_integrated(chrom_res, compound_id, sample_id = NULL) ## S4 method for signature 'ChromResBase' is_integrated(chrom_res, compound_id, sample_id = NULL)
chrom_res |
ChromRes or ChromResBase object |
compound_id |
Compound ID |
sample_id |
Sample ID. If NULL, all samples are checked |
logical
## Not run: lapply(1:10, \(x) is_integrated(chrom_res, sample_id = 1, compound_id = 1)) ## End(Not run)## Not run: lapply(1:10, \(x) is_integrated(chrom_res, sample_id = 1, compound_id = 1)) ## End(Not run)
Return an indicator if the chromatogram is smoothed
is_smoothed(chrom_res)is_smoothed(chrom_res)
chrom_res |
ChromRes object |
Length method for MultiPlate
## S4 method for signature 'MultiPlate' length(x)## S4 method for signature 'MultiPlate' length(x)
x |
MultiPlate object |
number of plates
Create a calibration study with calibration standards and QCs
make_calibration_study( plate, plate_std, lqc_conc = NULL, mqc_conc = NULL, hqc_conc = NULL, n_qc = NULL, qc_serial = FALSE, n_CS0IS0 = 1, n_CS0IS1 = 2, n_CS1IS0 = 1, group = NA )make_calibration_study( plate, plate_std, lqc_conc = NULL, mqc_conc = NULL, hqc_conc = NULL, n_qc = NULL, qc_serial = FALSE, n_CS0IS0 = 1, n_CS0IS1 = 2, n_CS1IS0 = 1, group = NA )
plate |
PlateObj object |
plate_std |
vector of calibration standards |
lqc_conc |
LQC concentration |
mqc_conc |
MQC concentration |
hqc_conc |
HQC concentration |
n_qc |
number of QC sets |
qc_serial |
logical. If TRUE, QCs are placed serially |
n_CS0IS0 |
number of CS0IS0 (double) blanks |
n_CS0IS1 |
number of CS0IS1 blanks |
n_CS1IS0 |
number of CS1IS0 blanks |
group |
A string for bioanalytical group. |
PlateObj
Create a metabolic study layout
make_metabolic_study( study = "Metabolic Study", cmpds, time_points = c(0, 5, 10, 15, 30, 45, 60, 75, 90, 120), dose = NA, n_NAD = 3, n_noNAD = 2 )make_metabolic_study( study = "Metabolic Study", cmpds, time_points = c(0, 5, 10, 15, 30, 45, 60, 75, 90, 120), dose = NA, n_NAD = 3, n_noNAD = 2 )
study |
study name |
cmpds |
vector of compounds, including any standards |
time_points |
vector of time points |
dose |
dose amount. Default is NA |
n_NAD |
number of NAD positive samples. Default is 3 |
n_noNAD |
number of NAD negative samples. Default is 2 |
Note that this function does not require plate object. It will create a plate object automatically and return MultiPlate object
MultiPlate object
Calculate Cmax, Tmax and AUC for each subject given a compound's PK profiles
nca_table(x, compound_id)nca_table(x, compound_id)
x |
QuantRes object with PK profiles extracted |
compound_id |
Compound ID for which to calculate NCA parameters |
This function calculates Cmax, Tmax and AUC for each subject given a compound's PK profiles.
data frame with columns: subject_id, cmax, tmax, auc_last, compound_id
Merge PK profiles into QuantRes object
pkmerge(x)pkmerge(x)
x |
QuantRes object |
Set plate description
plate_metadata(plate, descr)plate_metadata(plate, descr)
plate |
PlateObj |
descr |
character. Description of the plate |
PlateObj
Plot the design of the plate
plate_tree(plate, plot = TRUE)plate_tree(plate, plot = TRUE)
plate |
PlateObj object |
plot |
logical. If TRUE, plot the tree |
data.tree Node object or DiagrammeR object plot_tree will focus only on bioanalytical vial types, namely blanks, analytes, standards, QCs. The tree order will be plate_id, then group, then vial type, then entity, then number of technical replicates.
This function plots chromatograms for selected transitions per sample.
plot_chrom( chrom_res, ncol = 2, transitions_ids = NULL, sample_id, integrated = FALSE, show_RT = FALSE, smoothed = FALSE )plot_chrom( chrom_res, ncol = 2, transitions_ids = NULL, sample_id, integrated = FALSE, show_RT = FALSE, smoothed = FALSE )
chrom_res |
ChromRes object |
ncol |
Number of columns for facet_wrap. If 0, the chromatograms are overlayed in a single plot. |
transitions_ids |
Vector of transition IDs to plot. If NULL, all transitions are plotted. |
sample_id |
Sample ID to plot. |
integrated |
Boolean to show integrated area overlayed |
show_RT |
Boolean to show RT values |
smoothed |
Boolean to show smoothed chromatogram |
## Not run: path <- system.file("extdata", "waters_raw_ex", package="PKbioanalysis") main <- read_chrom(path, method = 1) plot_chrom(main, ncol = 2, transitions_ids = c(18,19,20), sample_id = 3) plot_chrom(main, ncol = 3, transitions_ids = c(18,19,20), sample_id = 3) plot_chrom(main, ncol = 1, transitions_ids = c(18,19,20), sample_id = 3) plot_chrom(main, ncol = NULL, transitions_ids = c(18,19,20), sample_id = 3) ## End(Not run)## Not run: path <- system.file("extdata", "waters_raw_ex", package="PKbioanalysis") main <- read_chrom(path, method = 1) plot_chrom(main, ncol = 2, transitions_ids = c(18,19,20), sample_id = 3) plot_chrom(main, ncol = 3, transitions_ids = c(18,19,20), sample_id = 3) plot_chrom(main, ncol = 1, transitions_ids = c(18,19,20), sample_id = 3) plot_chrom(main, ncol = NULL, transitions_ids = c(18,19,20), sample_id = 3) ## End(Not run)
Plot peak areas
plot_peak_areas.PeakRes( peaks_res, normalize = TRUE, blanks = TRUE, compounds = NULL, analytes = TRUE, standards = TRUE, QCs = TRUE, type = "bar" )plot_peak_areas.PeakRes( peaks_res, normalize = TRUE, blanks = TRUE, compounds = NULL, analytes = TRUE, standards = TRUE, QCs = TRUE, type = "bar" )
peaks_res |
PeakRes object |
normalize |
logical. If TRUE, normalize the peak area by the IS area. |
blanks |
logical. If TRUE, plot blanks |
compounds |
numeric vector of compound numbers to include. If NULL, include all compounds |
analytes |
logical. If TRUE, plot analytes |
standards |
logical. If TRUE, plot standards |
QCs |
logical. If TRUE, plot QCs |
type |
character. Either "bar" or "line" |
ggplot2 object
Plotting RT intervals of chromatogram
plot_RT.ChromRes(chrom_res)plot_RT.ChromRes(chrom_res)
chrom_res |
ChromRes object |
Plot RT
plot_RT.PeakRes( peaks_res, normalize = TRUE, blanks = TRUE, analytes = TRUE, standards = TRUE, QCs = TRUE, facet = FALSE, compounds = NULL )plot_RT.PeakRes( peaks_res, normalize = TRUE, blanks = TRUE, analytes = TRUE, standards = TRUE, QCs = TRUE, facet = FALSE, compounds = NULL )
peaks_res |
PeakRes object |
normalize |
logical. If TRUE, normalize the peak area by the IS area. |
blanks |
logical. If TRUE, plot blanks |
analytes |
logical. If TRUE, plot analytes |
standards |
logical. If TRUE, plot standards |
QCs |
logical. If TRUE, plot QCs |
facet |
logical. If TRUE, facet by compound name |
compounds |
numeric vector of compound numbers to include. If NULL, include all compounds |
ggplot2 object
Plot Relationship Between Concentration and CV/SD
plot_var_pattern(df, title = "")plot_var_pattern(df, title = "")
df |
Data frame with columns: stdconc (standardized concentration), cv (coefficient of variation), sdev (standard deviation), Type (e.g., "Estimated", "Observed") |
title |
Plot title |
Omar I. Elashkar
Plotting 96 well plate
## S3 method for class 'PlateObj' plot( x, color = "conc", Instrument = "", caption = "", label_size = 1, transform_dil = FALSE, watermark = "auto", layoutOverlay = FALSE, path = NULL, ... )## S3 method for class 'PlateObj' plot( x, color = "conc", Instrument = "", caption = "", label_size = 1, transform_dil = FALSE, watermark = "auto", layoutOverlay = FALSE, path = NULL, ... )
x |
PlateObj |
color |
character. Coloring variable. Choices: "conc", "group", "dil", "study", "time", "factor", "samples", "arm", "sex", "dose", "route", "matrix". Default is "conc" |
Instrument |
A string placed at subtitle |
caption |
A string place at plate caption |
label_size |
numeric. Size of the label. Default is 15 |
transform_dil |
logical. If TRUE, transform the dilution factor to the label |
watermark |
character. If "auto", a watermark is added to the plot. If "none", no watermark is added. Default is "auto" |
layoutOverlay |
logical. If TRUE, overlay the plot layout. Default is FALSE |
path |
If not null, must be a path to save plate image |
... |
additional arguments passed to ggplot2::ggsave |
ggplot object
plate <- generate_96("new_plate", "C", 11) |> add_blank(IS = FALSE, analyte = FALSE) |> add_blank(IS = TRUE, analyte = FALSE) |> add_samples(c( "RD_per1", "RD_in1", "RD_T30", "RD_T60", "RD_T90", "RD_per2", "RD_in2", "EE_in0", "EE_T30", "EE_in30", "EE_T60", "EE_in60", "EE_T90", "EE_in90" )) plot(plate)plate <- generate_96("new_plate", "C", 11) |> add_blank(IS = FALSE, analyte = FALSE) |> add_blank(IS = TRUE, analyte = FALSE) |> add_samples(c( "RD_per1", "RD_in1", "RD_T30", "RD_T60", "RD_T90", "RD_per2", "RD_in2", "EE_in0", "EE_T30", "EE_in30", "EE_T60", "EE_in60", "EE_T90", "EE_in90" )) plot(plate)
Precision per vial
precision_per_vial(peaks_res, suitability = FALSE)precision_per_vial(peaks_res, suitability = FALSE)
peaks_res |
PeakRes object |
suitability |
logical. If TRUE, suitability samples are ignored |
ggplot2 object
Filter data
prefilter_precision_data( x, type, acc_cutoff = 0.2, dev_cutoff = 0.2, compound_id = NULL ) ## S4 method for signature 'QuantRes' prefilter_precision_data( x, type, acc_cutoff = 0.2, dev_cutoff = 0.2, compound_id = NULL ) ## S4 method for signature 'data.frame' prefilter_precision_data(x, type, acc_cutoff = 0.2, dev_cutoff = 0.2)prefilter_precision_data( x, type, acc_cutoff = 0.2, dev_cutoff = 0.2, compound_id = NULL ) ## S4 method for signature 'QuantRes' prefilter_precision_data( x, type, acc_cutoff = 0.2, dev_cutoff = 0.2, compound_id = NULL ) ## S4 method for signature 'data.frame' prefilter_precision_data(x, type, acc_cutoff = 0.2, dev_cutoff = 0.2)
x |
Dataframe or QuantRes Object |
type |
QC, DQC, or Standard |
acc_cutoff |
Accuracy cutoff. 20% by default |
dev_cutoff |
Deviation cutoff. 20% by default |
compound_id |
Compound ID to filter. If NULL, all compounds are considered |
Filtered data
Omar I. Elashkar
This function creates a shiny app for quantification after peak integration
quant_app()quant_app()
This function reads chromatogram files from a directory and returns a data frame with the chromatogram data.
read_chrom(dir, format = "waters_raw", method)read_chrom(dir, format = "waters_raw", method)
dir |
directory for chromatraograms |
format |
format of the chromatogram files. Options are "waters_raw" and "mzML". |
method |
LC-MS/MS method ID saved available in the database. |
## Not run: path <- system.file("extdata", "waters_raw_ex", package="PKbioanalysis") main <- read_chrom(path, method = 1) ## End(Not run)## Not run: path <- system.file("extdata", "waters_raw_ex", package="PKbioanalysis") main <- read_chrom(path, method = 1) ## End(Not run)
Read experiment results
read_experiment_results( x, drop_prefix = FALSE, vendor = "targetlynx_xml", logkey = "Index" )read_experiment_results( x, drop_prefix = FALSE, vendor = "targetlynx_xml", logkey = "Index" )
x |
path to experiment results. See details |
drop_prefix |
logical. If TRUE, drop the prefix from the sample name |
vendor |
vendor name. Currently only "targetlynx_xml" or "targetlynx_csv" are supported. |
logkey |
character. The column name in the targetlynx CSV file that contains the injection sequence or log key. Default is "Index" which is the default column in targetlynx CSV exports, but it can be customized if the user has a different column name for the injection sequence. |
Currently only targetlynx XML or CSV exported files are supported.
QuantRes object with the results of the experiment.
This will save the plate to the database
register_plate(plate)register_plate(plate)
plate |
PlateObj object or MultiPlate object |
PlateObj object or list of PlateObj objects
Convert response to concentration
response_to_conc(quantres, compound_id, response)response_to_conc(quantres, compound_id, response)
quantres |
QuantRes object |
compound_id |
character |
response |
numeric. Must match the response type used in linearity. Either abs_response or rel_response |
numeric
Reverse predict concentration from response
reverse_predict(fit, newdata, intercept)reverse_predict(fit, newdata, intercept)
fit |
lm object |
newdata |
vector or data frame with response values |
intercept |
logical. Whether the model has intercept or not |
numeric. Estimated concentration
Omar I. Elashkar
Get Summary of an object
run_summary(object) ## S3 method for class 'PeakRes' run_summary(object)run_summary(object) ## S3 method for class 'PeakRes' run_summary(object)
object |
A PeakRes object |
This function smooths chromatogram peaks using different algorithms.
smooth_chrom(chrom_res, filter = "mean", window = 2, iter = 2)smooth_chrom(chrom_res, filter = "mean", window = 2, iter = 2)
chrom_res |
ChromRes object |
filter |
Filter to use. Options are "mean", "median", "savgol", "gaussian" |
window |
Window size for the filter |
iter |
Number of iterations. If 0, no smoothing is applied. |
This function creates a shiny app for plate management
study_app()study_app()
A shiny app. No default return value. Can return a PlateObj if reuse_plate_button is clicked
Update RT for either all compounds, all next samples, or single compound and sample
update_RT( chrom_res, compound_id, sample_id = NULL, peak_start, peak_end, mode = "auto", target = "single", force = FALSE, comment = "", flag = FALSE )update_RT( chrom_res, compound_id, sample_id = NULL, peak_start, peak_end, mode = "auto", target = "single", force = FALSE, comment = "", flag = FALSE )
chrom_res |
ChromRes object |
compound_id |
Compound ID |
sample_id |
Sample ID (required for "single" and "all_next", must be NULL for "all") |
peak_start |
Minimum RT value |
peak_end |
Maximum RT value |
mode |
Mode of update. Options are "auto", "manual", "ai". Default is "auto" |
target |
Target of update. Options are "single", "all", "all_next". Default is "single" |
force |
Force update if previous peak exists. Default is FALSE |
comment |
Comment for the update. Default is an empty string |
flag |
Flag the peak after update. Default is FALSE |
- target = "single": Updates RT for one compound and sample - target = "all": Updates expected RT for all samples (sets expected bounds) - target = "all_next": Updates RT for specified sample and subsequent samples
All modes affect both observed and expected RT values: - "manual": Sets exact peak bounds, marks as manual - "auto": Auto-detects peaks within bounds - "ai": AI-based peak detection
Updated ChromRes object
## Not run: update_RT(chrom_res, compound_id = 1, sample_id = 1, peak_start = 0.1, peak_end = 1, target = "single") ## End(Not run)## Not run: update_RT(chrom_res, compound_id = 1, sample_id = 1, peak_start = 0.1, peak_end = 1, target = "single") ## End(Not run)
Write injection sequence to database
write_injec_seq(injec_seq)write_injec_seq(injec_seq)
injec_seq |
InjecListObj object |
dataframe