Skip to contents

This function implements the meta cell aggregation from Persad et al., and returns the resulting SEACells. Compared to other algorithms, a kernel archetype analysis is used to identify the metacells. For details, please refer to the publication.

Usage

generate_seacells_sc(
  object,
  seacell_params = params_sc_seacells(),
  embd_to_use = "pca",
  no_embd_to_use = NULL,
  cells_to_use = NULL,
  regenerate_knn = FALSE,
  target_size = 1e+05,
  seed = 42L,
  .verbose = TRUE
)

Arguments

object

SingleCells or SingleCellsSubset class.

seacell_params

List. Output of params_sc_seacells(). A list with the following items:

  • n_sea_cells - Number of SEA cells to detect.

  • max_fw_iters - Maximum iterations for the Franke-Wolfe algorithm per matrix update.

  • convergence_epsilon - Convergence threshold. Algorithm stops when RSS change < epsilon * RSS(0).

  • max_iter - Maximum iterations to run SEACells for.

  • min_iter - Minimum iterations to run SEACells for.

  • greedy_threshold - Maximum number of cells before defaulting to rapid random selection of archetypes.

  • graph_building - Graph building method.

  • pruning - Boolean. Shall small values be pruned during the Franke- Wolfe iterations.

  • pruning_threshold - The threshold below which pruning shall be applied during Franke-Wolfe iterations.

  • knn - List of kNN parameters. See params_knn_defaults() for available parameters and their defaults.

embd_to_use

String. The embedding to use. Atm, the only option is "pca". Only relevant if you set regenerate_knn to TRUE.

no_embd_to_use

Optional integer. Number of embedding dimensions to use. If NULL all will be used. Only relevant if you set regenerate_knn to TRUE.

cells_to_use

Optional string. Names of the cells to use for the generation of the SEACells.

regenerate_knn

Boolean. Shall a kNN graph be regenerated. If not, the internal one will be used.

target_size

Numeric. The library target size to normalise the meta cells to.

seed

Integer. Seed for reproducibility.

.verbose

Boolean or integer. Controls verbosity and returns run times. FALSE -> quiet, TRUE or 1L -> normal verbosity, 2L -> detailed verbosity.

Value

A MetaCells() with the data generated by this meta cell aggregation method.

References

Persad, et al. Nat Biotechnol, 2023

Examples

# archetypal analysis based meta cells
sc <- demo_single_cells()
mc <- generate_seacells_sc(
  sc,
  seacell_params = params_sc_seacells(
    n_sea_cells = 50L,
    min_iter = 5L,
    knn = list(k = 10L)
  ),
  .verbose = FALSE
)
mc
#> Single cell experiment (Meta Cells).
#>   Meta cell method: seacell
#>   Merged: FALSE
#>   No meta cells: 50
#>   No genes: 50
#>   No cells aggregated: 500
#>   No obs rows in source: 500
#>   HVG calculated: FALSE
#>   PCA calculated: FALSE
#>   Other embeddings: none
#>   KNN generated: FALSE
#>   SNN generated: FALSE
#>   Stale artefacts: none

unlink(sc@dir_data, recursive = TRUE, force = TRUE)