Rename cells by adding a prefix to the names. Most commonly this will be a sample name.
All cells will recieve the exact text of prefix
added to the beginning, so any separator
characters like "_" must be included in the given prefix
. Use this prior to merging
fragments from different experiments with c()
in order to help prevent cell name
clashes.
Examples
## Prep data
frags <- tibble::tibble(
chr = "chr1",
start = seq(10, 260, 50),
end = start + 30,
cell_id = paste0("cell", c(rep(1, 2), rep(2,2), rep(3,2)))
) %>% convert_to_fragments()
frags
#> IterableFragments object of class "UnpackedMemFragments"
#>
#> Cells: 3 cells with names cell1, cell2, cell3
#> Chromosomes: 1 chromosomes with names chr1
#>
#> Queued Operations:
#> 1. Read uncompressed fragments from memory
## Prefix cells with foo
prefix_cell_names(frags, "foo_") %>% as("GRanges")
#> GRanges object with 6 ranges and 1 metadata column:
#> seqnames ranges strand | cell_id
#> <Rle> <IRanges> <Rle> | <factor>
#> [1] chr1 11-40 * | foo_cell1
#> [2] chr1 61-90 * | foo_cell1
#> [3] chr1 111-140 * | foo_cell2
#> [4] chr1 161-190 * | foo_cell2
#> [5] chr1 211-240 * | foo_cell3
#> [6] chr1 261-290 * | foo_cell3
#> -------
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths