For more information on the functionality of an AnnData object, see anndataR-package.
Usage
AnnData(
X = NULL,
obs = NULL,
var = NULL,
layers = NULL,
obsm = NULL,
varm = NULL,
obsp = NULL,
varp = NULL,
uns = NULL,
shape = shape
)
Arguments
- X
Either
NULL
or a observation × variable matrix with dimensions consistent withobs
andvar
.- obs
Either
NULL
or adata.frame
with columns containing information about observations. IfNULL
, ann_obs
×0 data frame will automatically be generated.- var
Either
NULL
or adata.frame
with columns containing information about variables. IfNULL
, ann_vars
×0 data frame will automatically be generated.- layers
Either
NULL
or a named list, where each element is an observation × variable matrix with dimensions consistent withobs
andvar
.- obsm
The obsm slot is used to store multi-dimensional annotation arrays. It must be either
NULL
or a named list, where each element is a matrix withn_obs
rows and an arbitrary number of columns.- varm
The varm slot is used to store multi-dimensional annotation arrays. It must be either
NULL
or a named list, where each element is a matrix withn_vars
rows and an arbitrary number of columns.- obsp
The obsp slot is used to store sparse multi-dimensional annotation arrays. It must be either
NULL
or a named list, where each element is a sparse matrix where each dimension has lengthn_obs
.- varp
The varp slot is used to store sparse multi-dimensional annotation arrays. It must be either
NULL
or a named list, where each element is a sparse matrix where each dimension has lengthn_vars
.- uns
The uns slot is used to store unstructured annotation. It must be either
NULL
or a named list.- shape
Shape tuple (#observations, #variables). Can be provided if
X
orobs
andvar
are not provided.
Examples
adata <- AnnData(
X = matrix(1:12, nrow = 3, ncol = 4),
obs = data.frame(
row.names = paste0("obs", 1:3),
n_counts = c(1, 2, 3),
n_cells = c(1, 2, 3)
),
var = data.frame(
row.names = paste0("var", 1:4),
n_cells = c(1, 2, 3, 4)
)
)
adata
#> AnnData object with n_obs × n_vars = 3 × 4
#> obs: 'n_counts', 'n_cells'
#> var: 'n_cells'