Subset per sample

subsetPerSample(object, ...)

# 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.

...

Additional arguments.

Value

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

  • assignAndSave = TRUE: Subset file paths.

Note

Updated 2019-08-11.

Examples

data(SingleCellExperiment, package = "acidtest") sce <- SingleCellExperiment ## SingleCellExperiment ==== object <- sce ## List mode (default). list <- subsetPerSample(object, assignAndSave = FALSE)
#> 1 sample matched: sample1.
#> 64 cells matched.
#> 1 sample matched: sample2.
#> 36 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 matched: sample1.
#> 64 cells matched.
#> Saving sample1.rds to /data00/draco/acidbase/packages/basejump/docs/reference/subsetPerSample
#> 1 sample matched: sample2.
#> 36 cells matched.
#> Saving sample2.rds to /data00/draco/acidbase/packages/basejump/docs/reference/subsetPerSample
sort(list.files("subsetPerSample"))
#> [1] "sample1.rds" "sample2.rds"
## Clean up. unlink("subsetPerSample", recursive = TRUE)