Skip to contents

View ggplot or plotly curve plots in a trelliscope html report

Usage

view_trellis_html(
  trellis_table,
  trellis_report_name = "Curve_Plot",
  trellis_report_folder = "Curve_Plot",
  grouping_variable = c("Curve_Name", "Curve_Batch_Name"),
  panel_variable = "panel",
  trellis_additional_labels = c(),
  testing = FALSE
)

Arguments

trellis_table

The trellis table generated by function add_ggplot_panel() and convert_to_cog() or add_plotly_panel() and convert_to_cog()

trellis_report_name

A string to indicate the title of the trellis report Default: 'Curve_Plot'

trellis_report_folder

A string to indicate the output folder of the plots found in panel_variable Default: 'Curve_Plot'

grouping_variable

A character vector of column names in trellis_table to indicate how each curve should be grouped by. It is also going to be used as a conditional cognostics in the trelliscopejs report. The function will check if these columns are indeed conditional cognostics Default: c("Curve_Name", "Curve_Batch_Name")

panel_variable

A column name in trellis_table to indicate the list of plots to be used in the trelliscopejs report. This column name must be fixed to the name panel and it must be of class trelliscope_panels Default: 'panel'

trellis_additional_labels

A character vector of columns names in trellis_table to display in the trellis report in addition to the conditional cognostics in the grouping varaible, Default: c()

testing

To indicate if we are running a test, if so, no trellis report is given out Default: FALSE

Examples

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_data <- tibble::tibble(
  Sample_Name = sample_name,
  `Curve_1` = curve_1_good_linearity,
  `Curve_2` = curve_2_good_linearity
)

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

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

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

# Add a plotly panel without curve summary
trellis_table <- add_plotly_panel(
  curve_table,
  grouping_variable = c("Curve_Name",
                        "Curve_Batch_Name"),
  sample_name_var = "Sample_Name",
  curve_batch_var = "Curve_Batch_Name",
  conc_var = "Concentration",
  conc_var_units = "%",
  conc_var_interval = 50,
  signal_var = "Signal"
  ) |>
  convert_to_cog(
    cog_df = NULL,
    grouping_variable = c(
      "Curve_Name",
      "Curve_Batch_Name"
    ),
    panel_variable = "panel",
    col_name_vec = "col_name_vec",
    desc_vec = "desc_vec",
    type_vec = "type_vec"
  )

# Create a trellis report, set testing = FALSE to output results
view_trellis_html(trellis_table, testing = TRUE)