Skip to contents

Works for converting a matrix or container object to a single ligerDataset, and can also convert the modality preset of a ligerDataset. When used with a dense matrix object, it automatically converts the matrix to sparse form (dgCMatrix-class). When used with container objects such as Seurat or SingleCellExperiment, it is highly recommended that the object contains only one dataset/sample which is going to be integrated with LIGER. For multi-sample objects, please use as.liger with dataset source variable specified.

Usage

# S3 method for ligerDataset
as.ligerDataset(
  object,
  modal = c("default", "rna", "atac", "spatial", "meth"),
  ...
)

# S3 method for default
as.ligerDataset(
  object,
  modal = c("default", "rna", "atac", "spatial", "meth"),
  ...
)

# S3 method for matrix
as.ligerDataset(
  object,
  modal = c("default", "rna", "atac", "spatial", "meth"),
  ...
)

# S3 method for Seurat
as.ligerDataset(
  object,
  modal = c("default", "rna", "atac", "spatial", "meth"),
  assay = NULL,
  ...
)

# S3 method for SingleCellExperiment
as.ligerDataset(
  object,
  modal = c("default", "rna", "atac", "spatial", "meth"),
  ...
)

as.ligerDataset(object, ...)

Arguments

object

Object.

modal

Modality setting for each dataset. Choose from "default", "rna", "atac", "spatial", "meth".

...

Additional arguments passed to createLigerDataset

assay

Name of assay to use. Default NULL uses current active assay.

Value

a liger object.

Examples

ctrl <- dataset(pbmc, "ctrl")
ctrl
#> An object of class ligerDataset with 300 cells
#> rawData: 266 features
# Convert the modality preset
as.ligerDataset(ctrl, modal = "atac")
#> An object of class ligerATACDataset with 300 cells
#> rawData: 266 features
rawCounts <- rawData(ctrl)
class(rawCounts)
#> [1] "dgCMatrix"
#> attr(,"package")
#> [1] "Matrix"
as.ligerDataset(rawCounts)
#> An object of class ligerDataset with 300 cells
#> rawData: 266 features