Skip to contents

Peak and tile matrix calculations can be sped up by reducing the number of cells. For cases where the outputs are going to be added together afterwards, this can provide a performance improvement

Usage

merge_cells(fragments, cell_groups)

Arguments

fragments

Input fragments object

cell_groups

Character or factor vector providing a group for each cell. Ordering is the same as cellNames(fragments)

Examples

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


## Pseudobulk into two groups
merge_cells(frags, as.factor(c(rep(1,3), rep(2,3))))
#> IterableFragments object of class "CellMerge"
#> 
#> Cells: 2 cells with names 1, 2
#> Chromosomes: 1 chromosomes with names chr1
#> 
#> Queued Operations:
#> 1. Read uncompressed fragments from memory
#> 2. Merge 6 cells into 2 groups