Skip to contents

Estimate useful dimensions from a reduction

Usage

RunDimsEstimate(
  srt,
  reduction = NULL,
  reduction_method = NULL,
  k = 30L,
  method = c("scree", "intrinsic", "ensemble"),
  min_dims = 5L,
  variance_threshold = 0.8,
  marginal_gain_threshold = 0.5,
  skip_first = FALSE,
  use_stored = TRUE,
  verbose = TRUE
)

Arguments

srt

A Seurat object.

reduction

Name of the dimensional reduction to inspect. Default is NULL, which automatically selects a PCA-like reduction via DefaultReduction() with pattern = "pca".

reduction_method

Optional reduction method name. When set to "nmf" or "glmpca", all available dimensions will be retained.

k

Number of neighbors used by intrinsicDimension::maxLikGlobalDimEst.

method

Dimension-selection method. "scree" uses PCA standard deviations with broken-stick, elbow, cumulative-variance, and marginal-gain criteria. "intrinsic" uses intrinsicDimension::maxLikGlobalDimEst. "ensemble" keeps the larger recommendation from both methods when both are available.

min_dims

Minimum number of dimensions kept when intrinsic-dimension estimation succeeds.

variance_threshold

Cumulative variance threshold used by method = "scree".

marginal_gain_threshold

Stop point for marginal variance gain (percentage points) used by method = "scree".

skip_first

Whether to drop the first dimension from the returned result. Useful for TFIDF/LSI workflows.

use_stored

Whether to use misc$dims_estimate already stored in the reduction when available.

verbose

Whether to print the message. Default is TRUE.

Value

An integer vector of dimensions to use.

See also

Examples

data(pancreas_sub)
pancreas_sub <- RunStandardWorkflow(pancreas_sub)
#>  [2026-08-30 04:56:30] Start standard processing workflow...
#>  [2026-08-30 04:56:30] Checking a list of <Seurat>...
#> ! [2026-08-30 04:56:30] Data 1/1 of the `srt_list` is "unknown"
#> Warning: Data 1/1 of the `srt_list` is "unknown"
#>  [2026-08-30 04:56:30] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on 1/1 of `srt_list`...
#>  [2026-08-30 04:56:30] Perform `FindVariableFeatures()` on 1/1 of `srt_list`...
#>  [2026-08-30 04:56:30] Use the separate HVF from `srt_list`
#>  [2026-08-30 04:56:30] Number of available HVF: 2000
#>  [2026-08-30 04:56:30] Finished check
#>  [2026-08-30 04:56:30] Perform `ScaleData()`
#>  [2026-08-30 04:56:30] Perform pca linear dimension reduction
#>  [2026-08-30 04:56:31] Use stored estimated dimensions 1:23 for Standardpca
#>  [2026-08-30 04:56:31] Perform `Seurat::FindClusters()` with `cluster_algorithm = 'louvain'` and `cluster_resolution = 0.6`
#>  [2026-08-30 04:56:31] Reorder clusters...
#>  [2026-08-30 04:56:31] Skip `log1p()` because `layer = data` is not "counts"
#>  [2026-08-30 04:56:31] Perform umap nonlinear dimension reduction
#>  [2026-08-30 04:56:39] Standard processing workflow completed
RunDimsEstimate(pancreas_sub)
#>  [2026-08-30 04:56:39] Use stored estimated dimensions 1:23 for Standardpca
#>  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

DimsEstimatePlot(pancreas_sub)
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.