How to do it... 

Selecting and classifying variants with VariantAnnotation can be done using the following steps:

  1. Create a prefilter function:
is_not_microsat <- function(x){ !grepl("microsat", x, fixed = TRUE)}
  1. Load up the prefilter function into a FilterRules object:
prefilters <- FilterRules(list(microsat = is_not_microsat) )
  1. Create a filter function to keep variants where the reference allele is in less than half the reads:
major_alt <- function(x){
af <- info(x)$AF
result <- unlist(lapply(af, function(x){x[1] < 0.5}))
return(result)
}
  1. Load the filter function into a FilterRules object:
filters <- FilterRules(list(alt_is_major = major_alt))
  1. Load the input VCF file and apply filters:
vcf_file <- file.path(getwd(), "datasets", "ch2", "sample.vcf.gz")
filterVcf(vcf_file, "hg17", "filtered.vcf", prefilters = prefilters, filters = filters)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.17.28