R/ctd_to_se.R

Defines functions ctd_to_se

Documented in ctd_to_se

#' Convert: \code{CellTypeDataset} ==> \code{SingleCellExperiment}
#'
#' @inheritParams converters
#' @inheritParams to_se
#' @export
#' @examples
#' obj <- example_obj("ctd")
#' obj <- ctd_to_se(obj)
ctd_to_se <- function(obj,
                      as_sce=FALSE,
                      as_sparse=TRUE,
                      as_delayedarray=FALSE,
                      verbose=TRUE){

  requireNamespace("EWCE")

  messager_to()
  if(is_ctd(obj)){
    obj2 <- EWCE::ctd_to_sce(object = obj,
                             as_sparse = as_sparse,
                             as_DelayedArray = as_delayedarray,
                             verbose = verbose)
  } else{
    stopper("obj must be a CellTypeDataset",
            "generated by EWCE::generate_celltype_data().")
  }
  if(isFALSE(as_sce)){
    obj2 <- lapply(obj2,sce_to_se, verbose = verbose)
  }
  return(obj2)
}
bschilder/scKirby documentation built on Oct. 2, 2024, 10:16 p.m.