Skip to contents

# Export Census slices to `SingleCellExperiment`

Source: `R/get_helpers.R`
`get_single_cell_experiment.Rd`

Convenience wrapper around `SOMAExperimentAxisQuery`, to build and execute a query, and return it as a `SingleCellExperiment` object.

## Usage

    get_single_cell_experiment(
      census,
      organism,
      measurement_name = "RNA",
      X_layers = c(counts = "raw"),
      obs_value_filter = NULL,
      obs_coords = NULL,
      obs_column_names = NULL,
      obsm_layers = FALSE,
      var_value_filter = NULL,
      var_coords = NULL,
      var_column_names = NULL,
      var_index = "feature_id"
    )

## Arguments

census

  The census object, usually returned by `cellxgene.census::open_soma()`.

organism

  The organism to query, usually one of `Homo sapiens` or `Mus musculus`

measurement_name

  The measurement object to query. Defaults to `RNA`.

X_layers

  A character vector of X layers to add as assays in the main experiment; may optionally be named to set the name of the resulting assay (eg. ‘X_layers = c(counts = "raw")’ will load in X layer “‘raw’” as assay “‘counts’”); by default, loads in all X layers

obs_value_filter

  A SOMA `value_filter` across columns in the `obs` dataframe, expressed as string.

obs_coords

  A set of coordinates on the obs dataframe index, expressed in any type or format supported by SOMADataFrame's read() method.

obs_column_names

  Columns to fetch for the `obs` data frame.

obsm_layers

  Names of arrays in obsm to add as the cell embeddings; pass FALSE to suppress loading in any dimensional reductions.

var_value_filter

  Same as `obs_value_filter` but for `var`.

var_coords

  Same as `obs_coords` but for `var`.

var_column_names

  Columns to fetch for the `var` data frame.

var_index

  Name of column in ‘var’ to add as feature names.

## Value

A `SingleCellExperiment` object containing the sensus slice.

## Examples

    if (FALSE) { # \dontrun{
    census <- open_soma()
    sce_obj <- get_single_cell_experiment(
      census,
      organism = "Homo sapiens",
      obs_value_filter = "cell_type == 'leptomeningeal cell'",
      var_value_filter = "feature_id %in% c('ENSG00000107317', 'ENSG00000106034')"
    )

    sce_obj

    census$close()
    } # }