Reading data from a BED or WIG file

Share:

Description

Read a track object from a BED, bedGraph, WIG or BigWig file

Usage

1
2
3
importScore(file, file2, 
            format=c("BED", "bedGraph", "WIG", "BigWig"), 
            ranges=GRanges(), ignore.strand=TRUE)

Arguments

file

The path to the file to read.

file2

The path to the second file to read.

format

The format of import file. Could be BED, bedGraph, WIG or BigWig

ranges

An object of GRanges to indicate the range to be imported

ignore.strand

ignore the strand or not when do filter. default TRUE

Value

a track object

Author(s)

Jianhong Ou

See Also

See Also as importBam, track, viewTracks

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#import a BED file
bedfile <- system.file("tests", "test.bed", package="rtracklayer",
                       mustWork=TRUE)
dat <- importScore(file=bedfile, format="BED",
                    ranges=GRanges("chr7", IRanges(127471197, 127474697)))

##import a WIG file
wigfile <- system.file("tests", "step.wig", package = "rtracklayer",
                       mustWork=TRUE)
dat <- importScore(file=wigfile, format="WIG")

##import a BigWig file
if(.Platform$OS.type!="windows"){##this is because we are using rtracklayer::import
    bwfile <- system.file("tests", "test.bw", package = "rtracklayer",
                       mustWork=TRUE)
    dat <- importScore(file=bwfile, format="BigWig")
}

##import 2 file
wigfile1 <- system.file("extdata", "cpsf160.repA_+.wig", package="trackViewer",
                        mustWork=TRUE)
wigfile2 <- system.file("extdata", "cpsf160.repA_-.wig", package="trackViewer",
                        mustWork=TRUE)
dat <- importScore(wigfile1, wigfile2, format="WIG", 
                    ranges=GRanges("chr11", IRanges(122817703, 122889073)))