Last data update: 2014.03.03

R: Extract narrow regions and peaks from a narrrowPeak file
readNarrowPeakFileR Documentation

Extract narrow regions and peaks from a narrrowPeak file

Description

Read a narrowPeak file and extract the narrow regions and/or the peaks, as specified by used. The narrowPeak file must fit the UCSC specifications. See https://genome.ucsc.edu/FAQ/FAQformat.html#format12 for more details. The file can have one or many header lines. However, the total number of header lines must be inferior to 250 lines.

Usage

readNarrowPeakFile(file_path, extractRegions = TRUE, extractPeaks = TRUE)

Arguments

file_path

the name of the file.

extractRegions

a logical indicating if the narrow regions must be extracted. If TRUE, a GRanges containing the narrow regions will be returned. Otherwise, NULL is returned. Default = TRUE.

extractPeaks

a logical indicating if the peaks must be extracted. If TRUE, a GRanges containing the peaks will be returned. Otherwise, NULL is returned. Default = TRUE.

Value

a list containing 2 entries:

  • narrowPeak a GRanges containing the narrow regions extracted from the file. NULL when not needed by user.

  • peak a GRanges containing the peaks extracted from the file. NULL when not

Author(s)

Astrid Deschenes

Examples


## Set file information
test_narrowPeak <- system.file("extdata",
            "A549_FOSL2_ENCSR000BQO_MZW_part_chr_1_and_12.narrowPeak",
            package = "consensusSeekeR")

## Read file to extract peaks and regions
data <- readNarrowPeakFile(test_narrowPeak, extractRegions = TRUE,
            extractPeaks = TRUE)

## To access peak data (GRanges format)
head(data$peak)

## To access region data (GRanges format)
head(data$narrowPeak)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(consensusSeekeR)
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: IRanges
Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

Loading required package: GenomicRanges
Loading required package: GenomeInfoDb
Loading required package: BiocParallel
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/consensusSeekeR/readNarrowPeakFile.Rd_%03d_medium.png", width=480, height=480)
> ### Name: readNarrowPeakFile
> ### Title: Extract narrow regions and peaks from a narrrowPeak file
> ### Aliases: readNarrowPeakFile
> 
> ### ** Examples
> 
> 
> ## Set file information
> test_narrowPeak <- system.file("extdata",
+             "A549_FOSL2_ENCSR000BQO_MZW_part_chr_1_and_12.narrowPeak",
+             package = "consensusSeekeR")
> 
> ## Read file to extract peaks and regions
> data <- readNarrowPeakFile(test_narrowPeak, extractRegions = TRUE,
+             extractPeaks = TRUE)
> 
> ## To access peak data (GRanges format)
> head(data$peak)
GRanges object with 6 ranges and 6 metadata columns:
      seqnames           ranges strand |
         <Rle>        <IRanges>  <Rle> |
  [1]     chr1 [846687, 846687]      * |
  [2]     chr1 [856112, 856112]      * |
  [3]     chr1 [856643, 856643]      * |
  [4]     chr1 [873964, 873964]      * |
  [5]     chr1 [878672, 878672]      * |
  [6]     chr1 [881440, 881440]      * |
                                                      name     score
                                               <character> <numeric>
  [1] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_2        57
  [2] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_3        43
  [3] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_4        33
  [4] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_5       189
  [5] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_6        33
  [6] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_7        29
      signalValue    pValue    qValue      peak
        <numeric> <numeric> <numeric> <integer>
  [1]     5.59984   8.75159   5.77648        98
  [2]     5.16770   7.21902   4.33609       108
  [3]     4.65093   6.18592   3.38310        96
  [4]     9.91576  22.37844  18.94888       314
  [5]     4.65093   6.18592   3.38310       217
  [6]     4.03975   5.68403   2.92251       143
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths
> 
> ## To access region data (GRanges format)
> head(data$narrowPeak)
GRanges object with 6 ranges and 6 metadata columns:
      seqnames           ranges strand |
         <Rle>        <IRanges>  <Rle> |
  [1]     chr1 [846589, 846847]      * |
  [2]     chr1 [856004, 856159]      * |
  [3]     chr1 [856547, 856768]      * |
  [4]     chr1 [873650, 874067]      * |
  [5]     chr1 [878455, 878768]      * |
  [6]     chr1 [881297, 881473]      * |
                                                      name     score
                                               <character> <numeric>
  [1] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_2        57
  [2] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_3        43
  [3] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_4        33
  [4] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_5       189
  [5] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_6        33
  [6] peaks/Hosa_A549_FOSL2_ENCSR000BQO_ENCFF000MZW_peak_7        29
      signalValue    pValue    qValue      peak
        <numeric> <numeric> <numeric> <integer>
  [1]     5.59984   8.75159   5.77648        98
  [2]     5.16770   7.21902   4.33609       108
  [3]     4.65093   6.18592   3.38310        96
  [4]     9.91576  22.37844  18.94888       314
  [5]     4.65093   6.18592   3.38310       217
  [6]     4.03975   5.68403   2.92251       143
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>