Learn R Programming

rliger (version 1.0.0)

optimizeNewData: Perform factorization for new data

Description

Uses an efficient strategy for updating that takes advantage of the information in the existing factorization. Assumes that selected genes (var.genes) are represented in the new datasets.

Usage

optimizeNewData(
  object,
  new.data,
  which.datasets,
  add.to.existing = TRUE,
  lambda = NULL,
  thresh = 1e-04,
  max.iters = 100,
  verbose = TRUE
)

Arguments

object

liger object. Should call optimizeALS before calling.

new.data

List of raw data matrices (one or more). Each list entry should be named.

which.datasets

List of datasets to append new.data to if add.to.existing is true. Otherwise, the most similar existing datasets for each entry in new.data.

add.to.existing

Add the new data to existing datasets or treat as totally new datasets (calculate new Vs?) (default TRUE)

lambda

Regularization parameter. By default, this will use the lambda last used with optimizeALS.

thresh

Convergence threshold. Convergence occurs when |obj0-obj|/(mean(obj0,obj)) < thresh (default 1e-4).

max.iters

Maximum number of block coordinate descent iterations to perform (default 100).

verbose

Print progress bar/messages (TRUE by default)

Value

liger object with H, W, and V slots reset. Raw.data, norm.data, and scale.data will also be updated to include the new data.

Examples

Run this code
# NOT RUN {
# Given preprocessed liger object: ligerex (contains two datasets Y and Z)
# get factorization using three restarts and 20 factors
ligerex <- optimizeALS(ligerex, k = 20, lambda = 5, nrep = 3)
# acquire new data (Y_new, Z_new) from the same cell type, let's add it to existing datasets
new_data <- list(Y_set = Y_new, Z_set = Z_new)
ligerex2 <- optimizeNewData(ligerex, new.data = new_data, which.datasets = list('y_set', 'z_set'))
# acquire new data from different cell type (X), we'll just add another dataset
# it's probably most similar to y_set
ligerex <- optimizeNewData(ligerex, new.data = list(x_set = X), which.datasets = list('y_set'),
                           add.to.existing = FALSE)
# }

Run the code above in your browser using DataLab