Calculate inter-distance of genomic regions

rainfallTransform(
    region,
    mode = c("min", "max", "mean", "left", "right"),
    normalize_to_width = FALSE)

Arguments

region

Genomic positions. It can be a data frame with two columns which are start positions and end positions on a single chromosome. It can also be a bed-format data frame which contains the chromosome column.

mode

How to calculate inter-distance. For a region, there is a distance to the prevous region and also there is a distance to the next region. mode controls how to merge these two distances into one value.

normalize_to_width

If it is TRUE, the value is the relative distance divided by the width of the region.

Value

If the input is a two-column data frame, the function returnes a data frame with three columns: start position, end position and distance. And if the input is a bed-format data frame, there will be the chromosome column added.

The row order of the returned data frame is as same as the input one.

Examples

bed = generateRandomBed() bed = subset(bed, chr == "chr1") head(rainfallTransform(bed))
#> chr start end dist #> 1 chr1 13320 34407 411684 #> 2 chr1 446091 575208 92554 #> 3 chr1 667762 890572 30749 #> 4 chr1 921321 936771 22156 #> 5 chr1 958927 970783 22156 #> 6 chr1 1264401 1403820 47438