Description Details Accessor methods Constructors Subsetting and Replacement Combining Evaluating Author(s) See Also Examples
The VcfFixedRules
and VcfInfoRules
classes
store filters applicable to the fixed
and info
slots
of VCF
objects, respectively.
The VcfVepRules
stores filters applicable to Ensembl VEP predictions
stores in a given INFO key.
All arguments are first passed to S4Vectors::FilterRules
before re-typing the resulting as a VcfFixedRules
, VcfInfoRules
,
or VcfVepRules
class.
In the following code snippets x
is an object from any of the classes
decribed in this help page, except when specified otherwise.
active(x)
, active(x)<-
Gets or sets the active state of each filter rule in x
.
Inherited from FilterRules
vep(x)
, vep(x)<-
Gets or sets the INFO key where the Ensembl VEP predictions
to use for filtering are stored.
Returns NA_character_
for filters not applicable to VEP predictions.
type(x)
Returns "filter"
(linkS4class{FilterRules}
),
"fixed"
(linkS4class{VcfFixedRules}
),
"info"
(linkS4class{VcfInfoRules}
),
or "vep"
(linkS4class{VcfVepRules}
)
as a character
vector of length(x)
.
VcfFixedRules(exprs = list(), ..., active = TRUE)
VcfInfoRules(exprs = list(), ..., active = TRUE)
VcfVepRules(exprs = list(), ..., active = TRUE, vep = "CSQ")
All methods construct an object of the corresponding class
with the rules given in the list exprs
or in ...
.
The initial active state of the rules is given by active
,
which is recycled as necessary.
See the constructor of FilterRules
for more details.
In the following code snippets x
and value
are objects from any of the classes described in this help page.
x[i]
: Subsets the filter rules using the same interface as for
List
.
x[[i]]
: Extracts an expression or function via the same interface
as for List
.
x[i] <- value
: Replaces a filter rule by one of the
same class.
The active state(s) and name(s) are transferred from value
to
x
.
x[[i]] <- value
:
The same interface as for List
.
The default active state for new rules is TRUE.
In the following code snippets x
, values
, and ...
are objects from any of the classes described in this help page, or
VcfFilterRules
.
append(x, values, after = length(x))
:
Appends the values onto x
at the index given by after
.
c(x, ...,)
:
Concatenates the filters objects in ...
onto the end of x
.
Note that combining rules of different types
(e.g. VcfFixedRules
and VcfVepRules
)
produces a VcfFilterRules
object.
As described in the S4Vectors
documentation:
eval(expr, envir, enclos)
:
Evaluates a rule instance (passed as the expr
argument)
in their respective context of a VCF
object
(passed as the envir
argument).
i.e.:
VcfFixedRules
: fixed(envir)
VcfInfoRules
: info(envir)
VcfVepRules
:
mcols(parseCSQToGRanges(envir, ...))
FilterRules
: envir
evalSeparately(expr, envir, enclos)
:
subsetByFilter(x, filter)
summary(object)
See eval,FilterRules,ANY-method
for details.
Kevin Rue-Albrecht
FilterRules
,
VcfFilterRules
,
and VCF
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | # Constructors ----
fixedRules <- VcfFixedRules(list(
pass = expression(FILTER == "PASS"),
qual = expression(QUAL > 20)
))
fixedRules
infoRules <- VcfInfoRules(list(
common = expression(MAF > 0.01), # minor allele frequency
alt = expression(ALT > 0) # count of alternative homozygotes
))
infoRules
vepRules <- VcfVepRules(list(
missense = expression(Consequence %in% c("missense_variant")),
CADD = expression(CADD_PHRED > 15)
))
vepRules
filterRules <- S4Vectors::FilterRules(list(
PASS = function(x) fixed(x)$FILTER == "PASS",
COMMON = function(x) info(x)$MAF > 0.05
))
filterRules
# Accessors ----
## get/set the active state directly
S4Vectors::active(infoRules)
S4Vectors::active(infoRules)["common"] <- FALSE
## See S4Vectors::FilterRules for more examples
# Example data ----
# VCF file
vcfFile <- system.file("extdata", "moderate.vcf", package = "TVTB")
# TVTB parameters
tparam <- TVTBparam(Genotypes("0|0", c("0|1", "1|0"), "1|1"))
# Pre-process variants
vcf <- VariantAnnotation::readVcf(vcfFile, param = tparam)
vcf <- VariantAnnotation::expand(vcf, row.names = TRUE)
vcf <- addOverallFrequencies(vcf)
# Applying filters to VCF objects ----
## Evaluate filters
S4Vectors::eval(fixedRules, vcf)
S4Vectors::eval(infoRules, vcf)
S4Vectors::eval(vepRules, vcf)
S4Vectors::eval(filterRules, vcf)
summary(S4Vectors::eval(vepRules, vcf))
## Evaluate filters separately
S4Vectors::evalSeparately(vepRules, vcf)
summary(S4Vectors::evalSeparately(vepRules, vcf))
## Subset VCF by filters
S4Vectors::subsetByFilter(vcf, vepRules)
# Subsetting and Replacement ----
vep1 <- vepRules[1] # VcfVepRules
vepRules[[1]] # expression
# Replace the expression (active reset to TRUE, original name retained)
vepRules[[2]] <- expression(CADD_PHRED > 30)
# Replace the rule (active state and name transferred from v5obj)
vepRules[2] <- VcfVepRules(
list(newRule = expression(CADD_PHRED > 30)),
active = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.