Skip to contents

Reverse direction of `convert_to_anndata()` for the SCE branch. `adata$X` (or `adata$layers[[counts_layer]]` if present) becomes the `counts` assay, additional layers become other assays, `adata$obs` is written to `colData`, `adata$var` to `rowData`, and `adata$obsm` entries to `reducedDims`.

Usage

convert_anndata_to_sce(
  adata,
  counts_layer = c("counts", "raw_counts", "raw_count"),
  conda_env = NULL
)

Arguments

adata

An AnnData object, OR a character path to an `.h5ad` file (in which case it is read with `anndata::read_h5ad()`).

counts_layer

Name(s) of the layer in `adata$layers` to use as the `counts` assay. May be a single string or a character vector of candidates; the first one present in `adata$layers` is used. If none are present, `adata$X` is used as `counts`. Defaults to `c("counts", "raw_counts", "raw_count")`.

conda_env

Optional conda environment to activate before reading the file. Equivalent to calling `setup_anndata_python(conda_env)` first. Only relevant when `adata` is a path.

Value

A SingleCellExperiment object.

Examples

if (FALSE) { # \dontrun{
# Path entrypoint:
sce <- convert_anndata_to_sce("pbmc.h5ad")
# Object entrypoint:
adata <- anndata::read_h5ad("pbmc.h5ad")
sce <- convert_anndata_to_sce(adata)
} # }