R/set_projection.R

Defines functions set_projection

Documented in set_projection

#' Set projections of Spaco Object
#'
#' @param SpaCoObject Fitted object of class \code{SpaCoObject} as returned from [SpaCo] on which to update the projection slot with new data.
#' @param data gene expression data matrix; p genes as columns, n loci as rows
#' @param neighborhood neighborhood matrix of the new data. Must be of dimension n times n, where n is the number of columns of \code{data}
#' @return
#' Returns the SpaCoObject with the updated data, neighborhood matrix, and projection matrix.
#' @export
set_projection <- function(SpaCoObject,
                           data,
                           neighborhood = SpaCoObject@neighbours) {
  SpaCoObject@data <- data
  GL <- computeGraphLaplacian(neighborhood)
  SpaCoObject@GraphLaplacian <- GL
  SpaCoObject@projection <-
    eigenMapMatMult(data, SpaCoObject@spacs)
  SpaCoObject
}

Try the SPACO package in your browser

Any scripts or data that you put into this service are public.

SPACO documentation built on March 31, 2026, 5:07 p.m.