Skip to contents

A lazy view of an AnnData object that allows applying subsetting operations without immediately executing them. Subsetting is applied when converting to a concrete AnnData implementation (InMemoryAnnData, HDF5AnnData) or other formats (SingleCellExperiment, Seurat).

Value

A AnnDataView object

See also

AnnData-usage for details on creating and using AnnData objects

Other AnnData classes: AbstractAnnData, HDF5AnnData, InMemoryAnnData, ReticulateAnnData

Super class

anndataR::AbstractAnnData -> AnnDataView

Active bindings

X

See AnnData-usage

layers

See AnnData-usage

obs

See AnnData-usage

var

See AnnData-usage

obs_names

See AnnData-usage

var_names

See AnnData-usage

obsm

See AnnData-usage

varm

See AnnData-usage

obsp

See AnnData-usage

varp

See AnnData-usage

uns

See AnnData-usage

Methods

Inherited methods


Method new()

Create a new AnnDataView object

Usage

AnnDataView$new(base_adata, i, j)

Arguments

base_adata

An existing AnnData object to create a view of

i

Optional initial obs subset (logical, integer, or character vector)

j

Optional initial var subset (logical, integer, or character vector)

Returns

A new AnnDataView object Subset the AnnDataView


Method subset()

Usage

AnnDataView$subset(i, j)

Arguments

i

Row indices (observations). Can be numeric, logical, or character.

j

Column indices (variables). Can be numeric, logical, or character.

Returns

A new AnnDataView object


Method clone()

The objects of this class are cloneable with this method.

Usage

AnnDataView$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Create a base AnnData object
ad <- AnnData(
  X = matrix(1:15, 3L, 5L),
  obs = data.frame(row.names = LETTERS[1:3], cell_type = c("A", "B", "A")),
  var = data.frame(row.names = letters[1:5], gene_type = c("X", "Y", "X", "Y", "Z"))
)

# Create a view with lazy subsetting using S3 [ method
view <- ad[ad$obs$cell_type == "A", ad$var$gene_type %in% c("X", "Y")]

# Apply subsetting by converting to a concrete implementation
result <- view$as_InMemoryAnnData()