Builds a declarative filter specification for use with extract_variant_set. The spec encodes filtering rules (QC, variant type, annotation masks, MAF) without accessing data.

variant_filter(
  qc_label = "annotation/filter",
  qc_pass_value = "PASS",
  variant_type = "SNV",
  annotation_clauses = NULL,
  rare_maf_cutoff = 0.01,
  min_mac = 1L,
  min_variants = 2L
)

Arguments

qc_label

Character GDS node path for QC status. Default "annotation/filter". A variant whose value in this node is missing does not pass: SeqArray::seqVCF2GDS() stores a VCF FILTER of "." (filters not applied) as NA, and such variants are excluded like any other non-passing variant. A GDS without the node passes every variant.

qc_pass_value

Character value that passes QC. Default "PASS".

variant_type

Character: "SNV", "Indel", or "variant" (both). Default "SNV".

annotation_clauses

List of clauses in DNF form. Each clause is a named list of field = condition terms (AND-ed within a clause); clauses are OR-ed together. A condition is either an atomic vector of accepted values (set membership, e.g. "GENCODE.Category" = c("UTR3", "UTR5")) or a predicate built with annotation_predicate for tests membership cannot express: non-empty / empty fields (annotation_predicate("nonempty")) and numeric comparisons (annotation_predicate("gt", 20)). NULL means no annotation filtering.

rare_maf_cutoff

Numeric MAF ceiling. Variants with MAF > this are excluded. Default 0.01.

min_mac

Integer minimum cohort minor allele count. Variants with cohort-MAC < min_mac are excluded. Default 1 — variants that are monomorphic in the analysis cohort are excluded because they carry no information for any association test. Set to 0 only if you have a specific reason to retain MAC=0 variants (rare).

min_variants

Integer minimum variants after filtering to proceed. Default 2.

Value

A glow_variant_filter S3 object.

Examples

# Default filter: rare SNVs passing QC
spec <- variant_filter()
spec
#> GLOWr Variant Filter Specification
#>   Variant type: SNV 
#>   MAF cutoff: 0.01 
#>   Min MAC: 1 
#>   Min variants: 2 
#>   Annotation filter: none (all passing variants)

# Custom annotation filter in DNF form (plof_ds equivalent):
# stopgain OR stoploss OR splicing OR (nonsynonymous AND MetaSVM=="D")
spec_custom <- variant_filter(
  annotation_clauses = list(
    list("GENCODE.EXONIC.Category" = "stopgain"),
    list("GENCODE.EXONIC.Category" = "stoploss"),
    list("GENCODE.Category" = "splicing"),
    list("GENCODE.EXONIC.Category" = "nonsynonymous SNV", "MetaSVM" = "D")
  ),
  rare_maf_cutoff = 0.01
)

# All rare variants (SNV + Indel), no annotation filter
spec_all <- variant_filter(variant_type = "variant", rare_maf_cutoff = 0.05)

# Predicates beyond set membership: nonsynonymous SNVs with CADD PHRED > 20,
# OR any variant inside a GeneHancer element (non-empty field)
spec_pred <- variant_filter(
  annotation_clauses = list(
    list("GENCODE.EXONIC.Category" = "nonsynonymous SNV",
         "CADD" = annotation_predicate("gt", 20)),
    list("GeneHancer" = annotation_predicate("nonempty"))
  ),
  rare_maf_cutoff = 0.5
)