Query a Variant Call Format (VCF) file. The VCF file can be either local or remote.
Usage
query_vcf(
target_path,
target_index = paste0(target_path, ".tbi"),
target_genome = "GRCh37",
query_granges,
samples = character(),
method = c("variantannotation", "conda", "rtracklayer", "seqminer"),
overlapping_only = FALSE,
query_save = TRUE,
save_path = construct_vcf_path(target_path = target_path, query_granges =
query_granges),
force_new = FALSE,
as_datatable = FALSE,
cleanup_tbi = TRUE,
conda_env = "echoR_mini",
verbose = TRUE
)Arguments
- target_path
Path to local VCF file or remote URL.
- target_index
Tabix index file for
target_path.- target_genome
Genome build of the VCF file.
- query_granges
GRanges object to be used for querying the
target_pathfile. Alternatively, can be variant-level summary statistics to be converted into a GRanges object by construct_query.- samples
[Optional] Sample names to subset the VCF by. If this option is used, the GRanges object will be converted to a ScanVcfParam for usage by readVcf.
- method
Method to query VCF with.
- overlapping_only
Remove variants that do not overlap with the positions in
query_dat.- query_save
Whether to save the results of the query on disk. Note: Writing to disk can take some time.
- save_path
File path to save query subset to (as VCF).
- force_new
Force the creation of a new VCF subset file even if one exists.
- as_datatable
Return the VCF subset file as a data.table (using vcf_to_dt). If
save_path=TRUEthe file will still be saved as a bgzip-compressed VCF file.- cleanup_tbi
Remove local copies of tabix index file (.tbi) after completing queries.
- conda_env
Conda environments to search in. If
NULL(default), will search all conda environments.- verbose
Print messages.
Value
VCF object,
or data.table (when as_datatable=TRUE).
See also
Other tabix functions:
construct_tabix_path(),
construct_vcf_path(),
convert(),
index,
query_table(),
read_bgz(),
run_bgzip()
Examples
if (FALSE) { # \dontrun{
query_dat <- echodata::BST1
target_path <- system.file("extdata", "BST1.1KGphase3.vcf.bgz",
package = "echodata")
#### Import ####
vcf <- query_vcf(
query_granges = query_dat,
target_path = target_path)
} # }