This function generates a lambda slope plot using pharmacokinetic data. It calculates relevant lambda parameters and visualizes the data points used for lambda calculation, along with a linear regression line and additional plot annotations.

lambda_slope_plot(
  res_pknca_df = myres$result,
  conc_pknca_df = mydata$conc$data,
  dosno = profile,
  usubjid = patient,
  R2ADJTHRESHOL = 0.7
)

Arguments

res_pknca_df

Data frame containing the results of the pharmacokinetic non-compartmental analysis (default is PKNCA::pk.nca(.)$result).

conc_pknca_df

Data frame containing the concentration data (default is mydata$conc$data).

dosno

Numeric value representing the dose number (default is profile).

usubjid

Character value representing the unique subject identifier (default is patient).

R2ADJTHRESHOL

Numeric value representing the R-squared adjusted threshold for determining the subtitle color (default is 0.7).

Value

A plotly object representing the lambda slope plot.

Details

The function performs the following steps:

  • Filters and arranges the input data to obtain relevant lambda calculation information.

  • Identifies the data points used for lambda calculation.

  • Calculates the fitness, intercept, and time span of the half-life estimate.

  • Determines the subtitle color based on the R-squared adjusted value and half-life estimate.

  • Generates a ggplot object with the relevant data points, linear regression line, and annotations.

  • Converts the ggplot object to a plotly object for interactive visualization.

Examples

if (FALSE) { # \dontrun{
  # Example usage:
  plot <- lambda_slope_plot(res_pknca_df = myres$result,
                            conc_pknca_df = mydata$conc$data,
                            dosno = 1,
                            usubjid = "subject_1",
                            R2ADJTHRESHOL = 0.7)
  plot
} # }