## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)

## ----load-package-------------------------------------------------------------
library(BenchHub)
library(readr)
library(dplyr)
library(stringr)

## ----load-result--------------------------------------------------------------
result_path <- system.file("extdata", "spatialsimbench_result.csv", package = "BenchHub")
spatialsimbench_result <- read_csv(result_path)
glimpse(spatialsimbench_result)

## ----create-bmi---------------------------------------------------------------
bmi <- BenchmarkInsights$new(spatialsimbench_result)
bmi

## ----addeval------------------------------------------------------------------
add_result <- data.frame(
  datasetID = rep("BREAST", 9),
  method = c(
    "scDesign2", "scDesign3_gau", "scDesign3_nb", "scDesign3_poi",
    "SPARsim", "splatter", "SRTsim", "symsim", "zinbwave"
  ),
  evidence = rep("svg", 9),
  metric = rep("recall", 9),
  result = c(
    0.921940928, 0.957805907, 0.964135021, 0.989451477, 0.774261603,
    0.890295359, 0.985232068, 0.067510549, 0.888185654
  ),
  stringsAsFactors = FALSE
)

bmi$addevalSummary(add_result)

## ----addmeta------------------------------------------------------------------
metadata_srtsim <- data.frame(
  method = "SRTsim",
  year = 2023,
  packageVersion = "0.99.6",
  parameterSetting = "default",
  spatialInfoReq = "No",
  DOI = "10.1186/s13059-023-02879-z",
  stringsAsFactors = FALSE
)

bmi$addMetadata(metadata_srtsim)

## ----heatmap, fig.width = 10, fig.height = 8, fig.cap = "Fig.1 Heatmap of benchmarking performance across simulation methods and evaluation metrics. Each row corresponds to a simulation method and each column to an evaluation criterion. The size and colour of the circles represent the normalised metric values (scaled to [0, 1])."----
bmi$getHeatmap()

## ----corplot, fig.cap = "Fig.2 Correlation plot illustrating relationships among evaluation metrics across different methods. Correlation coefficients are computed based on benchmarking results, with colour intensity indicating the strength and direction of association."----
bmi$getCorplot(input_type = "method")

## ----scatterplot, fig.cap = "Fig.3 Scatter plot illustrating the relationship between recall and precision across methods. Each point represents a method, with positions reflecting its performance on the two metrics."----
bmi$getScatterplot(variables = c("recall", "precision"))

## ----lineplot, fig.cap = "Fig.4 Line plot illustrating memory usage across increasing data complexity for different methods. Each line represents a method, showing how memory consumption scales under varying conditions."----
bmi$getLineplot(metricVariable = "memory")

## ----forestplot, fig.cap = "Fig.5 Forest plot of regression coefficients estimating the influence of evaluation metrics on method performance. The vertical line at zero indicates no difference relative to the reference method; larger absolute coefficients indicate stronger metric-specific discrimination between methods."----
bmi$getForestplot(input_group = "metric", input_model = "method")

## ----boxplot, fig.cap = "Fig.6 Boxplot showing the distribution of KDEstat values across simulation methods under the selected evidence setting. Differences in spread reflect variability and stability of method performance across datasets."----
bmi$getBoxplot(metricVariable = "KDEstat", evidenceVariable = "scaledVar")

## ----session-info-------------------------------------------------------------
sessionInfo()

