Plot curve using plotly
.
Usage
plot_curve_plotly(
curve_data,
title = "",
pal,
sample_name_var = "Sample_Name",
curve_batch_var = "Curve_Batch_Name",
dilution_data = lifecycle::deprecated(),
dil_batch_var = lifecycle::deprecated(),
conc_var = "Concentration",
conc_var_units = "%",
conc_var_interval = 50,
signal_var = "Signal",
plot_first_half_lin_reg = FALSE,
plot_last_half_lin_reg = FALSE
)
Arguments
- curve_data
A data frame or tibble containing curve data.
- title
Title to use for each curve plot.
- pal
Input palette for each curve batch group in
curve_batch_var
. It is a named char vector where each value is a colour and name is a curve batch group given incurve_batch_var
.- sample_name_var
Column name in
curve_data
to indicate the sample name.- curve_batch_var
Column name in
curve_data
to indicate the group name of each curve batch, used to colour the points in the curve plot.- dilution_data
- dil_batch_var
- conc_var
Column name in
curve_data
to indicate concentration.- conc_var_units
Unit of measure for
conc_var
in the curve plot.- conc_var_interval
Distance between two tick labels.
- signal_var
Column name in
curve_data
to indicate signal.- plot_first_half_lin_reg
Decide if we plot an extra regression line that best fits the first half of
conc_var
curve points. Default: FALSE- plot_last_half_lin_reg
Decide if we plot an extra regression line that best fits the last half of
conc_var
curve points. Default: FALSE
Examples
# Data Creation
concentration <- c(
10, 20, 25, 40, 50, 60,
75, 80, 100, 125, 150
)
sample_name <- c(
"Sample_010a", "Sample_020a",
"Sample_025a", "Sample_040a", "Sample_050a",
"Sample_060a", "Sample_075a", "Sample_080a",
"Sample_100a", "Sample_125a", "Sample_150a"
)
curve_batch_name <- c(
"B1", "B1", "B1", "B1", "B1",
"B1", "B1", "B1", "B1", "B1", "B1"
)
curve_1_saturation_regime <- c(
5748124, 16616414, 21702718, 36191617,
49324541, 55618266, 66947588, 74964771,
75438063, 91770737, 94692060
)
curve_data <- tibble::tibble(
Sample_Name = sample_name,
Concentration = concentration,
Signal = curve_1_saturation_regime,
Curve_Batch_Name = curve_batch_name
)
# Get the curve batch name from curve_table
curve_batch_name <- curve_batch_name |>
unique() |>
as.character()
curve_batch_col <- c("#377eb8")
# Create palette for each curve batch for plotting
pal <- curve_batch_col |>
stats::setNames(curve_batch_name)
# Plot the html
p <- plot_curve_plotly(curve_data,
title = "Curve_Saturated",
sample_name_var = "Sample_Name",
pal = pal,
curve_batch_var = "Curve_Batch_Name",
conc_var = "Concentration",
conc_var_units = "%",
conc_var_interval = 50,
signal_var = "Signal"
)
p