Gathering cells to make the pool according to specific factors, and randomly assign the cells from the pool to pseudo-sample with the randomized cell size. (min.cells <= size <= max.cells)

pseudo_sample_list(data, by, min.cells = 0, max.cells = Inf)

Arguments

data

matrix or data.frame or other single cell expression object

by

a vector or data.frame contains factor(s) for aggregation

min.cells

num, default 0, the minimum size of cells aggregating to each pseudo-sample

max.cells

num, default Inf, the maximum size of cells aggregating to each pseudo-sample

Value

A list of cell names for each pseudo-sample

Examples

counts <- matrix(abs(rnorm(10000, 10, 10)), 100)
rownames(counts) <- 1:100
colnames(counts) <- 1:100
meta <- data.frame(
  subset = rep(c("A", "B"), 50),
  level = rep(1:4, each = 25)
)
rownames(meta) <- 1:100
scRNA <- SeuratObject::CreateSeuratObject(counts = counts, meta.data = meta)
#> Warning: Data is of class matrix. Coercing to dgCMatrix.
pseudo_sample_list(scRNA,
  by = c("subset", "level"),
  min.cells = 10, max.cells = 20
)
#> $level
#> $level$`1`
#>  [1] "22" "56" "40" "36" "8"  "72" "68" "74" "34" "18" "86" "78"
#> 
#> $level$`2`
#>  [1] "24" "92" "12" "50" "52" "38" "20" "80" "88" "42" "60" "84" "90" "44" "2" 
#> 
#> $level$`3`
#>  [1] "14" "94" "10" "4"  "54" "46" "62" "58" "16" "82" "76" "30" "66"
#> 
#> $level$`4`
#>  [1] "6"   "26"  "28"  "32"  "48"  "64"  "70"  "96"  "98"  "100"
#> 
#> 
#> $subset
#> $subset$`1`
#>  [1] "11" "95" "39" "93" "45" "81" "51" "29" "83" "5" 
#> 
#> $subset$`2`
#>  [1] "35" "65" "25" "89" "85" "69" "63" "47" "23" "99" "59" "3"  "57" "17" "41"
#> [16] "1"  "27"
#> 
#> $subset$`3`
#>  [1] "49" "43" "91" "87" "15" "19" "9"  "79" "31" "37" "55" "77" "33"
#> 
#> $subset$`4`
#>  [1] "7"  "13" "21" "53" "61" "67" "71" "73" "75" "97"
#> 
#>