Subset per sample

# S4 method for SingleCellExperiment
subsetPerSample(object, minCells = 1L,
  assignAndSave = FALSE, envir = parent.frame(), dir = ".")

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 when assignAndSave = TRUE.

dir

character(1). Output directory. Only applicable when assignAndSave = TRUE.

Value

  • assignAndSave = FALSE: Per sample objects in a list.

  • assignAndSave = TRUE: Subset file paths.

Examples

data(sce) ## SingleCellExperiment ==== object <- sce ## List mode (default). list <- subsetPerSample(object, assignAndSave = FALSE)
#> 1 sample(s) matched: sample1
#> 41 cells matched.
#> 1 sample(s) matched: sample2
#> 59 cells matched.
names(list)
#> [1] "sample1" "sample2"
## Assign and save mode (useful for large datasets). subsetPerSample( object = object, assignAndSave = TRUE, envir = parent.frame(), dir = "subsetPerSample" )
#> 1 sample(s) matched: sample1
#> 41 cells matched.
#> Saving sample1.rds to /Users/mike/git/basejump/docs/reference/subsetPerSample
#> 1 sample(s) matched: sample2
#> 59 cells matched.
#> Saving sample2.rds to /Users/mike/git/basejump/docs/reference/subsetPerSample
list.files("subsetPerSample")
#> [1] "sample1.rds" "sample2.rds"
## Clean up. unlink("subsetPerSample", recursive = TRUE)