importBED: Import BED files

Description Usage Arguments Details Value References Examples

View source: R/importFiles.R

Description

Given a filename referring to a BED file, this function returns a dataframe containing the first 6 columns of the BED file. The BED file referred to by the filename MUST have as its first 6 columns: coordinate chromosome, coordinate start position, coordinate end position, coordinate name, coordinate score, and coordinate strand. 0 and . can be used for missing score and strand information, respectively. Resulting dataframes can then be used as peaks or features for annotation.

Usage

1
importBED(pathName)

Arguments

pathName

A filename giving a path to the BED file to be imported

Details

Use of read.delim from the utils package to import files was inspired by RStudio's default method of importing text files. Code to rename column names is based off of a StackOverflow post by Joshua Ulrich (see References).

Value

A dataframe containing all coordinates given in the BED file. This dataframe contains 6 columns: coordinate chromosome, coordinate start position, coordinate end position, coordinate name, coordinate score, and coordinate strand. Note that the end coordinate will be one less than given in the BED file since standard BED format has right-open intervals.

References

Joshua Ulrich. "How to rename a single column in a data.frame?". 23 September 2011. Accessed 25 September 2019. https://stackoverflow.com/a/7532464

Examples

1
2
3
4
5
6
7
8
  pathToPeaks <- system.file("extdata",
     "H3K27me3Peaks.bed", package = "PeakMapper")
  pathToGenes <- system.file("extdata",
     "WS263Genes.bed", package = "PeakMapper")
  H3K27me3Peaks <- importBED(pathToPeaks)
  WS263Genes <- importBED(pathToGenes)
  H3K27me3Peaks$Name
  WS263Genes$Score

fuscada2/PeakMapper documentation built on Dec. 8, 2019, 12:35 p.m.