The same workflow in README can be rewritten as a Tidyverse workflow
library(lancer)
# Data Creation
concentration <- c(
10, 20, 25, 40, 50, 60,
75, 80, 100, 125, 150,
10, 25, 40, 50, 60,
75, 80, 100, 125, 150
)
curve_batch_name <- c(
"B1", "B1", "B1", "B1", "B1",
"B1", "B1", "B1", "B1", "B1", "B1",
"B2", "B2", "B2", "B2", "B2",
"B2", "B2", "B2", "B2", "B2"
)
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",
"Sample_010b", "Sample_025b",
"Sample_040b", "Sample_050b", "Sample_060b",
"Sample_075b", "Sample_080b", "Sample_100b",
"Sample_125b", "Sample_150b"
)
curve_1_saturation_regime <- c(
5748124, 16616414, 21702718, 36191617,
49324541, 55618266, 66947588, 74964771,
75438063, 91770737, 94692060,
5192648, 16594991, 32507833, 46499896,
55388856, 62505210, 62778078, 72158161,
78044338, 86158414
)
curve_2_good_linearity <- c(
31538, 53709, 69990, 101977, 146436, 180960,
232881, 283780, 298289, 344519, 430432,
25463, 63387, 90624, 131274, 138069,
205353, 202407, 260205, 292257, 367924
)
curve_3_noise_regime <- c(
544, 397, 829, 1437, 1808, 2231,
3343, 2915, 5268, 8031, 11045,
500, 903, 1267, 2031, 2100,
3563, 4500, 5300, 8500, 10430
)
curve_4_poor_linearity <- c(
380519, 485372, 478770, 474467, 531640, 576301,
501068, 550201, 515110, 499543, 474745,
197417, 322846, 478398, 423174, 418577,
426089, 413292, 450190, 415309, 457618
)
curve_batch_annot <- tibble::tibble(
Sample_Name = sample_name,
Curve_Batch_Name = curve_batch_name,
Concentration = concentration
)
curve_data <- tibble::tibble(
Sample_Name = sample_name,
`Curve_1` = curve_1_saturation_regime,
`Curve_2` = curve_2_good_linearity,
`Curve_3` = curve_3_noise_regime,
`Curve_4` = curve_4_poor_linearity
)
curve_name <- c("Curve_1", "Curve_2", "Curve_3", "Curve_4")
curve_class <- c("Class_1", "Class_1", "Class_2", "Class_2")
curve_name_annot <- tibble::tibble(
Curve_Name = curve_name,
Curve_Class = curve_class
)
# Create curve table and curve statistical summary
curve_summary <- lancer::create_curve_table(
curve_batch_annot = curve_batch_annot,
curve_data_wide = curve_data,
common_column = "Sample_Name",
signal_var = "Signal",
column_group = "Curve_Name"
) |>
lancer::summarise_curve_table(
grouping_variable = c(
"Curve_Name",
"Curve_Batch_Name"
),
conc_var = "Concentration",
signal_var = "Signal"
) |>
lancer::evaluate_linearity(grouping_variable = c(
"Curve_Name",
"Curve_Batch_Name"
)) |>
dplyr::left_join(curve_name_annot, by = "Curve_Name")
print(curve_summary, width = 100)
#> # A tibble: 8 × 12
#> Curve_Name Curve_Batch_Name wf1_group wf2_group r_corr pra_linear
#> <chr> <chr> <chr> <chr> <dbl> <dbl>
#> 1 Curve_1 B1 Poor Linearity Saturation Regime 0.963 70.5
#> 2 Curve_2 B1 Good Linearity Good Linearity 0.990 92.8
#> 3 Curve_3 B1 Poor Linearity Noise Regime 0.964 71.2
#> 4 Curve_4 B1 Poor Linearity Poor Linearity 0.311 -251.
#> 5 Curve_1 B2 Poor Linearity Saturation Regime 0.950 62.3
#> 6 Curve_2 B2 Good Linearity Good Linearity 0.995 94.3
#> 7 Curve_3 B2 Poor Linearity Noise Regime 0.978 74.7
#> 8 Curve_4 B2 Poor Linearity Poor Linearity 0.608 -73.1
#> mandel_p_val concavity r2_linear r2_adj_linear mandel_stats Curve_Class
#> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 0.0000297 -4174. 0.928 0.920 71.2 Class_1
#> 2 0.150 -4.91 0.980 0.978 2.53 Class_1
#> 3 0.00000678 0.468 0.930 0.922 106. Class_2
#> 4 0.00660 -20.5 0.0970 -0.00333 13.2 Class_2
#> 5 0.000166 -4137. 0.903 0.890 52.9 Class_1
#> 6 0.382 -1.94 0.990 0.988 0.868 Class_1
#> 7 0.00256 0.321 0.956 0.951 20.9 Class_2
#> 8 0.0533 -22.9 0.370 0.291 5.39 Class_2
Results can be exported to Excel via
write_summary_excel
lancer::write_summary_excel(
curve_summary = curve_summary,
file_name = "curve_summary.xlsx")