collapse.bed: Merger of overlapping peaks in a provided .bed file.

View source: R/collapse.bed.R

collapse.bedR Documentation

Merger of overlapping peaks in a provided .bed file.

Description

Merge overlapping peaks in a provided .bed file.

Usage

collapse.bed(
  bed,
  maximal.distance = 0,
  keep.strandness = FALSE,
  only.one.strand = NULL,
  score.operation = "mean",
  bed.header = FALSE,
  sep = "\t",
  return.bed = TRUE,
  export.file.name = NULL,
  export.header = FALSE,
  verbose = TRUE
)

Arguments

bed

Two options are possible:
- String with the path to a .bed file;
- data.frame corresponding to a bed file format (only the first 6 columns, BED6, will be kept).

maximal.distance

Maximal distance between regions allowed for regions to be merged. By default 0.

keep.strandness

Logic value to indicate whether to force to only merge regions that are in the same strand. By default FALSE, disabled. Subordinated to not NULL value for 'only.one.strand' option.

only.one.strand

Atomic string to indicate whether to force merge for one specific strand only. It must be indicated the wished strand (e.g., '+', '-', '.'). Regions in the other strand/s will be kept without any modification. By default NULL.

score.operation

Applicable only if the regions contain scores. Atomic string to indicate the operation to apply to the scores of merged regions. Possible choices: 'mean', 'median', 'sum'. By default "mean".

bed.header

Logic value to define whether the .bed file contains an header or not. By default FALSE.

sep

String containing the separator character for a .bed file. By default "\t".

return.bed

Logic value to define if to return the bed as a data.frame. By default TRUE. Only unique rows are kept.

export.file.name

Optional: string to define the path to the file to be exported, if required. By default NULL, not exported.

export.header

Logic value to define whether the header should be exported in the sorted bed file. By default FALSE.

verbose

Logic value to indicate whether messages should be printed or not. By default TRUE.

Details

The function pre-sorts the bed and keeps only unique rows and only up to 6 columns (chr, start, end, name, score, strand).
The names of the regions (if available) of merged regions corresponds to the concatenation of all original region's name.
To get more information about the bed file format see the following page:
https://genome.ucsc.edu/FAQ/FAQformat.html#format1.

Value

If required, returns a data.frame corresponding to the collapsed .bed file.


sebastian-gregoricchio/Rseb documentation built on May 15, 2024, 5:45 a.m.