io-bed-write: Write a BED or BEDGraph file

Description Usage Arguments Value See Also Examples

Description

This is a lightweight wrapper to the export family of functions defined in rtracklayer.

Usage

1
2
3
4
5

Arguments

x

A GRanges object

file

File name, URL or connection specifying a file to write x to. Compressed files with extensions such as '.gz' are handled automatically. If you want to index the file with tabix use the index argument.

index

Compress and index the output file with bgzf and tabix (default = FALSE). Note that tabix indexing will sort the data by chromosome and start.

Value

The write functions return a BED(Graph)File invisibly

See Also

rtracklayer::BEDFile()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
  test_path <- system.file("tests", package = "rtracklayer")
  bed_file <- file.path(test_path, "test.bed")
  gr <- read_bed(bed_file)
  bed_file_out <- file.path(tempdir(), "new.bed")
  write_bed(gr, bed_file_out)
  read_bed(bed_file_out)
  #' bedgraph
  bg_file <- file.path(test_path, "test.bedGraph")
  gr <- read_bed_graph(bg_file)
  bg_file_out <- file.path(tempdir(), "new.bg")
  write_bed(gr, bg_file_out)
  read_bed(bg_file_out)
  # narrowpeaks
  np_file <- system.file("extdata", "demo.narrowPeak.gz",package="rtracklayer")
  gr <- read_narrowpeaks(np_file, genome_info = "hg19")
  np_file_out <- file.path(tempdir(), "new.bg")
  write_narrowpeaks(gr, np_file_out)
  read_narrowpeaks(np_file_out)

## End(Not run)

plyranges documentation built on Nov. 8, 2020, 7:36 p.m.