Convert objects (Seurat & LIGER) to anndata objects
as.anndata(x, ...)
# S3 method for Seurat
as.anndata(
x,
file_path,
file_name,
assay = NULL,
main_layer = "data",
other_layers = "counts",
transer_dimreduc = TRUE,
verbose = TRUE,
...
)
# S3 method for liger
as.anndata(
x,
file_path,
file_name,
transfer_norm.data = FALSE,
reduction_label = NULL,
add_barcode_names = FALSE,
barcode_prefix = TRUE,
barcode_cell_id_delimiter = "_",
verbose = TRUE,
...
)
Seurat or LIGER object
Arguments passed to other methods
directory file path and/or file name prefix. Defaults to current wd.
file name.
Assay containing data to use, (default is object default assay).
the layer of data to become default layer in anndata object (default is "data").
other data layers to transfer to anndata object (default is "counts").
logical, whether to transfer dimensionality reduction coordinates from Seurat to anndata object (default is TRUE).
logical, whether to print status messages during object conversion (default is TRUE).
logical, whether to transfer the norm.data in addition to raw.data, default is FALSE.
What to label the visualization dimensionality reduction. LIGER does not store name of technique and therefore needs to be set manually.
logical, whether to add dataset names to the cell barcodes when merging object data, default is FALSE.
logical, if add_barcode_names = TRUE
should the names be added as
prefix to current cell barcodes/names or a suffix (default is TRUE; prefix).
The delimiter to use when adding dataset id to barcode prefix/suffix. Default is "_".
an anndata object generated from x
, saved at path provided.
Seurat version modified and enhanced version of sceasy::seurat2anndata
(sceasy package: https://github.com/cellgeni/sceasy; License: GPL-3. Function has additional checks and supports Seurat V3 and V5 object structure.
LIGER version inspired by sceasy::seurat2anndata
modified and updated to apply to LIGER objects (sceasy package: https://github.com/cellgeni/sceasy; License: GPL-3.
if (FALSE) {
as.anndata(x = seurat_object, file_path = "/folder_name", file_name = "anndata_converted.h5ad")
}
if (FALSE) {
as.anndata(x = liger_object, file_path = "/folder_name", file_name = "anndata_converted.h5ad")
}