readBedFileAsGRanges: Import BED file into GRanges

Description Usage Arguments Value Examples

View source: R/importReads.R

Description

Import aligned reads from a BED file into a GRanges-class object.

Usage

1
2
3
4
5
6
7
8
9
readBedFileAsGRanges(
  bedfile,
  assembly,
  chromosomes = NULL,
  remove.duplicate.reads = FALSE,
  min.mapq = 10,
  max.fragment.width = 1000,
  blacklist = NULL
)

Arguments

bedfile

A file with aligned reads in BED-6 format. The columns have to be c('chromosome','start','end','description','mapq','strand').

assembly

Please see getChromInfoFromUCSC for available assemblies. Only necessary when importing BED files. BAM files are handled automatically. Alternatively a data.frame with columns 'chromosome' and 'length'.

chromosomes

If only a subset of the chromosomes should be imported, specify them here.

remove.duplicate.reads

A logical indicating whether or not duplicate reads should be removed.

min.mapq

Minimum mapping quality when importing from BAM files. Set min.mapq=0 to keep all reads.

max.fragment.width

Maximum allowed fragment length. This is to filter out erroneously wrong fragments.

blacklist

A GRanges-class or a bed(.gz) file with blacklisted regions. Reads falling into those regions will be discarded.

Value

A GRanges-class object containing the reads.

Examples

1
2
3
4
5
6
7
8
## Get an example BED file with single-cell-sequencing reads
bedfile <- system.file("extdata", "liver-H3K4me3-BN-male-bio2-tech1.bed.gz",
                       package="chromstaRData")
## Read the file into a GRanges object
data(rn4_chrominfo)
reads <- readBedFileAsGRanges(bedfile, assembly=rn4_chrominfo, chromosomes='chr12',
                    min.mapq=10, remove.duplicate.reads=TRUE)
print(reads)

chromstaR documentation built on Nov. 8, 2020, 8:29 p.m.