Chapters and reference
Complete canonical API text; task articles explain the workflows. Usage guide

Read paired BED intervals as ggchord links
Source:R/data-bedpe.R
read_bedpe.RdReads tab-separated BEDPE with six required columns, optional name, score, strand1 and strand2 in standard order, and any additional fields. Each file must have a consistent field count. Blank/comment lines and tab-free track/browser headers are skipped. Accession identifiers and the order of the two anchors are retained: the first anchor is query, the second subject.
Usage
R · Example code
read_bedpe(
file = NULL,
files = NULL,
source_file = FALSE,
unmapped = c("error", "keep")
)Value
A data frame with canonical q/s endpoints, anchor strands, mapping
flags, relative direction, original BEDPE fields, bedpe_extra and physical
.source_line. The ggchord_import attribute records files, row counts
and coordinate conventions. The keep policy does not make missing anchors
drawable and does not manufacture source positions.
Details
Zero-based half-open intervals become one-based inclusive intervals.
Negative-strand anchor endpoints decrease, matching as_ggchord_link() for
paired interval objects. Unspecified strands remain "."; relative anchor
direction is known only when both anchors and both strands are known.
Anchor direction does not establish a pairwise alignment. No identity,
alignment length, read support or full sequence length is inferred.
Original standard fields are retained as character columns, including
arbitrary score strings. Extra fields are retained in the bedpe_extra
list-column as character vectors named by their physical column number.
Names are labels, not guaranteed unique HSP IDs. Unknown chromosome "."
and coordinate -1 are explicit missing-value sentinels. The default stops
on incomplete anchors; unmapped = "keep" retains them for auditing with
missing canonical fields and q_mapped/s_mapped flags. Filter for both
flags before adaptation or plotting. Invalid known coordinates, including
zero-width intervals, are always errors.
Examples
R · Example code
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
data(ribbon_data_example)
# Re-encode observed intervals for a format round trip, not paired-read evidence.
paired <- ribbon_data_example |>
transmute(
chrom1 = qaccver, start1 = pmin(qstart, qend) - 1, end1 = pmax(qstart, qend),
chrom2 = saccver, start2 = pmin(sstart, send) - 1, end2 = pmax(sstart, send)
)
path <- tempfile(fileext = ".bedpe")
write.table(paired, path,
sep = "\t", quote = FALSE, row.names = FALSE, col.names = FALSE
)
read_bedpe(path)
#> qaccver saccver qstart qend sstart send qstrand sstrand q_mapped
#> 1 MT108731.1 MT118296.1 26298 51139 7121 31959 . . TRUE
#> 2 MT108731.1 MT118296.1 21513 25922 2365 6772 . . TRUE
#> 3 MT108731.1 MT118296.1 20376 20677 403 704 . . TRUE
#> 4 MT108731.1 OQ646790.1 45278 50839 27955 33476 . . TRUE
#> 5 MT108731.1 OQ646790.1 12796 14536 722 2456 . . TRUE
#> 6 MT108731.1 OQ646790.1 2466 3102 49307 49945 . . TRUE
#> 7 MT108731.1 OR222515.1 48107 50830 31245 33968 . . TRUE
#> 8 MT118296.1 OQ646790.1 26098 31659 27955 33476 . . TRUE
#> 9 MT118296.1 OQ646790.1 7922 10392 11415 13891 . . TRUE
#> 10 MT118296.1 OQ646790.1 3464 4527 6711 7777 . . TRUE
#> 11 MT118296.1 OR222515.1 28927 31650 31245 33968 . . TRUE
#> 12 OQ646790.1 OR222515.1 31842 33461 32343 33962 . . TRUE
#> 13 OQ646790.1 OR222515.1 30765 31732 31242 32209 . . TRUE
#> s_mapped orientation_known direction chrom1 start1 end1 chrom2
#> 1 TRUE FALSE <NA> MT108731.1 26297 51139 MT118296.1
#> 2 TRUE FALSE <NA> MT108731.1 21512 25922 MT118296.1
#> 3 TRUE FALSE <NA> MT108731.1 20375 20677 MT118296.1
#> 4 TRUE FALSE <NA> MT108731.1 45277 50839 OQ646790.1
#> 5 TRUE FALSE <NA> MT108731.1 12795 14536 OQ646790.1
#> 6 TRUE FALSE <NA> MT108731.1 2465 3102 OQ646790.1
#> 7 TRUE FALSE <NA> MT108731.1 48106 50830 OR222515.1
#> 8 TRUE FALSE <NA> MT118296.1 26097 31659 OQ646790.1
#> 9 TRUE FALSE <NA> MT118296.1 7921 10392 OQ646790.1
#> 10 TRUE FALSE <NA> MT118296.1 3463 4527 OQ646790.1
#> 11 TRUE FALSE <NA> MT118296.1 28926 31650 OR222515.1
#> 12 TRUE FALSE <NA> OQ646790.1 31841 33461 OR222515.1
#> 13 TRUE FALSE <NA> OQ646790.1 30764 31732 OR222515.1
#> start2 end2 bedpe_extra .source_line
#> 1 7120 31959 1
#> 2 2364 6772 2
#> 3 402 704 3
#> 4 27954 33476 4
#> 5 721 2456 5
#> 6 49306 49945 6
#> 7 31244 33968 7
#> 8 27954 33476 8
#> 9 11414 13891 9
#> 10 6710 7777 10
#> 11 31244 33968 11
#> 12 32342 33962 12
#> 13 31241 32209 13
unlink(path)