liger
object is the main data container for LIGER
analysis in R. The slot datasets
is a list where each element should
be a ligerDataset object containing dataset specific
information, such as the expression matrices. The other parts of liger object
stores information that can be shared across the analysis, such as the cell
metadata.
This manual provides explanation to the liger
object structure as well
as usage of class-specific methods. Please see detail sections for more
information.
For liger
objects created with older versions of rliger package,
please try updating the objects individually with
convertOldLiger
.
Usage
datasets(x, check = NULL)
datasets(x, check = TRUE) <- value
dataset(x, dataset = NULL)
dataset(x, dataset, type = NULL, qc = TRUE) <- value
cellMeta(
x,
columns = NULL,
useDatasets = NULL,
cellIdx = NULL,
as.data.frame = FALSE,
...
)
cellMeta(
x,
columns = NULL,
useDatasets = NULL,
cellIdx = NULL,
inplace = FALSE,
check = FALSE
) <- value
defaultCluster(x, useDatasets = NULL, ...)
defaultCluster(x, name = NULL, useDatasets = NULL, ...) <- value
dimReds(x)
dimReds(x) <- value
dimRed(x, name = NULL, useDatasets = NULL, cellIdx = NULL, ...)
dimRed(x, name = NULL, useDatasets = NULL, cellIdx = NULL, ...) <- value
defaultDimRed(x, useDatasets = NULL, cellIdx = NULL)
defaultDimRed(x) <- value
varFeatures(x)
varFeatures(x, check = TRUE) <- value
varUnsharedFeatures(x, dataset = NULL)
varUnsharedFeatures(x, dataset, check = TRUE) <- value
commands(x, funcName = NULL, arg = NULL)
# S4 method for liger
show(object)
# S4 method for liger
dim(x)
# S4 method for liger
dimnames(x)
# S4 method for liger,list
dimnames(x) <- value
# S4 method for liger
datasets(x, check = NULL)
# S4 method for liger,logical
datasets(x, check = TRUE) <- value
# S4 method for liger,missing
datasets(x, check = TRUE) <- value
# S4 method for liger,character_OR_NULL
dataset(x, dataset = NULL)
# S4 method for liger,missing
dataset(x, dataset = NULL)
# S4 method for liger,numeric
dataset(x, dataset = NULL)
# S4 method for liger,character,missing,ANY,ligerDataset
dataset(x, dataset, type = NULL, qc = TRUE) <- value
# S4 method for liger,character,ANY,ANY,matrixLike
dataset(x, dataset, type = c("rawData", "normData"), qc = FALSE) <- value
# S4 method for liger,character,missing,ANY,NULL
dataset(x, dataset, type = NULL, qc = TRUE) <- value
# S3 method for liger
names(x)
# S3 method for liger
names(x) <- value
# S3 method for liger
length(x)
# S3 method for liger
lengths(x, use.names = TRUE)
# S4 method for liger,NULL
cellMeta(
x,
columns = NULL,
useDatasets = NULL,
cellIdx = NULL,
as.data.frame = FALSE,
...
)
# S4 method for liger,character
cellMeta(
x,
columns = NULL,
useDatasets = NULL,
cellIdx = NULL,
as.data.frame = FALSE,
...
)
# S4 method for liger,missing
cellMeta(
x,
columns = NULL,
useDatasets = NULL,
cellIdx = NULL,
as.data.frame = FALSE,
...
)
# S4 method for liger,missing
cellMeta(x, columns = NULL, useDatasets = NULL, cellIdx = NULL, check = FALSE) <- value
# S4 method for liger,character
cellMeta(
x,
columns = NULL,
useDatasets = NULL,
cellIdx = NULL,
inplace = TRUE,
check = FALSE
) <- value
# S4 method for liger
rawData(x, dataset = NULL)
# S4 method for liger,ANY,ANY,matrixLike_OR_NULL
rawData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger,ANY,ANY,H5D
rawData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger
normData(x, dataset = NULL)
# S4 method for liger,ANY,ANY,matrixLike_OR_NULL
normData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger,ANY,ANY,H5D
normData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger,ANY
scaleData(x, dataset = NULL)
# S4 method for liger,ANY,ANY,matrixLike_OR_NULL
scaleData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger,ANY,ANY,H5D
scaleData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger,ANY,ANY,H5Group
scaleData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger,character
scaleUnsharedData(x, dataset = NULL)
# S4 method for liger,numeric
scaleUnsharedData(x, dataset = NULL)
# S4 method for liger,ANY,ANY,matrixLike_OR_NULL
scaleUnsharedData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger,ANY,ANY,H5D
scaleUnsharedData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger,ANY,ANY,H5Group
scaleUnsharedData(x, dataset = NULL, check = TRUE) <- value
# S4 method for liger,ANY,ANY,ANY
getMatrix(
x,
slot = c("rawData", "normData", "scaleData", "scaleUnsharedData", "H", "V", "U", "A",
"B", "W", "H.norm"),
dataset = NULL,
returnList = FALSE
)
# S4 method for liger,ANY
getH5File(x, dataset = NULL)
# S3 method for liger
[[(x, i) <- value
# S3 method for liger
$(x, name)
# S3 method for liger
$(x, name) <- value
# S4 method for liger
defaultCluster(x, useDatasets = NULL, droplevels = FALSE, ...)
# S4 method for liger,ANY,ANY,character
defaultCluster(x, name = NULL, useDatasets = NULL, ...) <- value
# S4 method for liger,ANY,ANY,factor
defaultCluster(x, name = NULL, useDatasets = NULL, droplevels = TRUE, ...) <- value
# S4 method for liger,ANY,ANY,NULL
defaultCluster(x, name = NULL, useDatasets = NULL, ...) <- value
# S4 method for liger
dimReds(x)
# S4 method for liger,list
dimReds(x) <- value
# S4 method for liger,missing_OR_NULL
dimRed(x, name = NULL, useDatasets = NULL, cellIdx = NULL, ...)
# S4 method for liger,index
dimRed(x, name = NULL, useDatasets = NULL, cellIdx = NULL, ...)
# S4 method for liger,index,ANY,ANY,NULL
dimRed(x, name = NULL, useDatasets = NULL, cellIdx = NULL, ...) <- value
# S4 method for liger,character,ANY,ANY,matrixLike
dimRed(
x,
name = NULL,
useDatasets = NULL,
cellIdx = NULL,
asDefault = NULL,
inplace = FALSE,
...
) <- value
# S4 method for liger
defaultDimRed(x, useDatasets = NULL, cellIdx = NULL)
# S4 method for liger,character
defaultDimRed(x) <- value
# S4 method for liger
varFeatures(x)
# S4 method for liger,ANY,character
varFeatures(x, check = TRUE) <- value
# S4 method for liger,ANY
varUnsharedFeatures(x, dataset = NULL)
# S4 method for liger,ANY,ANY,character
varUnsharedFeatures(x, dataset, check = TRUE) <- value
# S3 method for liger
fortify(model, data, ...)
# S3 method for liger
c(...)
# S4 method for liger
commands(x, funcName = NULL, arg = NULL)
# S4 method for ligerDataset,missing
varUnsharedFeatures(x, dataset = NULL)
# S4 method for ligerDataset,missing,ANY,character
varUnsharedFeatures(x, dataset = NULL, check = TRUE) <- value
Arguments
- x, object, model
A liger object
- check
Logical, whether to perform object validity check on setting new value. Users are not supposed to set
FALSE
here.- value
Metadata value to be inserted
- dataset
Name or numeric index of a dataset
- type
When using
dataset<-
with a matrix likevalue
, specify what type the matrix is. Choose from"rawData"
,"normData"
or"scaleData"
.- qc
Logical, whether to perform general qc on added new dataset.
- columns
The names of available variables in
cellMeta
slot. Whenas.data.frame = TRUE
, please use variable names after coercion.- useDatasets
Setter or getter method should only apply on cells in specified datasets. Any valid character, numeric or logical subscriber is acceptable. Default
NULL
works with all datasets.- cellIdx
Valid cell subscription to subset retrieved variables. Default
NULL
uses all cells.- as.data.frame
Logical, whether to apply
as.data.frame
on the subscription. DefaultFALSE
.- ...
See detailed sections for explanation.
- inplace
For
cellMeta<-
method, whencolumns
is for existing variable anduseDatasets
orcellIdx
indicate partial insertion to the object, whether to by default (TRUE
) in-place insertvalue
into the variable for selected cells or to replace the whole variable with non-selected part left as NA.- name
The name of available variables in
cellMeta
slot or the name of a new variable to store.- funcName, arg
See Command records section.
- use.names
Whether returned vector should be named with dataset names.
- slot
Name of slot to retrieve matrix from. Options shown in Usage.
- returnList
Logical, whether to force return a list even when only one dataset-specific matrix (i.e. expression matrices, H, V or U) is requested. Default
FALSE
.- i
Name or numeric index of cell meta variable to be replaced
- droplevels
Whether to remove unused cluster levels from the factor object fetched by
defaultCluster()
. DefaultFALSE
.- asDefault
Whether to set the inserted dimension reduction matrix as default for visualization methods. Default
NULL
sets it when no default has been set yet, otherwise does not change current default.- data
fortify method required argument. Not used.
Value
See detailed sections for explanetion.
Input liger object updated with replaced/new variable in
cellMeta(x)
.
Slots
datasets
list of ligerDataset objects. Use generic
dataset
,dataset<-
,datasets
ordatasets<-
to interact with. See detailed section accordingly.cellMeta
DFrame object for cell metadata. Pre-existing metadata, QC metrics, cluster labeling and etc. are all stored here. Use generic
cellMeta
,cellMeta<-
,$
,[[]]
or[[]]<-
to interact with. See detailed section accordingly.varFeatures
Character vector of names of variable features. Use generic
varFeatures
orvarFeatures<-
to interact with. See detailed section accordingly.W
iNMF output matrix of shared gene loadings for each factor. See
runIntegration
.H.norm
Matrix of aligned factor loading for each cell. See
alignFactors
andrunIntegration
.commands
List of ligerCommand objects. Record of analysis. Use
commands
to retrieve information. See detailed section accordingly.uns
List for unstructured meta-info of analyses or presets.
version
Record of version of rliger package
Dataset access
datasets()
method only accesses the datasets
slot, the list of
ligerDataset objects. dataset()
method accesses a single
dataset, with subsequent cell metadata updates and checks bonded when adding
or modifying a dataset. Therefore, when users want to modify something inside
a ligerDataset
while no cell metadata change should happen, it is
recommended to use: datasets(x)[[name]] <- ligerD
for efficiency,
though the result would be the same as dataset(x, name) <- ligerD
.
length()
and names()
methods are implemented to access the
number and names of datasets. names<-
method is supported for
modifying dataset names, with taking care of the "dataset" variable in cell
metadata.
Matrix access
For liger
object, rawData()
, normData
,
scaleData()
and scaleUnsharedData()
methods are exported for
users to access the corresponding feature expression matrix with
specification of one dataset. For retrieving a type of matrix from multiple
datasets, please use getMatrix()
method.
When only one matrix is expected to be retrieved by getMatrix()
, the
matrix itself will be returned. A list will be returned if multiple matrices
is requested (by querying multiple datasets) or returnList
is set to
TRUE
.
Cell metadata access
Three approaches are provided for access of cell metadata. A generic function
cellMeta
is implemented with plenty of options and multi-variable
accessibility. Besides, users can use double-bracket (e.g.
ligerObj[[varName]]
) or dollor-sign (e.g. ligerObj$nUMI
) to
access or modify single variables.
For users' convenience of generating a customized ggplot with available cell
metadata, the S3 method fortify.liger
is implemented. With this under
the hook, users can create simple ggplots by directly starting with
ggplot(ligerObj, aes(...))
where cell metadata variables can be
directly thrown into aes()
.
Special partial metadata insertion is implemented specifically for mapping
categorical annotation from sub-population (subset object) back to original
experiment (full-size object). For example, when sub-clustering and
annotation is done for a specific cell-type of cells (stored in
subobj
) subset from an experiment (stored as obj
), users can do
cellMeta(obj, "sub_ann", cellIdx = colnames(subobj)) <- subobj$sub_ann
to map the value back, leaving other cells non-annotated with NAs. Plotting
with this variable will then also show NA cells with default grey color.
Furthermore, sub-clustering labels for other cell types can also be mapped
to the same variable. For example, cellMeta(obj, "sub_ann",
cellIdx = colnames(subobj2)) <- subobj2$sub_ann
. As long as the labeling
variables are stored as factor class (categorical), the levels (category
names) will be properly handled and merged. Other situations follow the R
default behavior (e.g. categories might be converted to integer numbers if
mapped to numerical variable in the original object). Note that this feature
is only available with using the generic function cellMeta
but not
with the `[[`
or `$`
accessing methods due to syntax reasons.
The generic defaultCluster
works as both getter and setter. As a
setter, users can do defaultCluster(obj) <- "existingVariableName"
to
set a categorical variable as default cluster used for visualization or
downstream analysis. Users can also do defaultCluster(obj,
"newVarName") <- factorOfLabels
to push new labeling into the object and set
as default. For getter method, the function returns a factor object of the
default cluster labeling. Argument useDatasets
can be used for
requiring that given or retrieved labeling should match with cells in
specified datasets. We generally don't recommend setting "dataset"
as
a default cluster because it is a preserved (always existing) field in
metadata and can lead to meaningless result when running analysis that
utilizes both clustering information and the dataset source information.
Dimension reduction access
Currently, low-dimensional representaion of cells, presented as dense
matrices, are all stored in dimReds
slot, and can totally be accessed
with generics dimRed
and dimRed<-
. Adding a dimRed to the
object looks as simple as dimRed(obj, "name") <- matrixLike
. It can
be retrieved back with dimRed(obj, "name")
. Similar to having a
default cluster labeling, we also constructed the feature of default dimRed.
It can be set with defaultDimRed(obj) <- "existingMatLikeVar"
and the
matrix can be retrieved with defaultDimRed(obj)
.
Variable feature access
The varFeatures
slot allows for character vectors of gene names.
varFeatures(x)
returns this vector and value
for
varFeatures<-
method has to be a character vector or NULL
.
The replacement method, when check = TRUE
performs checks on gene
name consistency check across the scaleData
, H
, V
slots
of inner ligerDataset
objects as well as the W
and
H.norm
slots of the input liger
object.
Command records
rliger functions, that perform calculation and update the liger
object, will be recorded in a ligerCommand
object and stored in the
commands
slot, a list, of liger
object. Method
commands()
is implemented to retrieve or show the log history.
Running with funcName = NULL
(default) returns all command labels.
Specifying funcName
allows partial matching to all command labels
and returns a subset list (of ligerCommand
object) of matches (or
the ligerCommand
object if only one match found). If arg
is
further specified, a subset list of parameters from the matches will be
returned. For example, requesting a list of resolution values used in
all louvain cluster attempts: commands(ligerObj, "louvainCluster",
"resolution")
Dimensionality
For a liger
object, the column orientation is assigned for
cells. Due to the data structure, it is hard to define a row index for the
liger
object, which might contain datasets that vary in number of
genes.
Therefore, for liger
objects, dim
and dimnames
returns
NA
/NULL
for rows and total cell counts/barcodes for the
columns.
For direct call of dimnames<-
method, value
should be a list
with NULL
as the first element and valid cell identifiers as the
second element. For colnames<-
method, the character vector of cell
identifiers. rownames<-
method is not applicable.
Subsetting
For more detail of subsetting a liger
object or a
ligerDataset object, please check out subsetLiger
and subsetLigerDataset
. Here, we set the S4 method
"single-bracket" [
as a quick wrapper to subset a liger
object.
Note that j
serves as cell subscriptor which can be any valid index
refering the collection of all cells (i.e. rownames(cellMeta(obj))
).
While i
, the feature subscriptor can only be character vector because
the features for each dataset can vary. ...
arugments are passed to
subsetLiger
so that advanced options are allowed.
Combining multiple liger object
The list of datasets
slot,
the rows of cellMeta
slot and the list of commands
slot will
be simply concatenated. Variable features in varFeatures
slot will be
taken a union. The \(W\) and \(H.norm\) matrices are not taken into
account for now.
Examples
# Methods for base generics
pbmcPlot
#> An object of class liger with 600 cells
#> datasets(2): ctrl (300 cells), stim (300 cells)
#> cellMeta(3): dataset, nUMI, leiden_cluster
#> varFeatures(50): ISG15, ID3, RPL11, ..., HIST1H2AC
#> dimReds(1): UMAP
print(pbmcPlot)
#> An object of class liger with 600 cells
#> datasets(2): ctrl (300 cells), stim (300 cells)
#> cellMeta(3): dataset, nUMI, leiden_cluster
#> varFeatures(50): ISG15, ID3, RPL11, ..., HIST1H2AC
#> dimReds(1): UMAP
dim(pbmcPlot)
#> [1] NA 600
ncol(pbmcPlot)
#> [1] 600
colnames(pbmcPlot)[1:5]
#> [1] "ctrl_AAACATACCTCGCT.1" "ctrl_AAACGGCTCTTCGC.1" "ctrl_AACACTCTAAGTAG.1"
#> [4] "ctrl_AACCGCCTCAGGAG.1" "ctrl_AACGTTCTTCCGTC.1"
pbmcPlot[varFeatures(pbmcPlot)[1:10], 1:10]
#> ℹ Subsetting dataset: "ctrl"
#> ✔ Subsetting dataset: "ctrl" ... done
#>
#> An object of class liger with 10 cells
#> datasets(1): ctrl (10 cells)
#> cellMeta(3): dataset, nUMI, leiden_cluster
#> varFeatures(10): ISG15, ID3, RPL11, ..., S100A8
#> dimReds(1): UMAP
names(pbmcPlot)
#> [1] "ctrl" "stim"
length(pbmcPlot)
#> [1] 2
# rliger generics
## Retrieving dataset(s), replacement methods available
datasets(pbmcPlot)
#> $ctrl
#> An object of class ligerDataset with 300 cells
#> normData: 50 features
#>
#> $stim
#> An object of class ligerDataset with 300 cells
#> normData: 50 features
#>
dataset(pbmcPlot, "ctrl")
#> An object of class ligerDataset with 300 cells
#> normData: 50 features
dataset(pbmcPlot, 2)
#> An object of class ligerDataset with 300 cells
#> normData: 50 features
## Retrieving cell metadata, replacement methods available
cellMeta(pbmcPlot)
#> DataFrame with 600 rows and 3 columns
#> dataset nUMI leiden_cluster
#> <factor> <numeric> <factor>
#> ctrl_AAACATACCTCGCT.1 ctrl 2151 0
#> ctrl_AAACGGCTCTTCGC.1 ctrl 1916 0
#> ctrl_AACACTCTAAGTAG.1 ctrl 1869 0
#> ctrl_AACCGCCTCAGGAG.1 ctrl 733 3
#> ctrl_AACGTTCTTCCGTC.1 ctrl 573 1
#> ... ... ... ...
#> stim_TTCATGACTTATCC.1 stim 1091 0
#> stim_TTCATGACTTCAGG.1 stim 431 1
#> stim_TTCGGAGATTTCAC.1 stim 1344 7
#> stim_TTGACACTTCCTGC.1 stim 1423 7
#> stim_TTTGCATGAACGAA.1 stim 2818 6
head(pbmcPlot[["nUMI"]])
#> [1] 2151 1916 1869 733 573 1872
## Retrieving dimemtion reduction matrix
head(dimRed(pbmcPlot, "UMAP"))
#> UMAP_1 UMAP_2
#> ctrl_AAACATACCTCGCT.1 -10.816668 -0.2671702
#> ctrl_AAACGGCTCTTCGC.1 -12.135740 -1.2503758
#> ctrl_AACACTCTAAGTAG.1 -8.491358 -0.3795932
#> ctrl_AACCGCCTCAGGAG.1 9.259152 -2.1941839
#> ctrl_AACGTTCTTCCGTC.1 11.014518 1.0113766
#> ctrl_AAGAACGAAACGAA.1 -9.361416 -5.3618426
## Retrieving variable features, replacement methods available
varFeatures(pbmcPlot)
#> [1] "ISG15" "ID3" "RPL11" "MARCKSL1" "RPS8" "GBP1"
#> [7] "S100A10" "S100A11" "S100A9" "S100A8" "S100A6" "S100A4"
#> [13] "RPS27" "FCER1G" "FCGR3A" "XCL2" "XCL1" "SELL"
#> [19] "RSAD2" "RPS27A" "GNLY" "DUSP2" "RPL31" "IL1B"
#> [25] "CXCR4" "PTMA" "RPL32" "RPL15" "RPL14" "GPX1"
#> [31] "TEX264" "FGFBP2" "RPL9" "IL8" "PPBP" "CXCL3"
#> [37] "CXCL10" "PLAC8" "H2AFZ" "RPL34" "ANXA5" "RPS3A"
#> [43] "GZMK" "RPS23" "CD14" "CD74" "RPS14" "NPM1"
#> [49] "CD83" "HIST1H2AC"
## Command record/history
pbmcPlot <- scaleNotCenter(pbmcPlot)
#> ℹ Scaling dataset "ctrl"
#> ✔ Scaling dataset "ctrl" ... done
#>
#> ℹ Scaling dataset "stim"
#> ✔ Scaling dataset "stim" ... done
#>
commands(pbmcPlot)
#> [1] "normalize.liger_741028558e" "selectGenes.liger_c7a9432654"
#> [3] "scaleNotCenter.liger_fbb78f6b9e" "runINMF.liger_2b7a03d986"
#> [5] "quantileNorm.liger_3d42d49bd9" "runCluster_8c80b11e91"
#> [7] "runUMAP_51304eca8d" "scaleNotCenter.liger_76fae4fa4f"
commands(pbmcPlot, funcName = "scaleNotCenter")
#> $scaleNotCenter.liger_fbb78f6b9e
#> A liger command record, performed at 02-29-2024 23:33:43 EST
#> Call: scaleNotCenter.liger(.)
#> Parameters:
#> useDatasets : "ctrl", "stim"
#> features : "Long character with 173 elements: ISG15, ID3, RPL11, ..., CCNH"
#> verbose : TRUE
#>
#> $scaleNotCenter.liger_76fae4fa4f
#> A liger command record, performed at 10-25-2024 15:12:28 EDT
#> Call: scaleNotCenter.liger(pbmcPlot)
#> Parameters:
#> useDatasets : "ctrl", "stim"
#> features : "Long character with 50 elements: ISG15, ID3, RPL11, ..., HIST1H2AC"
#> verbose : TRUE
#>
# S3 methods
pbmcPlot2 <- pbmcPlot
names(pbmcPlot2) <- paste0(names(pbmcPlot), 2)
c(pbmcPlot, pbmcPlot2)
#> An object of class liger with 1200 cells
#> datasets(4): ctrl (300 cells), stim (300 cells), ctrl2 (300 cells), stim2 (300 cells)
#> cellMeta(3): dataset, nUMI, leiden_cluster
#> varFeatures(50): ISG15, ID3, RPL11, ..., HIST1H2AC
#> dimReds(0):
library(ggplot2)
ggplot(pbmcPlot, aes(x = UMAP_1, y = UMAP_2)) + geom_point()
cellMeta(pbmc)
#> DataFrame with 600 rows and 7 columns
#> dataset barcode nUMI nGene
#> <factor> <character> <numeric> <integer>
#> ctrl_AAACATACCTCGCT.1 ctrl ctrl_AAACATACCTCGCT.1 2151 102
#> ctrl_AAACGGCTCTTCGC.1 ctrl ctrl_AAACGGCTCTTCGC.1 1916 103
#> ctrl_AACACTCTAAGTAG.1 ctrl ctrl_AACACTCTAAGTAG.1 1869 95
#> ctrl_AACCGCCTCAGGAG.1 ctrl ctrl_AACCGCCTCAGGAG.1 733 84
#> ctrl_AACGTTCTTCCGTC.1 ctrl ctrl_AACGTTCTTCCGTC.1 573 76
#> ... ... ... ... ...
#> stim_TTCATGACTTATCC.1 stim stim_TTCATGACTTATCC.1 1091 101
#> stim_TTCATGACTTCAGG.1 stim stim_TTCATGACTTCAGG.1 431 86
#> stim_TTCGGAGATTTCAC.1 stim stim_TTCGGAGATTTCAC.1 1344 102
#> stim_TTGACACTTCCTGC.1 stim stim_TTGACACTTCCTGC.1 1423 105
#> stim_TTTGCATGAACGAA.1 stim stim_TTTGCATGAACGAA.1 2818 120
#> mito ribo hemo
#> <numeric> <numeric> <numeric>
#> ctrl_AAACATACCTCGCT.1 0 10.83217 0
#> ctrl_AAACGGCTCTTCGC.1 0 20.25052 0
#> ctrl_AACACTCTAAGTAG.1 0 5.08293 0
#> ctrl_AACCGCCTCAGGAG.1 0 42.70123 0
#> ctrl_AACGTTCTTCCGTC.1 0 38.04538 0
#> ... ... ... ...
#> stim_TTCATGACTTATCC.1 0 8.61595 0
#> stim_TTCATGACTTCAGG.1 0 41.29930 0
#> stim_TTCGGAGATTTCAC.1 0 8.85417 0
#> stim_TTGACACTTCCTGC.1 0 11.94659 0
#> stim_TTTGCATGAACGAA.1 0 9.43932 0
# Add new variable
pbmc[["newVar"]] <- 1
cellMeta(pbmc)
#> DataFrame with 600 rows and 8 columns
#> dataset barcode nUMI nGene
#> <factor> <character> <numeric> <integer>
#> ctrl_AAACATACCTCGCT.1 ctrl ctrl_AAACATACCTCGCT.1 2151 102
#> ctrl_AAACGGCTCTTCGC.1 ctrl ctrl_AAACGGCTCTTCGC.1 1916 103
#> ctrl_AACACTCTAAGTAG.1 ctrl ctrl_AACACTCTAAGTAG.1 1869 95
#> ctrl_AACCGCCTCAGGAG.1 ctrl ctrl_AACCGCCTCAGGAG.1 733 84
#> ctrl_AACGTTCTTCCGTC.1 ctrl ctrl_AACGTTCTTCCGTC.1 573 76
#> ... ... ... ... ...
#> stim_TTCATGACTTATCC.1 stim stim_TTCATGACTTATCC.1 1091 101
#> stim_TTCATGACTTCAGG.1 stim stim_TTCATGACTTCAGG.1 431 86
#> stim_TTCGGAGATTTCAC.1 stim stim_TTCGGAGATTTCAC.1 1344 102
#> stim_TTGACACTTCCTGC.1 stim stim_TTGACACTTCCTGC.1 1423 105
#> stim_TTTGCATGAACGAA.1 stim stim_TTTGCATGAACGAA.1 2818 120
#> mito ribo hemo newVar
#> <numeric> <numeric> <numeric> <numeric>
#> ctrl_AAACATACCTCGCT.1 0 10.83217 0 1
#> ctrl_AAACGGCTCTTCGC.1 0 20.25052 0 1
#> ctrl_AACACTCTAAGTAG.1 0 5.08293 0 1
#> ctrl_AACCGCCTCAGGAG.1 0 42.70123 0 1
#> ctrl_AACGTTCTTCCGTC.1 0 38.04538 0 1
#> ... ... ... ... ...
#> stim_TTCATGACTTATCC.1 0 8.61595 0 1
#> stim_TTCATGACTTCAGG.1 0 41.29930 0 1
#> stim_TTCGGAGATTTCAC.1 0 8.85417 0 1
#> stim_TTGACACTTCCTGC.1 0 11.94659 0 1
#> stim_TTTGCATGAACGAA.1 0 9.43932 0 1
# Change existing variable
pbmc[["newVar"]][1:3] <- 1:3
cellMeta(pbmc)
#> DataFrame with 600 rows and 8 columns
#> dataset barcode nUMI nGene
#> <factor> <character> <numeric> <integer>
#> ctrl_AAACATACCTCGCT.1 ctrl ctrl_AAACATACCTCGCT.1 2151 102
#> ctrl_AAACGGCTCTTCGC.1 ctrl ctrl_AAACGGCTCTTCGC.1 1916 103
#> ctrl_AACACTCTAAGTAG.1 ctrl ctrl_AACACTCTAAGTAG.1 1869 95
#> ctrl_AACCGCCTCAGGAG.1 ctrl ctrl_AACCGCCTCAGGAG.1 733 84
#> ctrl_AACGTTCTTCCGTC.1 ctrl ctrl_AACGTTCTTCCGTC.1 573 76
#> ... ... ... ... ...
#> stim_TTCATGACTTATCC.1 stim stim_TTCATGACTTATCC.1 1091 101
#> stim_TTCATGACTTCAGG.1 stim stim_TTCATGACTTCAGG.1 431 86
#> stim_TTCGGAGATTTCAC.1 stim stim_TTCGGAGATTTCAC.1 1344 102
#> stim_TTGACACTTCCTGC.1 stim stim_TTGACACTTCCTGC.1 1423 105
#> stim_TTTGCATGAACGAA.1 stim stim_TTTGCATGAACGAA.1 2818 120
#> mito ribo hemo newVar
#> <numeric> <numeric> <numeric> <numeric>
#> ctrl_AAACATACCTCGCT.1 0 10.83217 0 1
#> ctrl_AAACGGCTCTTCGC.1 0 20.25052 0 2
#> ctrl_AACACTCTAAGTAG.1 0 5.08293 0 3
#> ctrl_AACCGCCTCAGGAG.1 0 42.70123 0 1
#> ctrl_AACGTTCTTCCGTC.1 0 38.04538 0 1
#> ... ... ... ... ...
#> stim_TTCATGACTTATCC.1 0 8.61595 0 1
#> stim_TTCATGACTTCAGG.1 0 41.29930 0 1
#> stim_TTCGGAGATTTCAC.1 0 8.85417 0 1
#> stim_TTGACACTTCCTGC.1 0 11.94659 0 1
#> stim_TTTGCATGAACGAA.1 0 9.43932 0 1