Get and set layer data

# S3 method for Assay
[(x, i = missing_arg(), j = missing_arg(), ...)

# S4 method for Assay,character,ANY,ANY
[(x, i, j, ...) <- value

Arguments

x

An Assay object

i

Name of layer data to get or set

j

Ignored

...

Arguments passed to LayerData

value

A matrix-like object to add as a new layer

Value

[: The layer data for layer i

[<-: x with layer data value saved as i

See also

LayerData

v3 Assay object, validity, and interaction methods: $.Assay(), Assay-class, Assay-validity, CreateAssayObject(), [[.Assay(), dim.Assay(), dimnames.Assay(), merge.Assay(), split.Assay(), subset.Assay()

Examples

rna <- pbmc_small[["RNA"]]

# Get a vector of layer names in this assay
rna[]
#> [1] "counts"     "data"       "scale.data"

# Fetch layer data
rna["data"][1:10, 1:4]
#> 10 x 4 sparse Matrix of class "dgCMatrix"
#>           ATGCCAGAACGACT CATGGCCTGTGCAT GAACCTGATGAACC TGACTGGATTCTCA
#> MS4A1           .              .              .              .       
#> CD79B           4.968821       .              .              .       
#> CD79A           .              .              .              .       
#> HLA-DRA         .              4.776153       .              .       
#> TCL1A           .              .              .              .       
#> HLA-DQB1        4.968821       .              .              .       
#> HVCN1           .              .              .              .       
#> HLA-DMB         .              .              .              .       
#> LTB             6.062788       6.714813       7.143118       6.932079
#> LINC00926       .              .              .              .       

# Set layer data
rna["data"] <- rna["counts"]
rna["data"][1:10, 1:4]
#> 10 x 4 sparse Matrix of class "dgCMatrix"
#>           ATGCCAGAACGACT CATGGCCTGTGCAT GAACCTGATGAACC TGACTGGATTCTCA
#> MS4A1                  .              .              .              .
#> CD79B                  1              .              .              .
#> CD79A                  .              .              .              .
#> HLA-DRA                .              1              .              .
#> TCL1A                  .              .              .              .
#> HLA-DQB1               1              .              .              .
#> HVCN1                  .              .              .              .
#> HLA-DMB                .              .              .              .
#> LTB                    3              7             11             13
#> LINC00926              .              .              .              .