Skip to contents

Force an object to belong to a class

Note

Updated 2023-08-16.

Examples

data(Seurat, SingleCellExperiment_Seurat, package = "AcidTest")

## SingleCellExperiment to Seurat ====
from <- SingleCellExperiment_Seurat
to <- as(from, "Seurat")
class(to)
#> [1] "Seurat"
#> attr(,"package")
#> [1] "SeuratObject"
print(to)
#> An object of class Seurat 
#> 230 features across 80 samples within 1 assay 
#> Active assay: RNA (230 features, 0 variable features)
#>  2 layers present: counts, data

## Seurat to SingleCellExperiment ====
from <- Seurat
to <- as(from, "SingleCellExperiment")
class(to)
#> [1] "SingleCellExperiment"
#> attr(,"package")
#> [1] "SingleCellExperiment"
print(to)
#> class: SingleCellExperiment 
#> dim: 230 80 
#> metadata(2): scaleData variableFeatures
#> assays(2): counts logcounts
#> rownames(230): MS4A1 CD79B ... SPON2 S100B
#> rowData names(6): broadClass geneBiotype ... ncbiGeneId seqCoordSystem
#> colnames(80): ATGCCAGAACGACT CATGGCCTGTGCAT ... GGAACACTTCAGAC
#>   CTTGATTGATCTTC
#> colData names(8): orig.ident nCount_RNA ... RNA_snn_res.1 ident
#> reducedDimNames(3): PCA TSNE UMAP
#> mainExpName: RNA
#> altExpNames(0):