Can be a plain text file or a BGZIP file.

write_bed(
  x,
  file_path,
  tabix_index = TRUE,
  batch_size = NULL,
  comments = NULL,
  ...
)

Arguments

x

A data.table object to write.

file_path

Path of the output file. If the extension name is .gz or .bgz, the output will be compressed in BGZIP format.

tabix_index

If TRUE, and file_path indicates a gzip file, will create create the tabix index file.

batch_size

An positive integer. Write file in batches. During each batch, only write up to batch_size lines.

comments

A character vector, which will be written to the top of the file as header lines.

...

Other arguments passed to methods. Compliant with data.table::fwrite.

Examples

bedtbl <- read_bed(system.file("extdata", "example_merge.bed", package = "bedtorch"))

# Write data to uncompressed file
write_bed(bedtbl,  tempfile(fileext = ".bed"))

# Write data to file and create tabix index
write_bed(bedtbl, tempfile(fileext = ".bed.gz"), tabix_index = TRUE)

# Write data to uncompressed file, with header lines
write_bed(bedtbl,  tempfile(fileext = ".bed"), comments = c("Author: X", "Date: N/A"))