read_vcfs_as_granges: Read VCF files into a GRangesList

Description Usage Arguments Value Examples

View source: R/read_vcfs_as_granges.R

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 the same seqlevel style to the GRanges objects as the reference genome passed in the 'genome' parameter.

Usage

1
2
read_vcfs_as_granges(vcf_files, sample_names, genome = "-",
  group = "auto+sex", check_alleles = TRUE)

Arguments

vcf_files

Character vector of VCF file names

sample_names

Character vector of sample names

genome

A string matching the name of a BSgenome library corresponding to the reference genome of your VCFs

group

Selector for a seqlevel group. All seqlevels outside of this group will be removed. Possible values: * 'all' for all chromosomes; * 'auto' for autosomal chromosomes; * 'sex' for sex chromosomes; * 'auto+sex' for autosomal + sex chromosomes (default); * 'circular' for circular chromosomes; * 'none' for no filtering, which results in keeping all seqlevels from the VCF file.

check_alleles

logical. If TRUE (default) positions with insertions, deletions and/or multiple alternative alleles are excluded from the vcf object, since these positions cannot be analysed with this package. This setting can be set to FALSE to speed up processing time only if the input vcf does not contain any of such positions, as these will cause obscure errors.

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
16
17
18
19
20
# 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)

# Get a reference genome BSgenome object.
ref_genome <- "BSgenome.Hsapiens.UCSC.hg19"
library("BSgenome")
library(ref_genome, character.only = TRUE)

# This function loads the files as GRanges objects
vcfs <- read_vcfs_as_granges(vcf_files, sample_names, ref_genome)

MutationalPatterns documentation built on May 31, 2017, 3:34 p.m.