Skip to contents

Get the summary statistics of each group from the curve table

Usage

summarise_curve_table(
  curve_table,
  grouping_variable = c("Curve_Name", "Curve_Batch_Name"),
  conc_var = "Concentration",
  signal_var = "Signal"
)

Arguments

curve_table

Output given from the function create_curve_table() It is in long table format with columns indicating at least the curve name, the concentration and signal. Other columns may be present if it is used to group the curves together

grouping_variable

A character vector of column names in curve_tableto indicate how each curve should be grouped by.

conc_var

Column name in curve_table to indicate concentration Default: 'Concentration'

signal_var

Column name in curve_table to indicate signal Default: 'Area'

Value

A curve summary table output from the function summarise_curve_data() for each group

Details

The function first perform tidyr::nest on curve_table based on the grouping_variable to organise the curve data for each group. Next for each group, the function summarise_curve_data() is used to get the summary statistics.

Examples

# Data Creation
concentration <- c(
  10, 20, 40, 60, 80, 100,
  10, 20, 40, 60, 80, 100
)

curve_batch_name <- c(
  "B1", "B1", "B1", "B1", "B1", "B1",
  "B2", "B2", "B2", "B2", "B2", "B2"
)

sample_name <- c(
  "Sample_010a", "Sample_020a", "Sample_040a",
  "Sample_060a", "Sample_080a", "Sample_100a",
  "Sample_010b", "Sample_020b", "Sample_040b",
  "Sample_060b", "Sample_080b", "Sample_100b"
)

curve_1_good_linearity <- c(
  22561, 31178, 39981, 48390, 52171, 53410,
  32561, 41178, 49981, 58390, 62171, 63410
)

curve_2_good_linearity <- c(
  2299075, 4136350, 7020062, 8922063, 9288742, 11365710,
  2300075, 4137350, 7021062, 8923063, 9289742, 11366710
)

curve_batch_annot <- tibble::tibble(
  Sample_Name = sample_name,
  Curve_Batch_Name = curve_batch_name,
  Concentration = concentration
)

curve_data_wide <- tibble::tibble(
  Sample_Name = sample_name,
  `Curve_1` = curve_1_good_linearity,
  `Curve_2` = curve_2_good_linearity
)

# Create curve table
curve_table <- create_curve_table(
  curve_batch_annot = curve_batch_annot,
  curve_data_wide = curve_data_wide,
  common_column = "Sample_Name",
  signal_var = "Signal",
  column_group = "Curve_Name"
)

# Give summary result for each curve grouped by Curve_Name
# and Curve_Batch_Name
curve_summary <- curve_table |>
  summarise_curve_table(
    grouping_variable = c(
      "Curve_Name",
      "Curve_Batch_Name"
    ),
    conc_var = "Concentration",
    signal_var = "Signal"
  )

print(curve_summary, width = 100)
#> # A tibble: 4 × 9
#>   Curve_Name Curve_Batch_Name r_corr r2_linear r2_adj_linear mandel_stats
#>   <chr>      <chr>             <dbl>     <dbl>         <dbl>        <dbl>
#> 1 Curve_1    B1                0.956     0.913         0.892        70.1 
#> 2 Curve_2    B1                0.972     0.946         0.932         5.67
#> 3 Curve_1    B2                0.956     0.913         0.892        70.1 
#> 4 Curve_2    B2                0.972     0.946         0.932         5.67
#>   mandel_p_val pra_linear concavity
#>          <dbl>      <dbl>     <dbl>
#> 1      0.00357       66.4     -4.09
#> 2      0.0974        74.8   -735.  
#> 3      0.00357       66.4     -4.09
#> 4      0.0974        74.8   -735.