Filter the data in an AlphaVarSet while tracking filter history and clearing stale statistics. This enables dynamic drill-down analysis.
Arguments
- obj
An
AlphaVarSetobject.- ...
Filter expressions passed to
dplyr::filter().- .description
Optional character string describing this filter step (for breadcrumb display).
Value
A new AlphaVarSet object with:
Filtered
dataCleared
statsslot (to prevent stale statistics)Updated
meta$filter_historywith the filter breadcrumb
Details
This function is the core "scalpel" for the dynamic exploration engine. Each call creates a new subset and records the filter in the history, allowing users to trace their analysis path.
Statistics are intentionally cleared because global stats computed on the
full dataset would be misleading when applied to a subset. Use
av_calc_enrichment() after subsetting to compute fresh statistics.
Examples
example_file <- system.file("extdata", "bcl11a_rs1427407_example.csv",
package = "AlphaVaR")
obj <- av_import_csv(example_file)
#> Reading bcl11a_rs1427407_example.csv ...
atac <- av_subset(obj, output_type == "ATAC", .description = "ATAC tracks")
nrow(atac$data)
#> [1] 320
# The score column is metadata, so inject it instead of naming it literally.
sc <- obj$meta$active_score
strong_atac <- av_subset(atac, !!rlang::sym(sc) > 0.9,
.description = "quantile > 0.9")
nrow(strong_atac$data)
#> [1] 97
av_get_filter_history(strong_atac)
#> # A tibble: 2 × 5
#> step description n_before n_after timestamp
#> <dbl> <chr> <int> <int> <dttm>
#> 1 1 ATAC tracks 2676 320 2026-08-14 20:02:35
#> 2 2 quantile > 0.9 320 97 2026-08-14 20:02:35