The L notation explicitely makes integers:
> class(1000)
[1] "numeric"
> class(1000L)
[1] "integer"
Apparently this can have advantages for speed and memory, but this you probably only notice if you work with super large datasets,
see https://stackoverflow.com/questions/7014387/whats-the-difference-between-1l-and-1
There is I think not really a function for this. Here is a custom approach, not sure how well this scales with large datasets:
Output:
> ranges1
GRanges object with 3 ranges and 0 metadata columns:
seqnames ranges strand
<Rle> <IRanges> <Rle>
[1] chr1 1-10 *
[2] chr2 100-150 *
[3] chr3 1000-5000 *
-------
seqinfo: 3 sequences from an unspecified genome; no seqlengths
>
> ranges2
GRanges object with 3 ranges and 0 metadata columns:
seqnames ranges strand
<Rle> <IRanges> <Rle>
[1] chr1 11-20 *
[2] chr2 110-130 *
[3] chr3 2000-3000 *
-------
seqinfo: 3 sequences from an unspecified genome; no seqlengths
>
> GetPercentOverlap(query = ranges1, subject = ranges2)
GRanges object with 2 ranges and 2 metadata columns:
seqnames ranges strand | percentOverlap subject
<Rle> <IRanges> <Rle> | <numeric> <IRanges>
[1] chr2 100-150 * | 41.1765 110-130
[2] chr3 1000-5000 * | 25.0187 2000-3000
-------
seqinfo: 2 sequences from an unspecified genome; no seqlengths
>
> GetPercentOverlap(query = ranges2, subject = ranges1)
GRanges object with 2 ranges and 2 metadata columns:
seqnames ranges strand | percentOverlap subject
<Rle> <IRanges> <Rle> | <numeric> <IRanges>
[1] chr2 110-130 * | 100 100-150
[2] chr3 2000-3000 * | 100 1000-5000
-------
seqinfo: 2 sequences from an unspecified genome; no seqlengths