## ----include = [encoded data, 9983 characters]
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----load-greatR, [encoded data, 9980 characters]
# Load the package
library(greatR)
library(data.table)

## ----brapa-data, message=FALSE, [encoded data, 9966 characters]
# Load a data frame from the sample data
b_rapa_data <- system.file("extdata/brapa_arabidopsis_data.csv", package = "greatR") |>
  data.table::fread()

## ----reg-data-manual, echo=FALSE, fig.align='center', out.width='65%'[encoded data, 9929 characters]
knitr::include_graphics("figures/registration_params_table.png")

## ----get-subset-data, message=FALSE, [encoded data, 9961 characters]
gene_BRAA03G023790.3C_data <- b_rapa_data[gene_id == "BRAA03G023790.3C"]

## ----get-approximate, message=FALSE, [encoded data, 9961 characters]
get_approximate_stretch(
  gene_BRAA03G023790.3C_data,
  reference = "Ro18",
  query = "Col0"
)

## ----register-subset-data, message=FALSE, [encoded data, 9956 characters]
registration_results <- register(
  gene_BRAA03G023790.3C_data,
  reference = "Ro18",
  query = "Col0",
  scaling_method = "z-score",
  stretches = 2.25,
  shifts = -4.36,
  use_optimisation = FALSE
)
#> ── Validating input data ───────────────────────────────────────────────────────
#> ℹ Will process 1 gene.
#> ℹ Using estimated standard deviation, as no `exp_sd` was provided.
#> ℹ Using `scaling_method` = "z-score".
#>
#> ── Starting manual registration ────────────────────────────────────────────────
#> ℹ Using `overlapping_percent` = 50% as a registration criterion.
#> ✔ Applying registration for genes (1/1) [38ms]

## ----get-model-summary-data, [encoded data, 9969 characters]
registration_results$model_comparison |>
  knitr::kable()

## ----register-multiple-gene-manual, message=FALSE, warning=FALSE, [encoded data, 9932 characters]
# registration_results <- register(
#   gene_BRAA03G023790.3C_data,
#   reference = "Ro18",
#   query = "Col0",
#   scaling_method = "z-score",
#   stretches = seq(1, 3, 0.1),
#   shifts = seq(0, 4, 0.1),
#   use_optimisation = FALSE
# )
# #> ── Validating input data ───────────────────────────────────────────────────────
# #> ℹ Will process 1 gene.
# #> ℹ Using estimated standard deviation, as no `exp_sd` was provided.
# #> ℹ Using `scaling_method` = "z-score".
# #>
# #> ── Starting manual registration ────────────────────────────────────────────────
# #> ℹ Using `overlapping_percent` = 50% as a registration criterion.
# #> ✔ Applying registration for genes (1/1) [1.3s]

