R/dimreduc_to_list.R

Defines functions dimreduc_to_list

Documented in dimreduc_to_list

#' Convert: \code{DimReduc} ==> \code{list}
#'
#' @inheritParams converters
#' @export
#' @examples
#' obj <- example_obj("anndata")
#' obj2 <- anndata_to_list(obj)
dimreduc_to_list <- function(obj){
  messager_to()
  res <- list()
  slots <- methods::slotNames(obj)
  if("cell.embeddings" %in% slots) {
    res[["obsm"]] <- obj@cell.embeddings
  }
  if("feature.loadings" %in% slots) {
    res[["varm"]] <- obj@feature.loadings
  }
  if("feature.loadings.projected" %in% slots) {
    res[["varm_projected"]] <- obj@feature.loadings.projected
  }
  return(res)
}
bschilder/scKirby documentation built on Oct. 2, 2024, 10:16 p.m.