BPCells fragments can be interconverted with GRanges and data.frame R objects.
The main conversion method is R's builtin as()
function, though the
convert_to_fragments()
helper is also available. For all R objects except
GRanges, BPCells assumes a 0-based, end-exclusive coordinate system. (See
genomic-ranges-like reference for details)
Usage
# Convert from R to BPCells
convert_to_fragments(x, zero_based_coords = !is(x, "GRanges"))
as(x, "IterableFragments")
# Convert from BPCells to R
as.data.frame(bpcells_fragments)
as(bpcells_fragments, "data.frame")
as(bpcells_fragments, "GRanges")
Arguments
- x
Fragment coordinates given as GRanges, data.frame, or list. See
help("genomic-ranges-like")
for details on format and coordinate systems. Required attributes:chr
,start
,end
: genomic positioncell_id
: cell barcodes or unique identifiers as string or factor
- zero_based_coords
Whether to convert the ranges from a 1-based end-inclusive coordinate system to a 0-based end-exclusive coordinate system. Defaults to true for GRanges and false for other formats (see this archived UCSC blogpost)