Downsample each cell to a specified number of UMIs. Includes an option to upsample cells below specified UMI as well.

SampleUMI(data, max.umi = 1000, upsample = FALSE, verbose = FALSE)

Arguments

data

Matrix with the raw count data

max.umi

Number of UMIs to sample to

upsample

Upsamples all cells with fewer than max.umi

verbose

Display the progress bar

Value

Matrix with downsampled data

Examples

data("pbmc_small")
counts = as.matrix(x = GetAssayData(object = pbmc_small, assay = "RNA", slot = "counts"))
downsampled = SampleUMI(data = counts)
head(x = downsampled)
#> 6 x 80 sparse Matrix of class "dgCMatrix"
#>   [[ suppressing 80 column names ‘ATGCCAGAACGACT’, ‘CATGGCCTGTGCAT’, ‘GAACCTGATGAACC’ ... ]]
#>                                                                                
#> MS4A1    . . . . . . . . . .  2  2  4 4  2  3 3  4  2  3 .  . .  . 1 . . . .  .
#> CD79B    1 . . . . . . . . 1  2  4  3 3  2  3 1  2  2  5 .  . .  . . . . . .  1
#> CD79A    . . . . . . . . . .  .  5  2 2  5  8 1  5  5 12 .  . 1  . . . . 1 .  .
#> HLA-DRA  . 1 . . 1 1 . 1 . . 14 28 18 7 15 28 7 26 10 16 7 22 . 10 6 . 4 3 7 13
#> TCL1A    . . . . . . . . . .  3  .  2 4  .  . 3  3  3  2 .  . .  . . . . . .  .
#> HLA-DQB1 1 . . . . . . . . .  1  6  2 2  2  8 2  2  1  2 .  3 .  . . . 1 . 1  .
#>                                                                              
#> MS4A1    . . . . . . . . . . . . . . . . . . . .  .  . . . .  .  .  . . .   .
#> CD79B    1 . 2 . . . . . . . . . . . . . . . . .  1  . 1 1 2  2  .  . 3 .   .
#> CD79A    . . . . . . . . . . . . . . . . . . . .  .  . . . .  .  .  . . .   .
#> HLA-DRA  . 1 . . 1 . 1 1 . . . . . . . 1 1 1 . . 10 10 4 1 6 28 10 13 5 8 108
#> TCL1A    . . . . . . . . . . . . . . . . . . . .  .  . . . .  .  .  . . .   .
#> HLA-DQB1 . . . . . . . . . . . . . . . . . . . .  .  1 1 . 2  .  .  1 1 .  21
#>                                                          
#> MS4A1     .  .  .   .  .  .  1  .   . . . . . . . . . . .
#> CD79B     .  .  4   1  .  .  .  .   . . . . . . . . . . .
#> CD79A     .  .  8   .  .  .  .  1   . . . . . . . . . . .
#> HLA-DRA  93 41 42 138 77 76 15 19 104 1 . . . 2 1 1 . 2 7
#> TCL1A     .  .  4   .  .  .  .  .   . . . . . . . . . . .
#> HLA-DQB1 21  3  5  11 11 10  1  2  11 . . . . . . . . . 1