Skip to contents

Generates an HTML report from an AlphaVarSet object.

Usage

av_create_report(
  obj,
  output_file = "AlphaVaR_Report.html",
  open = TRUE,
  custom_template = NULL,
  top_n_genes = NULL
)

Arguments

obj

An AlphaVarSet object.

output_file

Path where the HTML file should be saved.

open

Logical. Open the file in the browser after creating? Only takes effect in an interactive session.

custom_template

One of: NULL (default spec); an AlphaVarReportSpec object; a path to a .yaml/.yml spec file; or a path to a .Rmd/.rmd file for direct rendering. See Details for the behaviour of each mode.

top_n_genes

Integer, or NULL (default) to keep the number of genes the template itself declares. A number overrides every gene_deep_dive block. Passed as-is for .Rmd passthrough; ignored for spec/YAML templates.

Value

The path to the created file (invisibly).

Details

The custom_template parameter supports four modes:

NULL (default)

Builds the report from the default spec (av_report_template_default(), which has auto_compute = TRUE). Missing enrichment stats are computed automatically, so no prior call to av_calc_*() is required. A non-NULL top_n_genes overrides every gene_deep_dive block.

AlphaVarReportSpec object

Validates the spec and renders via the modular engine (report_modular.Rmd). Missing stats cause a hard error unless the spec carries auto_compute = TRUE.

YAML file (.yaml / .yml)

Loads an AlphaVarReportSpec from disk and renders via the modular engine. The same auto-compute/hard-error contract applies.

Rmd file (.Rmd / .rmd)

Renders the supplied Rmd directly with params = list(obj = obj, top_n_genes = top_n_genes). No spec validation is performed.

Examples

example_file <- system.file("extdata", "bcl11a_rs1427407_example.csv",
                            package = "AlphaVaR")
obj <- av_import_csv(example_file)
#> Reading bcl11a_rs1427407_example.csv ...

# The NULL default renders av_report_template_default(), whose
# auto_compute = TRUE computes every stat a block needs during the render.
spec <- av_report_template_default()
length(spec$blocks)
#> [1] 27

# open = FALSE leaves the browser closed, and tempdir() keeps the figure
# directory knitr creates out of the working directory.
report_path <- av_create_report(
  obj,
  output_file = file.path(tempdir(), "bcl11a_report.html"),
  open = FALSE
)
#> Rendering modular report to: /tmp/RtmpZ7Nxif/bcl11a_report.html
file.exists(report_path)
#> [1] TRUE