Subset per sample
Usage
subsetPerSample(object, ...)
# S4 method for SingleCellExperiment
subsetPerSample(
object,
minCells = 1L,
assignAndSave = FALSE,
envir = parent.frame(),
dir = getwd()
)
Arguments
- object
Object.
- minCells
integer(1)
. Minimum number of cells required per sample.- assignAndSave
logical(1)
. Assign and save the individual datasets.- envir
environment
. Where to assign the subsets. Only applicable whenassignAndSave = TRUE
.- dir
character(1)
. Output directory. Only applicable whenassignAndSave = TRUE
.- ...
Additional arguments.
Examples
data(SingleCellExperiment_splatter, package = "AcidTest")
## SingleCellExperiment ====
object <- SingleCellExperiment_splatter
## List mode (default).
list <- subsetPerSample(object, assignAndSave = FALSE)
#> ℹ 1 sample matched: "sample1".
#> ℹ 95 cells matched.
#> ℹ 1 sample matched: "sample2".
#> ℹ 96 cells matched.
#> ℹ 1 sample matched: "sample3".
#> ℹ 121 cells matched.
#> ℹ 1 sample matched: "sample4".
#> ℹ 88 cells matched.
names(list)
#> [1] "sample1" "sample2" "sample3" "sample4"
## Assign and save mode (useful for large datasets).
subsetPerSample(
object = object,
assignAndSave = TRUE,
envir = parent.frame(),
dir = "subsetPerSample"
)
#> ℹ 1 sample matched: "sample1".
#> ℹ 95 cells matched.
#> → Saving sample1.rds to /Users/mike/git/monorepo/r-packages/AcidSingleCell/docs/reference/subsetPerSample.
#> ℹ 1 sample matched: "sample2".
#> ℹ 96 cells matched.
#> → Saving sample2.rds to /Users/mike/git/monorepo/r-packages/AcidSingleCell/docs/reference/subsetPerSample.
#> ℹ 1 sample matched: "sample3".
#> ℹ 121 cells matched.
#> → Saving sample3.rds to /Users/mike/git/monorepo/r-packages/AcidSingleCell/docs/reference/subsetPerSample.
#> ℹ 1 sample matched: "sample4".
#> ℹ 88 cells matched.
#> → Saving sample4.rds to /Users/mike/git/monorepo/r-packages/AcidSingleCell/docs/reference/subsetPerSample.
sort(list.files("subsetPerSample"))
#> [1] "sample1.rds" "sample2.rds" "sample3.rds" "sample4.rds"
## Clean up.
unlink("subsetPerSample", recursive = TRUE)