toGRanges: Convert dataset to GRanges

Description Usage Arguments Value Author(s) Examples

Description

Convert UCSC BED format and its variants, such as GFF, or any user defined dataset such as MACS output file to GRanges

Usage

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
toGRanges(data, ...)

## S4 method for signature 'connection'
toGRanges(
  data,
  format = c("BED", "GFF", "GTF", "MACS", "MACS2", "MACS2.broad", "narrowPeak",
    "broadPeak", "others"),
  header = FALSE,
  comment.char = "#",
  colNames = NULL,
  ...
)

## S4 method for signature 'TxDb'
toGRanges(
  data,
  feature = c("gene", "transcript", "exon", "CDS", "fiveUTR", "threeUTR", "microRNA",
    "tRNAs", "geneModel"),
  OrganismDb,
  ...
)

## S4 method for signature 'EnsDb'
toGRanges(
  data,
  feature = c("gene", "transcript", "exon", "disjointExons"),
  ...
)

## S4 method for signature 'character'
toGRanges(
  data,
  format = c("BED", "GFF", "GTF", "MACS", "MACS2", "MACS2.broad", "narrowPeak",
    "broadPeak", "others"),
  header = FALSE,
  comment.char = "#",
  colNames = NULL,
  ...
)

Arguments

data

an object of data.frame, TxDb or EnsDb, or the file name of data to be imported. Alternatively, data can be a readable txt-mode connection (See ?read.table).

...

parameters passed to read.table

format

data format. If the data format is set to BED, GFF, narrowPeak or broadPeak, please refer to http://genome.ucsc.edu/FAQ/FAQformat#format1 for column order. "MACS" is for converting the excel output file from MACS1. "MACS2" is for converting the output file from MACS2.

header

A logical value indicating whether the file contains the names of the variables as its first line. If missing, the value is determined from the file format: header is set to TRUE if and only if the first row contains one fewer field than the number of columns.

comment.char

character: a character vector of length one containing a single character or an empty string. Use "" to turn off the interpretation of comments altogether.

colNames

If the data format is set to "others", colname must be defined. And the colname must contain space, start and end. The column name for the chromosome # should be named as space.

feature

annotation type

OrganismDb

an object of OrganismDb. It is used for extracting gene symbol for geneModel group for TxDb

Value

An object of GRanges

Author(s)

Jianhong Ou

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
26
27
28
29
30
31
32
33
34
  macs <- system.file("extdata", "MACS_peaks.xls", package="ChIPpeakAnno")
  macsOutput <- toGRanges(macs, format="MACS")
  if(interactive() || Sys.getenv("USER")=="jianhongou"){
    ## MACS connection
    macs <- readLines(macs)
    macs <- textConnection(macs)
    macsOutput <- toGRanges(macs, format="MACS")
    close(macs)
    ## bed
    toGRanges(system.file("extdata", "MACS_output.bed", package="ChIPpeakAnno"),
                format="BED")
    ## narrowPeak
    toGRanges(system.file("extdata", "peaks.narrowPeak", package="ChIPpeakAnno"),
                format="narrowPeak")
    ## broadPeak
    toGRanges(system.file("extdata", "TAF.broadPeak", package="ChIPpeakAnno"),
                format="broadPeak")
    ## MACS2
    toGRanges(system.file("extdata", "MACS2_peaks.xls", package="ChIPpeakAnno"),
                format="MACS2")
    ## GFF
    toGRanges(system.file("extdata", "GFF_peaks.gff", package="ChIPpeakAnno"),
                format="GFF")
    ## EnsDb
    library(EnsDb.Hsapiens.v75)
    toGRanges(EnsDb.Hsapiens.v75, feature="gene")
    ## TxDb
    library(TxDb.Hsapiens.UCSC.hg19.knownGene)
    toGRanges(TxDb.Hsapiens.UCSC.hg19.knownGene, feature="gene")
    ## data.frame
    macs <- system.file("extdata", "MACS_peaks.xls", package="ChIPpeakAnno")
    macs <- read.delim(macs, comment.char="#")
    toGRanges(macs)
  }

ChIPpeakAnno documentation built on April 1, 2021, 6:01 p.m.