Tune ncomp using cross-validation.

CVTune_ncomp(
  reference,
  assayName = "logcounts",
  phenotypes = NULL,
  YY = NULL,
  center = TRUE,
  scale = FALSE,
  ncompLimits = c(1, 100),
  gridSize = 20,
  ncompGrid = NULL,
  selectedFeat = NULL,
  Kfolds = 5,
  regMethod = "PCA",
  labelCode = "-1,1",
  Ncores = 1,
  seed = 5202056,
  ncomp = NULL
)

Arguments

reference

SingleCellExperiment object.

assayName

Character.

phenotypes

Character.

YY

Matrix.

center

Logic.

scale

Logic.

ncompLimits

Vector.

gridSize

Integer.

ncompGrid

Vector.

selectedFeat

Vector.

Kfolds

Integer.

regMethod

Character.

labelCode

Character.

Ncores

Integer.

seed

Integer. The function sets the seed with withr::local_seed(), so the session's random-number state is restored on exit.

ncomp

Chosen number of components, or NULL to choose after the cross-validation: in an interactive session the function plots the loss and asks; otherwise it takes the grid value with the lowest loss.

Value

A list.