Read VCF files into a GRangesList

Share:

Description

This function reads Variant Call Format (VCF) files into a GRanges object and combines them in a GRangesList. In addition to loading the files, this function applies a seqlevel style to the GRanges objects. The default seqlevel style is "UCSC".

Usage

1
read_vcfs_as_granges(vcf_files, sample_names, genome = "-", style = "UCSC")

Arguments

vcf_files

Character vector of vcf file names

sample_names

Character vector of sample names

genome

A character or Seqinfo object

style

The naming standard to use for the GRanges. (default = "UCSC")

Value

A GRangesList containing the GRanges obtained from vcf_files

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# The example data set consists of three colon samples, three intestine
# samples and three liver samples.  So, to map each file to its appropriate
# sample name, we create a vector containing the sample names:
sample_names <- c("colon1", "colon2", "colon3",
                    "intestine1", "intestine2", "intestine3",
                    "liver1", "liver2", "liver3")

# We assemble a list of files we want to load.  These files match the
# sample names defined above.
vcf_files <- list.files(system.file("extdata", 
                                    package="MutationalPatterns"),
                                    pattern = ".vcf", full.names = TRUE)

# This function loads the files as GRanges objects
vcfs <- read_vcfs_as_granges(vcf_files, sample_names, genome = "hg19")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.