Here is an example when the Curve Batches and Curve Names are not sorted in alphabetical order.
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(
"B2", "B2", "B2", "B2", "B2",
"B2", "B2", "B2", "B2", "B2", "B2",
"B1", "B1", "B1", "B1", "B1",
"B1", "B1", "B1", "B1", "B1"
)
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_010a", "Sample_025a",
"Sample_040a", "Sample_050a", "Sample_060a",
"Sample_075a", "Sample_080a", "Sample_100a",
"Sample_125a", "Sample_150a"
)
curve_4_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_3_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_2_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_1_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_4` = curve_4_saturation_regime,
`Curve_3` = curve_3_good_linearity,
`Curve_2` = curve_2_noise_regime,
`Curve_1` = curve_1_poor_linearity
)
Order of the Curve_Batch_Name
and
Curve_Name
grouping variables is maintained when
summarise_curve_table
is used. No sorting is involved.
# Create curve table and 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_Batch_Name",
"Curve_Name"
),
conc_var = "Concentration",
signal_var = "Signal"
)
print(curve_summary, width = 100)
#> # A tibble: 8 × 9
#> Curve_Batch_Name Curve_Name r_corr r2_linear r2_adj_linear mandel_stats
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 B2 Curve_4 0.952 0.906 0.901 62.5
#> 2 B2 Curve_3 0.978 0.957 0.954 1.19
#> 3 B2 Curve_2 0.971 0.942 0.939 84.6
#> 4 B2 Curve_1 0.344 0.118 0.0718 5.11
#> 5 B1 Curve_4 0.949 0.9 0.894 57.0
#> 6 B1 Curve_3 0.976 0.953 0.951 1.10
#> 7 B1 Curve_2 0.969 0.940 0.936 82.2
#> 8 B1 Curve_1 0.384 0.147 0.0997 6.77
#> mandel_p_val pra_linear concavity
#> <dbl> <dbl> <dbl>
#> 1 0.000000290 65.8 -4134.
#> 2 0.290 90.2 -3.35
#> 3 0.0000000320 72.9 0.394
#> 4 0.0363 -233. -19.9
#> 5 0.000000792 64.6 -4147.
#> 6 0.308 90.0 -3.39
#> 7 0.0000000637 72.4 0.401
#> 8 0.0186 -172. -22.6
grouping variable
in evaluate_linearity
only put these variables to the front
curve_classified <- lancer::evaluate_linearity(
curve_summary = curve_summary,
grouping_variable = c(
"Curve_Batch_Name",
"Curve_Name"
)
)
print(curve_classified, width = 100)
#> # A tibble: 8 × 11
#> Curve_Batch_Name Curve_Name wf1_group wf2_group r_corr pra_linear
#> <chr> <chr> <chr> <chr> <dbl> <dbl>
#> 1 B2 Curve_4 Poor Linearity Saturation Regime 0.952 65.8
#> 2 B2 Curve_3 Good Linearity Good Linearity 0.978 90.2
#> 3 B2 Curve_2 Poor Linearity Noise Regime 0.971 72.9
#> 4 B2 Curve_1 Poor Linearity Poor Linearity 0.344 -233.
#> 5 B1 Curve_4 Poor Linearity Saturation Regime 0.949 64.6
#> 6 B1 Curve_3 Good Linearity Good Linearity 0.976 90.0
#> 7 B1 Curve_2 Poor Linearity Noise Regime 0.969 72.4
#> 8 B1 Curve_1 Poor Linearity Poor Linearity 0.384 -172.
#> mandel_p_val concavity r2_linear r2_adj_linear mandel_stats
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.000000290 -4134. 0.906 0.901 62.5
#> 2 0.290 -3.35 0.957 0.954 1.19
#> 3 0.0000000320 0.394 0.942 0.939 84.6
#> 4 0.0363 -19.9 0.118 0.0718 5.11
#> 5 0.000000792 -4147. 0.9 0.894 57.0
#> 6 0.308 -3.39 0.953 0.951 1.10
#> 7 0.0000000637 0.401 0.940 0.936 82.2
#> 8 0.0186 -22.6 0.147 0.0997 6.77