Skip to contents

Subset, translate, or reorder cell IDs

Usage

select_cells(fragments, cell_selection)

Arguments

fragments

Input fragments object

cell_selection

List of cell IDs (numeric), names (character), or logical mask.

Details

Numeric cell IDs will be re-assigned in the order of cell_selection. The output cell ID n will be taken from the input cell with ID/name cell_selection[n].

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


## Select cells by name
select_cells(frags, "cell1")
#> IterableFragments object of class "CellSelectName"
#> 
#> Cells: 1 cells with names cell1
#> Chromosomes: 1 chromosomes with names chr1
#> 
#> Queued Operations:
#> 1. Read uncompressed fragments from memory
#> 2. Select 1 cells by name: cell1

## Select cells by index
select_cells(frags, c(1,3))
#> IterableFragments object of class "CellSelectIndex"
#> 
#> Cells: 2 cells with names cell1, cell3
#> Chromosomes: 1 chromosomes with names chr1
#> 
#> Queued Operations:
#> 1. Read uncompressed fragments from memory
#> 2. Select 2 cells by index: 1, 3