This uses an efficient strategy for updating that takes
advantage of the information in the existing factorization. It is most
recommended for values of kNew
smaller than current value (k
,
which is set when running runINMF
), where it is more likely to
speed up the factorization.
Usage
optimizeNewK(
object,
kNew,
lambda = NULL,
nIteration = 30,
seed = 1,
verbose = getOption("ligerVerbose"),
k.new = kNew,
max.iters = nIteration,
rand.seed = seed,
thresh = NULL
)
Arguments
- object
A liger object. Should have integrative factorization performed e.g. (
runINMF
) in advance.- kNew
Number of factors of factorization.
- lambda
Numeric regularization parameter. By default
NULL
, this will use the lambda value used in the latest factorization.- nIteration
Number of block coordinate descent iterations to perform. Default
30
.- seed
Random seed to allow reproducible results. Default
1
. Used byrunINMF
factorization and initialization only when ifkNew
is greater thank
.- verbose
Logical. Whether to show information of the progress. Default
getOption("ligerVerbose")
which isTRUE
if users have not set.- k.new, max.iters, rand.seed
These arguments are now replaced by others and will be removed in the future. Please see usage for replacement.
- thresh
Deprecated. New implementation of iNMF does not require a threshold for convergence detection. Setting a large enough
nIteration
will bring it to convergence.
Value
object
with W
slot updated with the new \(W\)
matrix, and the H
and V
slots of each
ligerDataset object in the datasets
slot updated with
the new dataset specific \(H\) and \(V\) matrix, respectively.
Examples
pbmc <- normalize(pbmc)
#> ℹ Normalizing datasets "ctrl"
#> ℹ Normalizing datasets "stim"
#> ✔ Normalizing datasets "stim" ... done
#>
#> ℹ Normalizing datasets "ctrl"
#> ✔ Normalizing datasets "ctrl" ... done
#>
pbmc <- selectGenes(pbmc)
#> ℹ Selecting variable features for dataset "ctrl"
#> ✔ ... 168 features selected out of 249 shared features.
#> ℹ Selecting variable features for dataset "stim"
#> ✔ ... 166 features selected out of 249 shared features.
#> ✔ Finally 173 shared variable features are selected.
pbmc <- scaleNotCenter(pbmc)
#> ℹ Scaling dataset "ctrl"
#> ✔ Scaling dataset "ctrl" ... done
#>
#> ℹ Scaling dataset "stim"
#> ✔ Scaling dataset "stim" ... done
#>
# Only running a few iterations for fast examples
if (requireNamespace("RcppPlanc", quietly = TRUE)) {
pbmc <- runINMF(pbmc, k = 20, nIteration = 2)
pbmc <- optimizeNewK(pbmc, kNew = 25, nIteration = 2)
}
#> Fri Oct 25 15:12:33 2024 ... Initializing with new k...