Skip to contents

Update cognostics on curve_summary based on the cognostics parameters given by cog_df. We assume cog_df is created manually

Usage

update_cog_manual(
  curve_summary,
  dilution_summary = lifecycle::deprecated(),
  cog_df = NULL,
  col_name_vec = "col_name_vec",
  desc_vec = "desc_vec",
  type_vec = "type_vec"
)

Arguments

curve_summary

The summary data frame or tibble generated by function summarise_curve_table() and/or evaluate_linearity().

dilution_summary

[Deprecated] dilution_summary was renamed to curve_summary.

cog_df

A data frame or tibble that contains cognostics information If no input is given the cognostics information generated by function create_default_cog_df() will be used. Default: NULL

col_name_vec

Column name in cog_df to indicate the columns in curve_summary that needs to be converted to a cognostics. Default: 'col_name_vec'

desc_vec

Column name in cog_df to indicate the description for each cognostics as define in trelliscopejs::cog. Default: 'desc_vec'

type_vec

Column name in cog_df to indicate the type of each cognostics as define in trelliscopejs::cog. Default: 'type_vec'

Value

curve_summary with some columns converted to type cog as defined in trelliscopejs::cog.

Details

More details in trelliscopejs::cog can be found in https://rdrr.io/cran/trelliscopejs/man/cog.html.

Examples


# 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
)

# Create curve table
curve_table <- 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"
)

# Create curve statistical summary
curve_summary <- curve_table |>
  summarise_curve_table(
    grouping_variable = c(
      "Curve_Name",
      "Curve_Batch_Name"
    ),
    conc_var = "Concentration",
    signal_var = "Signal"
  ) |>
  dplyr::arrange(.data[["Curve_Name"]]) |>
  evaluate_linearity(grouping_variable = c(
    "Curve_Name",
    "Curve_Batch_Name"
  ))

# Create our own cog_df
col_name_vec <- c(
  "Curve_Name", "Curve_Batch_Name",
  "Curve_Class"
)

desc_vec <- c(
  "Curve_Name", "Curve_Batch_Name",
  "Curve_Class"
)

type_vec <- c("factor", "factor", "factor")

cog_df <- data.frame(
  col_name_vec = col_name_vec,
  desc_vec = desc_vec,
  type_vec = type_vec
)

updated_summary <- update_cog_manual(
  curve_summary,
  cog_df,
  col_name_vec = "col_name_vec",
  desc_vec = "desc_vec",
  type_vec = "type_vec"
)
#> Warning: The `dilution_summary` argument of `update_cog_manual()` is deprecated as of
#> lancer 0.0.6.9000.
#>  Please use the `curve_summary` argument instead.

# Observe that the first two columns has been converted
# to class cognostics
curve_summary
#> # A tibble: 8 × 11
#>   Curve_Name Curve_Bat…¹ wf1_g…² wf2_g…³ r_corr pra_l…⁴ mande…⁵ concav…⁶ r2_li…⁷
#>   <chr>      <chr>       <chr>   <chr>    <dbl>   <dbl>   <dbl>    <dbl>   <dbl>
#> 1 Curve_1    B1          Poor L… Satura…  0.963    70.5 2.97e-5 -4.17e+3  0.928 
#> 2 Curve_1    B2          Poor L… Satura…  0.950    62.3 1.66e-4 -4.14e+3  0.903 
#> 3 Curve_2    B1          Good L… Good L…  0.990    92.8 1.50e-1 -4.91e+0  0.980 
#> 4 Curve_2    B2          Good L… Good L…  0.995    94.3 3.82e-1 -1.94e+0  0.990 
#> 5 Curve_3    B1          Poor L… Noise …  0.964    71.2 6.78e-6  4.68e-1  0.930 
#> 6 Curve_3    B2          Poor L… Noise …  0.978    74.7 2.56e-3  3.21e-1  0.956 
#> 7 Curve_4    B1          Poor L… Poor L…  0.311  -251.  6.60e-3 -2.05e+1  0.0970
#> 8 Curve_4    B2          Poor L… Poor L…  0.608   -73.1 5.33e-2 -2.29e+1  0.370 
#> # … with 2 more variables: r2_adj_linear <dbl>, mandel_stats <dbl>, and
#> #   abbreviated variable names ¹​Curve_Batch_Name, ²​wf1_group, ³​wf2_group,
#> #   ⁴​pra_linear, ⁵​mandel_p_val, ⁶​concavity, ⁷​r2_linear

updated_summary
#>       col_name_vec         desc_vec type_vec
#> 1       Curve_Name       Curve_Name   factor
#> 2 Curve_Batch_Name Curve_Batch_Name   factor
#> 3      Curve_Class      Curve_Class   factor