Package 'ExperimentSubset'

Title: Manages Subsets of Data with Bioconductor Experiment Objects
Description: Experiment objects such as the SummarizedExperiment, RangedSummarizedExperiment, SingleCellExperiment, TreeSummarizedExperiment or SpatialExperiment are data containers for one or more matrix-like assays along with the associated row and column data. Often only a subset of the original data is needed for down-stream analysis. For example, filtering out poor quality samples will require excluding some columns before analysis. The ExperimentSubset object is a container to efficiently manage different subsets of the same data without having to make separate objects for each new subset.
Authors: Irzam Sarfraz [aut] (ORCID: <https://orcid.org/0000-0001-8121-792X>), Muhammad Asif [aut, ths] (ORCID: <https://orcid.org/0000-0003-1839-2527>), Joshua D. Campbell [aut, cre] (ORCID: <https://orcid.org/0000-0003-0780-8662>)
Maintainer: Joshua D. Campbell <[email protected]>
License: MIT + file LICENSE
Version: 1.23.50
Built: 2026-11-11 08:27:18 UTC
Source: https://github.com/bioc/ExperimentSubset

Help Index


Subset creation method for ExperimentSubset objects

Description

Create a subset from an already available assay in the input ExperimentSubset object by specifying the rows and columns to include in the subset.

Usage

createSubset(x, subsetName, rows = NULL, cols = NULL, parentAssay = NULL)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
createSubset(x, subsetName, rows = NULL, cols = NULL, parentAssay = NULL)

## S4 method for signature 'SubsetSingleCellExperiment'
createSubset(x, subsetName, rows = NULL, cols = NULL, parentAssay = NULL)

## S4 method for signature 'SubsetSummarizedExperiment'
createSubset(x, subsetName, rows = NULL, cols = NULL, parentAssay = NULL)

## S4 method for signature 'SubsetSpatialExperiment'
createSubset(x, subsetName, rows = NULL, cols = NULL, parentAssay = NULL)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
createSubset(x, subsetName, rows = NULL, cols = NULL, parentAssay = NULL)

Arguments

x

ExperimentSubset Specify the object from which a subset should be created. Use ExperimentSubset() first to convert another experiment object.

subsetName

character(1) Specify the name of the subset to create.

rows

numeric or character vector. Specify the rows to include in this subset. If missing or NULL, all rows are included in the subset. Default NULL.

cols

numeric or character vector. Specify the columns to include in this subset. If missing or NULL, all columns are included in the subset. Default NULL.

parentAssay

character(1) Specify the parent assay of the subset: the name of a main assay, of a subset, or of an assay seen in a subset written as "subset/assay". If NULL, the first available main assay will be marked as parent. Default NULL.

Value

An ExperimentSubset object that now contains the newly created subset.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
es

ExperimentSubset constructor

Description

This constructor function sets up an ExperimentSubset object from a SummarizedExperiment, RangedSummarizedExperiment, SingleCellExperiment, TreeSummarizedExperiment or SpatialExperiment object, or from a named list of assay matrices. A subset can also be created directly by passing a named list to the subset parameter, with elements named subsetName, rows, cols and parentAssay.

Usage

ExperimentSubset(
  x,
  subset = list(subsetName = NA, rows = NA, cols = NA, parentAssay = NA)
)

Arguments

x

An experiment object of one of the five supported classes, or a named list of assay matrices, which is passed to the SingleCellExperiment constructor as its assays. An object of a subclass of a supported class is converted as the class it extends, with a warning: the slots and methods that the subclass adds are not kept. An object that is already an ExperimentSubset is returned as is, with the subset from subset, if given.

subset

A named list to create a subset from within the constructor, with elements subsetName and, optionally, rows, cols and parentAssay. Leave out rows, cols or parentAssay, or set them to NULL, to use all rows, all columns or the first assay. The default, a list of NA values, creates no subset; an NA in a list you supply is an error.

Value

An object of the matching Subset* class, for example a SubsetSingleCellExperiment for a SingleCellExperiment or a list of assays. For an ExperimentSubset object, the same object, with the new subset if subset is given.

See Also

ExperimentSubset, the class every Subset* class extends, for testing whether an object is an ExperimentSubset.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es

Alternative experiments of subsets in ExperimentSubset objects

Description

Get or set the alternative experiments (altExps) of a subset by naming it with subsetName. Without subsetName, these methods act on the main object, as for SingleCellExperiment. They exist for the classes that extend SingleCellExperiment: SubsetSingleCellExperiment, SubsetSpatialExperiment and SubsetTreeSummarizedExperiment.

Usage

## S4 method for signature 'SubsetSingleCellExperiment,character'
altExp(x, e, ...)

## S4 method for signature 'SubsetSingleCellExperiment,missing'
altExp(x, e, ...)

## S4 method for signature 'SubsetSingleCellExperiment,numeric'
altExp(x, e, ...)

## S4 method for signature 'SubsetSingleCellExperiment'
altExps(x, ...)

## S4 method for signature 'SubsetSingleCellExperiment'
altExpNames(x, ...)

## S4 replacement method for signature 'SubsetSingleCellExperiment,character'
altExpNames(x, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,ANY'
altExpNames(x, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,character'
altExp(x, e, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,missing'
altExp(x, e, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,numeric'
altExp(x, e, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment'
altExps(x, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 method for signature 'SubsetSpatialExperiment,character'
altExp(x, e, ...)

## S4 method for signature 'SubsetSpatialExperiment,missing'
altExp(x, e, ...)

## S4 method for signature 'SubsetSpatialExperiment,numeric'
altExp(x, e, ...)

## S4 method for signature 'SubsetSpatialExperiment'
altExps(x, ...)

## S4 method for signature 'SubsetSpatialExperiment'
altExpNames(x, ...)

## S4 replacement method for signature 'SubsetSpatialExperiment,character'
altExpNames(x, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,ANY'
altExpNames(x, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,character'
altExp(x, e, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,missing'
altExp(x, e, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,numeric'
altExp(x, e, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment'
altExps(x, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment,character'
altExp(x, e, ...)

## S4 method for signature 'SubsetTreeSummarizedExperiment,missing'
altExp(x, e, ...)

## S4 method for signature 'SubsetTreeSummarizedExperiment,numeric'
altExp(x, e, ...)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
altExps(x, ...)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
altExpNames(x, ...)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,character'
altExpNames(x, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,ANY'
altExpNames(x, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,character'
altExp(x, e, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,missing'
altExp(x, e, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,numeric'
altExp(x, e, withDimnames = TRUE, withColData = FALSE, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment'
altExps(x, withDimnames = TRUE, withColData = FALSE, ...) <- value

Arguments

x

An ExperimentSubset object.

e

character(1) or integer(1) The name or position of the alternative experiment. Leave it out for the first one. With subsetName, positions follow altExpNames().

...
subsetName

character(1) Name of the subset whose alternative experiments to get or set. Leave it out for the main object's.

unlink

For altExp<- and altExps<- with subsetName: TRUE, FALSE or a character vector of "altExpName/assayName" names. Store assays of value that have the name of a linked altExp assay but different values: with TRUE, every such assay; with names, only those. Any other such assay is an error, and nothing is stored. A message names each assay that is unlinked. Default FALSE. Any other value is an error without subsetName.

Other arguments are passed on to the SingleCellExperiment method. With subsetName, altExpNames() and altExpNames<- ignore other arguments.

value

For altExp<-, a SummarizedExperiment with one column per column of the subset (or of the main object). For altExps<-, a list of them. For altExpNames<-, a character vector of new names, one for each name altExpNames() returns; with subsetName, they must all differ, and only the subset's own altExps can get new names.

withDimnames

logical(1) Passed on to altExp<- or altExps<-. Default TRUE.

withColData

logical(1) Passed on to altExp<- or altExps<-. Default FALSE.

Details

A subset sees the main object's altExps, and those stored on the subsets it was made from, cut to its own columns (cells). Their rows (features, such as the proteins of an ADT altExp) are not cut: a subset's rows pick features of the main object only. These altExps are linked, as assays are: the subset sees their current values, and stores only what it changes.

Storing an altExp in a subset with altExp<- or altExps<- compares it with the linked one of the same name, assay by assay:

  • A new assay is stored as the subset's own, and the linked assays stay linked.

  • An assay with the values of the linked one is not stored.

  • An assay with other values than the linked one needs unlink, named as "altExpName/assayName", such as "ADT/counts".

  • rowData, colData, metadata and reducedDims are stored when they differ from the linked altExp's, and then replace them whole. An empty one shows the linked one, so a subset can't clear them. Other parts, such as the altExp's own altExps, colPairs and rowPairs, always come from the linked altExp.

  • An assay the subset already stores itself, after an unlink, is not linked, so storing it again needs no unlink.

  • An altExp with other rows, rownames or class than the linked one replaces it entirely, so every linked assay counts as changed. It keeps replacing it for as long as the subset stores it, even if the linked altExp later has the same rows, and so does an altExp a subset stores while nothing of that name is linked. To add to the linked altExp instead, remove the subset's with altExp(x, e, subsetName = s) <- NULL and store it again.

A subset can't remove or rename a linked altExp, or give one of its own the name of another altExp it sees: an altExp missing from value in altExps<- stays visible, and altExp(x, e, subsetName = s) <- NULL removes only what the subset stores, so the linked altExp shows again.

Changes to a linked altExp carry along to the subsets below it, made from the main object or from the subset that stores it. Its new values show in them. Renaming it renames what they store of it. Removing it, or storing it with other rows or another class, drops what they added to it, with a warning; an altExp a subset stores whole is kept.

Value

altExp() returns a SummarizedExperiment, altExps() a list of them and altExpNames() a character vector. With subsetName, these are every altExp the subset sees: the main object's first, then those stored only on subsets. The setters return x with the change made.

See Also

altExps

Examples

# an object with 10 genes and 20 cells
set.seed(1)
counts <- matrix(rpois(200, lambda = 5), nrow = 10)
rownames(counts) <- paste0("gene", 1:10)
colnames(counts) <- paste0("cell", 1:20)
es <- ExperimentSubset(list(counts = counts))
# counts of 2 proteins in the same 20 cells, as an altExp
adtCounts <- matrix(rpois(40, lambda = 20), nrow = 2)
rownames(adtCounts) <- c("CD3", "CD4")
altExp(es, "ADT") <- SummarizedExperiment(list(counts = adtCounts))
# a subset of the first 5 genes and the first 8 cells
es <- createSubset(es, subsetName = "first", rows = 1:5, cols = 1:8)
# the subset sees ADT for its 8 cells, with both proteins
altExpNames(es, subsetName = "first")
adt <- altExp(es, "ADT", subsetName = "first")
dim(adt)
# add an assay to ADT in the subset only; ADT's counts stay linked
assay(adt, "logcounts") <- log1p(assay(adt, "counts"))
altExp(es, "ADT", subsetName = "first") <- adt
assayNames(altExp(es, "ADT", subsetName = "first"))
assayNames(altExp(es, "ADT"))
# a changed linked assay needs unlink
assay(adt, "counts") <- assay(adt, "counts") + 1L
altExp(es, "ADT", subsetName = "first", unlink = "ADT/counts") <- adt

Assays of subsets in ExperimentSubset objects

Description

Get or set an assay of the main object or of a subset. Unlike the other methods, assay() and assay<- name the subset with i, not with subsetName.

assay(x, i) returns:

  • a main assay, when i is its name, as for the class x extends;

  • the subset's rows and columns of the assay it was made from, when i is a subset name. If the subset, or a subset it was made from, stored its own assay of that name with unlink, that assay is returned instead;

  • an assay as a subset sees it, when i is "subset/assay", or a subset name with subsetAssayName = "assay": either one stored in the subset, or one linked from its parent, cut to the subset's rows and columns.

assay(x, i) <- value stores value in a subset when i is "subset/assay", or a subset name with subsetAssayName, as setSubsetAssay does. A name with a "/" is read as "subset/assay" unless it is the name of a main assay, and a subset name without subsetAssayName is an error. Any other name stores a main assay.

Usage

## S4 method for signature 'SubsetRangedSummarizedExperiment,character'
assay(x, i, withDimnames = TRUE, ...)

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment,character'
assay(x, i, withDimnames = TRUE, ...) <- value

## S4 method for signature 'SubsetSingleCellExperiment,character'
assay(x, i, withDimnames = TRUE, ...)

## S4 replacement method for signature 'SubsetSingleCellExperiment,character'
assay(x, i, withDimnames = TRUE, ...) <- value

## S4 method for signature 'SubsetSummarizedExperiment,character'
assay(x, i, withDimnames = TRUE, ...)

## S4 replacement method for signature 'SubsetSummarizedExperiment,character'
assay(x, i, withDimnames = TRUE, ...) <- value

## S4 method for signature 'SubsetSpatialExperiment,character'
assay(x, i, withDimnames = TRUE, ...)

## S4 replacement method for signature 'SubsetSpatialExperiment,character'
assay(x, i, withDimnames = TRUE, ...) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment,character'
assay(x, i, withDimnames = TRUE, ...)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,character'
assay(x, i, withDimnames = TRUE, ...) <- value

Arguments

x

An ExperimentSubset object.

i

character(1) The name of a main assay, a subset name, or "subset/assay".

withDimnames

logical(1) As for SummarizedExperiment: TRUE gives the assay returned the row and column names of the main object or the subset, and FALSE keeps the names stored with the assay, if any. When setting a main assay, passed on to the method of the class x extends. Default TRUE.

...
subsetAssayName

character(1) With a subset name in i, the name of the assay to get from or store in that subset. It is an error with any other i, including "subset/assay". Default NULL.

unlink

TRUE, FALSE or a character vector of assay names. When storing in a subset, store the assay even though the subset sees an assay of that name linked from its parent, with TRUE or a vector that contains its name, as for setSubsetAssay. It is an error when storing a main assay. Default FALSE.

For a main assay, other arguments are passed on to the method of the class x extends.

value

A matrix-like assay with the main object's dimensions, or, to store it in a subset, the subset's.

Value

assay() returns a matrix-like assay. assay<- returns x with the assay stored.

See Also

getSubsetAssay, setSubsetAssay, assay

Examples

# an object with 10 genes and 20 cells
set.seed(1)
counts <- matrix(rpois(200, lambda = 5), nrow = 10)
rownames(counts) <- paste0("gene", 1:10)
colnames(counts) <- paste0("cell", 1:20)
es <- ExperimentSubset(list(counts = counts))
# a subset of the first 5 genes and the first 8 cells
es <- createSubset(es, subsetName = "first", rows = 1:5, cols = 1:8)
# the subset's 5 x 8 part of the counts
firstCounts <- assay(es, "first")
# store a new assay in the subset
assay(es, "first", subsetAssayName = "logcounts") <- log1p(firstCounts)
# read it back
assay(es, "first/logcounts")

The class of every ExperimentSubset object

Description

A virtual class that the five Subset* classes extend: SubsetSummarizedExperiment, SubsetRangedSummarizedExperiment, SubsetSingleCellExperiment, SubsetTreeSummarizedExperiment and SubsetSpatialExperiment. Use is(x, "ExperimentSubset") to test whether x is an ExperimentSubset object, whichever class it extends. A SubsetSpatialExperiment, for example, is not a SubsetSingleCellExperiment, though it extends SingleCellExperiment.

Details

The class is virtual, so there are no objects of the class itself. Create an ExperimentSubset object with ExperimentSubset().

Examples

# simulate counts for 10 genes in 20 spots
set.seed(1)
values <- rpois(200, lambda = 5)
counts <- matrix(values, nrow = 10)
rownames(counts) <- paste0("gene", 1:10)
colnames(counts) <- paste0("spot", 1:20)

# make a SpatialExperiment from the counts
spe <- SpatialExperiment(assays = list(counts = counts))

# convert it to an ExperimentSubset object
es <- ExperimentSubset(spe)

# es is an ExperimentSubset: TRUE
is(es, "ExperimentSubset")

# but not a SubsetSingleCellExperiment, though it extends
# SingleCellExperiment: FALSE
is(es, "SubsetSingleCellExperiment")

# the SpatialExperiment it was made from is not an ExperimentSubset: FALSE
is(spe, "ExperimentSubset")

Combine ExperimentSubset objects by columns or rows

Description

cbind(...) and rbind(...) combine objects as for the class they extend, and keep the subsets of every object, with their own assays, rowData, colData, reducedDims and altExps. Subsets of the second and later objects are moved to where that object's columns (for cbind) or rows (for rbind) are in the result. Subset names must be unique across the objects, and differ from the assay names of all of them.

combineCols(x, ...) and combineRows(x, ...) combine objects whose rows (for combineCols) or columns (for combineRows) differ, as for the class they extend: the result has all of the rows (or columns), matched by name, and fills the gaps. They keep the subsets of every object too, matching each subset's rows (or columns) by name to the result's, or by position with use.names = FALSE.

Usage

## S4 method for signature 'SubsetRangedSummarizedExperiment'
cbind(..., deparse.level = 1)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
rbind(..., deparse.level = 1)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
combineCols(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
combineRows(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

## S4 method for signature 'SubsetSingleCellExperiment'
cbind(..., deparse.level = 1)

## S4 method for signature 'SubsetSingleCellExperiment'
rbind(..., deparse.level = 1)

## S4 method for signature 'SubsetSingleCellExperiment'
combineCols(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

## S4 method for signature 'SubsetSingleCellExperiment'
combineRows(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

## S4 method for signature 'SubsetSummarizedExperiment'
cbind(..., deparse.level = 1)

## S4 method for signature 'SubsetSummarizedExperiment'
rbind(..., deparse.level = 1)

## S4 method for signature 'SubsetSummarizedExperiment'
combineCols(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

## S4 method for signature 'SubsetSummarizedExperiment'
combineRows(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

## S4 method for signature 'SubsetSpatialExperiment'
cbind(..., deparse.level = 1)

## S4 method for signature 'SubsetSpatialExperiment'
rbind(..., deparse.level = 1)

## S4 method for signature 'SubsetSpatialExperiment'
combineCols(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

## S4 method for signature 'SubsetSpatialExperiment'
combineRows(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
cbind(..., deparse.level = 1)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
rbind(..., deparse.level = 1)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
combineCols(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
combineRows(x, ..., delayed = TRUE, fill = NA, use.names = TRUE)

Arguments

...

ExperimentSubset objects of the same class, which must have the same rows for cbind or the same columns for rbind. Convert a plain object, such as a SingleCellExperiment, with ExperimentSubset() first, which keeps all of its data: combining it as it is makes R warn about "multiple direct matches", and if it comes first, the result is a plain object without subsets. For combineCols and combineRows, the objects to combine with x.

deparse.level

Passed on to the method of the class the objects extend. Default 1.

x

For combineCols and combineRows, the first ExperimentSubset object to combine.

delayed, fill

Passed on to the method of the class the objects extend: whether to combine assays as DelayedArray objects, and the value for the gaps. Defaults TRUE and NA.

use.names

Whether to match rows (for combineCols) or columns (for combineRows) by name, as the method of the class the objects extend does; if FALSE, they are matched by position and the objects must have the same number of them. Default TRUE.

Details

For some classes, combineCols() and combineRows() of the class the objects extend return a different class: combineCols() of a TreeSummarizedExperiment or SpatialExperiment returns a SingleCellExperiment, and combineRows() of a SingleCellExperiment, TreeSummarizedExperiment or SpatialExperiment returns a RangedSummarizedExperiment. The result is then the matching ExperimentSubset class, such as SubsetSingleCellExperiment, and each subset is converted to that class too, so it loses what the class can't hold, as the main object does: for example its reducedDims and altExps in a SubsetRangedSummarizedExperiment.

combineCols() and combineRows() use the method for the class of x only, so if x is a plain object, such as a SingleCellExperiment, the result is a plain object without subsets. Convert it with ExperimentSubset() first.

Value

For cbind and rbind, an object of the same class as the objects in .... For combineCols and combineRows, the ExperimentSubset class matching the result of the method of the class x extends; see Details.

Examples

# two objects with the same 10 genes and 20 cells each
set.seed(1)
counts1 <- matrix(rpois(200, lambda = 5), nrow = 10)
rownames(counts1) <- paste0("gene", 1:10)
colnames(counts1) <- paste0("cellA", 1:20)
counts2 <- matrix(rpois(200, lambda = 5), nrow = 10)
rownames(counts2) <- paste0("gene", 1:10)
colnames(counts2) <- paste0("cellB", 1:20)
es1 <- ExperimentSubset(list(counts = counts1))
es2 <- ExperimentSubset(list(counts = counts2))
# a subset in each object
es1 <- createSubset(es1, subsetName = "firstA", rows = 1:5, cols = 1:8)
es2 <- createSubset(es2, subsetName = "firstB", rows = 1:5, cols = 1:8)
# combine the cells of both objects
esBoth <- cbind(es1, es2)
# both subsets are kept
subsetNames(esBoth)
subsetColnames(esBoth, subsetName = "firstB")

# a third object, with genes 6 to 10 and 5 genes the others don't have
counts3 <- matrix(rpois(200, lambda = 5), nrow = 10)
rownames(counts3) <- paste0("gene", 6:15)
colnames(counts3) <- paste0("cellC", 1:20)
es3 <- ExperimentSubset(list(counts = counts3))
# a subset of the genes only the third object has
es3 <- createSubset(es3, subsetName = "newGenes", rows = 6:10)
# combine the cells, keeping the genes of both; the gaps are NA
esAll <- combineCols(es1, es3)
dim(esAll)
# the subsets of both objects are kept
subsetNames(esAll)
# the new subset keeps its genes
subsetRownames(esAll, subsetName = "newGenes")

Metadata of subsets in ExperimentSubset objects

Description

Get or set the metadata list of a subset by naming it with subsetName. Without subsetName, metadata() and metadata<- act on the main object, as for the class x extends.

Usage

## S4 method for signature 'SubsetRangedSummarizedExperiment'
metadata(x, ...)

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment'
metadata(x, ...) <- value

## S4 method for signature 'SubsetSingleCellExperiment'
metadata(x, ...)

## S4 replacement method for signature 'SubsetSingleCellExperiment'
metadata(x, ...) <- value

## S4 method for signature 'SubsetSummarizedExperiment'
metadata(x, ...)

## S4 replacement method for signature 'SubsetSummarizedExperiment'
metadata(x, ...) <- value

## S4 method for signature 'SubsetSpatialExperiment'
metadata(x, ...)

## S4 replacement method for signature 'SubsetSpatialExperiment'
metadata(x, ...) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment'
metadata(x, ...)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment'
metadata(x, ...) <- value

Arguments

x

An ExperimentSubset object.

...
subsetName

character(1) Name of the subset whose metadata to get or set. Leave it out for the main object's.

Without subsetName, all arguments are passed on to the method of the class x extends.

value

A list to store as the metadata.

Value

metadata() returns a list. metadata<- returns x with the metadata set.

See Also

metadata

Examples

# an object with 10 genes and 20 cells
set.seed(1)
counts <- matrix(rpois(200, lambda = 5), nrow = 10)
rownames(counts) <- paste0("gene", 1:10)
colnames(counts) <- paste0("cell", 1:20)
es <- ExperimentSubset(list(counts = counts))
# a subset of the first 5 genes and the first 8 cells
es <- createSubset(es, subsetName = "first", rows = 1:5, cols = 1:8)
# store a note in the subset's metadata
metadata(es, subsetName = "first") <- list(note = "the first 8 cells")
# read it back
metadata(es, subsetName = "first")
# the main object's metadata is unchanged
metadata(es)

Reduced dimensions of subsets in ExperimentSubset objects

Description

Get or set the reduced dimensions, such as a PCA or UMAP, of a subset by naming it with subsetName. Without subsetName, these methods act on the main object, as for SingleCellExperiment. They exist for the classes that extend SingleCellExperiment: SubsetSingleCellExperiment, SubsetSpatialExperiment and SubsetTreeSummarizedExperiment. reducedDimNames and reducedDimNames<- have their own pages.

Usage

## S4 method for signature 'SubsetSingleCellExperiment,character'
reducedDim(x, type, ...)

## S4 method for signature 'SubsetSingleCellExperiment,missing'
reducedDim(x, type, ...)

## S4 method for signature 'SubsetSingleCellExperiment,numeric'
reducedDim(x, type, ...)

## S4 replacement method for signature 'SubsetSingleCellExperiment,character'
reducedDim(x, type, withDimnames = TRUE, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,missing'
reducedDim(x, type, withDimnames = TRUE, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,numeric'
reducedDim(x, type, withDimnames = TRUE, ...) <- value

## S4 method for signature 'SubsetSingleCellExperiment'
reducedDims(x, ...)

## S4 replacement method for signature 'SubsetSingleCellExperiment'
reducedDims(x, withDimnames = TRUE, ...) <- value

## S4 method for signature 'SubsetSpatialExperiment,character'
reducedDim(x, type, ...)

## S4 method for signature 'SubsetSpatialExperiment,missing'
reducedDim(x, type, ...)

## S4 method for signature 'SubsetSpatialExperiment,numeric'
reducedDim(x, type, ...)

## S4 replacement method for signature 'SubsetSpatialExperiment,character'
reducedDim(x, type, withDimnames = TRUE, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,missing'
reducedDim(x, type, withDimnames = TRUE, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,numeric'
reducedDim(x, type, withDimnames = TRUE, ...) <- value

## S4 method for signature 'SubsetSpatialExperiment'
reducedDims(x, ...)

## S4 replacement method for signature 'SubsetSpatialExperiment'
reducedDims(x, withDimnames = TRUE, ...) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment,character'
reducedDim(x, type, ...)

## S4 method for signature 'SubsetTreeSummarizedExperiment,missing'
reducedDim(x, type, ...)

## S4 method for signature 'SubsetTreeSummarizedExperiment,numeric'
reducedDim(x, type, ...)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,character'
reducedDim(x, type, withDimnames = TRUE, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,missing'
reducedDim(x, type, withDimnames = TRUE, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,numeric'
reducedDim(x, type, withDimnames = TRUE, ...) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment'
reducedDims(x, ...)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment'
reducedDims(x, withDimnames = TRUE, ...) <- value

Arguments

x

An ExperimentSubset object.

type

character(1) or integer(1) The name or position of the reduced dimension. Leave it out for the first one.

...
subsetName

character(1) Name of the subset whose reduced dimensions to get or set. Leave it out for the main object's. Give it by name: for reducedDims<-, a subset name in second place is withDimnames, and an error.

Other arguments are passed on to the SingleCellExperiment method, for the subset or the main object.

withDimnames

logical(1) Passed on to reducedDim<- or reducedDims<-. Default TRUE.

value

For reducedDim<-, a matrix with one row per column of the subset (or of the main object). For reducedDims<-, a named list of such matrices, which replaces all of them.

Value

reducedDim() returns a matrix and reducedDims() a list of them. reducedDim<- and reducedDims<- return x with the reduced dimensions stored.

See Also

reducedDims

Examples

# an object with 10 genes and 20 cells
set.seed(1)
counts <- matrix(rpois(200, lambda = 5), nrow = 10)
rownames(counts) <- paste0("gene", 1:10)
colnames(counts) <- paste0("cell", 1:20)
es <- ExperimentSubset(list(counts = counts))
# a subset of the first 5 genes and the first 8 cells
es <- createSubset(es, subsetName = "first", rows = 1:5, cols = 1:8)
# a 2-dimensional embedding of the subset's 8 cells
embedding <- matrix(rnorm(16), ncol = 2)
# store it in the subset
reducedDim(es, "PCA", subsetName = "first") <- embedding
# read it back
reducedDim(es, "PCA", subsetName = "first")
# all of the subset's reduced dimensions
reducedDims(es, subsetName = "first")
# replace them all with a list of two
reducedDims(es, subsetName = "first") <- list(PCA = embedding,
                                              UMAP = embedding * 2)
reducedDimNames(es, subsetName = "first")

rowData and colData of subsets in ExperimentSubset objects

Description

Get or set the rowData or colData of a subset by naming it with subsetName. Without subsetName, these methods act on the main object, as for the class x extends.

A subset stores only its own columns. With parentRowData = TRUE or parentColData = TRUE, the main object's columns come first, for the subset's rows or columns, and a subset's own column hides the main object's column of the same name, with a message if their values differ. When setting a subset's data, columns that came from the main object, in data read with parentRowData = TRUE or parentColData = TRUE, are left out with a message, so only the subset's own are stored. To add one column, use colData(x, subsetName = "name")$column <- values.

Usage

## S4 method for signature 'SubsetRangedSummarizedExperiment'
rowData(x, use.names = TRUE, ...)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
colData(x, ...)

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment'
rowData(x, ...) <- value

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment,DataFrame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment,NULL'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment,data.frame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment,ANY'
colData(x, ...) <- value

## S4 method for signature 'SubsetSingleCellExperiment'
rowData(x, use.names = TRUE, ...)

## S4 method for signature 'SubsetSingleCellExperiment'
colData(x, ...)

## S4 replacement method for signature 'SubsetSingleCellExperiment'
rowData(x, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,DataFrame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,NULL'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,data.frame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetSingleCellExperiment,ANY'
colData(x, ...) <- value

## S4 method for signature 'SubsetSummarizedExperiment'
rowData(x, use.names = TRUE, ...)

## S4 method for signature 'SubsetSummarizedExperiment'
colData(x, ...)

## S4 replacement method for signature 'SubsetSummarizedExperiment'
rowData(x, ...) <- value

## S4 replacement method for signature 'SubsetSummarizedExperiment,DataFrame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetSummarizedExperiment,NULL'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetSummarizedExperiment,data.frame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetSummarizedExperiment,ANY'
colData(x, ...) <- value

## S4 method for signature 'SubsetSpatialExperiment'
rowData(x, use.names = TRUE, ...)

## S4 method for signature 'SubsetSpatialExperiment'
colData(x, ...)

## S4 replacement method for signature 'SubsetSpatialExperiment'
rowData(x, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,DataFrame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,NULL'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,data.frame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetSpatialExperiment,ANY'
colData(x, ...) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment'
rowData(x, use.names = TRUE, ...)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
colData(x, ...)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment'
rowData(x, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,DataFrame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,NULL'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,data.frame'
colData(x, ...) <- value

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment,ANY'
colData(x, ...) <- value

Arguments

x

An ExperimentSubset object.

use.names

logical(1) Whether the rowData returned has row names. Default TRUE.

...
subsetName

character(1) Name of the subset whose data to get or set. Leave it out for the main object's.

parentRowData

logical(1) For rowData() of a subset, whether to include the main object's columns. Default FALSE.

parentColData

logical(1) For colData() of a subset, whether to include the main object's columns. Default FALSE.

Without subsetName, other arguments are passed on to the method of the class x extends.

value

A DataFrame with one row per row (rowData<-) or column (colData<-) of the subset or the main object, or NULL to remove all columns (a SpatialExperiment keeps its sample_id column). For a subset, a data.frame is also accepted and converted to a DataFrame; for the main object, colData<- with a data.frame is an error. For a subset, the rownames of value must be NULL or the subset's row names (rowData<-) or column names (colData<-), in the same order.

Value

rowData() and colData() return a DataFrame. The setters return x with the data set.

See Also

subsetRowData, subsetColData, rowData, colData

Examples

# an object with 10 genes and 20 cells
set.seed(1)
counts <- matrix(rpois(200, lambda = 5), nrow = 10)
rownames(counts) <- paste0("gene", 1:10)
colnames(counts) <- paste0("cell", 1:20)
es <- ExperimentSubset(list(counts = counts))
# a sample label for every cell of the main object
es$sample <- rep(c("A", "B"), each = 10)
# a subset of the first 5 genes and the first 8 cells
es <- createSubset(es, subsetName = "first", rows = 1:5, cols = 1:8)
# a cluster label for each of the subset's 8 cells
colData(es, subsetName = "first")$cluster <- rep(1:2, times = 4)
# the subset's own columns
colData(es, subsetName = "first")
# with the main object's columns first
colData(es, subsetName = "first", parentColData = TRUE)
# the subset's rowData, which has no columns yet
rowData(es, subsetName = "first")

Subset an ExperimentSubset object by rows or columns

Description

x[i, j] keeps rows i and columns j of the main object, as for the class it extends, and also updates every subset. Each subset keeps the rows and columns that remain, in its own order, together with its own assays, rowData, colData, reducedDims and altExps. A subset none of whose rows or columns remain is kept with no rows or no columns. If i or j repeats a row or column, subsets keep one copy of it.

Usage

## S4 method for signature 'SubsetRangedSummarizedExperiment,ANY,ANY,ANY'
x[i, j, ..., drop = TRUE]

## S4 method for signature 'SubsetSingleCellExperiment,ANY,ANY,ANY'
x[i, j, ..., drop = TRUE]

## S4 method for signature 'SubsetSummarizedExperiment,ANY,ANY,ANY'
x[i, j, ..., drop = TRUE]

## S4 method for signature 'SubsetSpatialExperiment,ANY,ANY,ANY'
x[i, j, ..., drop = TRUE]

## S4 method for signature 'SubsetTreeSummarizedExperiment,ANY,ANY,ANY'
x[i, j, ..., drop = TRUE]

Arguments

x

An ExperimentSubset object.

i, j

Rows and columns to keep: positions, names or logical vectors, as for the class x extends. Leave one out to keep all rows or all columns.

...

Passed on to the method of the class x extends.

drop

Ignored, as for SummarizedExperiment. Default TRUE.

Value

An object of the same class as x.

Examples

# an object with 10 genes and 20 cells
set.seed(1)
counts <- matrix(rpois(200, lambda = 5), nrow = 10)
rownames(counts) <- paste0("gene", 1:10)
colnames(counts) <- paste0("cell", 1:20)
es <- ExperimentSubset(list(counts = counts))
# a subset of the first 5 genes and the first 8 cells
es <- createSubset(es, subsetName = "first", rows = 1:5, cols = 1:8)
# keep genes 3 to 10 of the main object
esSmaller <- es[3:10, ]
# the subset keeps genes 3 to 5
subsetRownames(esSmaller, subsetName = "first")

Get subset assay from an ExperimentSubset object.

Description

Get subset assay from an ExperimentSubset object.

Usage

getSubsetAssay(x, subsetName, subsetAssayName = NULL)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
getSubsetAssay(x, subsetName, subsetAssayName = NULL)

## S4 method for signature 'SubsetSingleCellExperiment'
getSubsetAssay(x, subsetName, subsetAssayName = NULL)

## S4 method for signature 'SubsetSummarizedExperiment'
getSubsetAssay(x, subsetName, subsetAssayName = NULL)

## S4 method for signature 'SubsetSpatialExperiment'
getSubsetAssay(x, subsetName, subsetAssayName = NULL)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
getSubsetAssay(x, subsetName, subsetAssayName = NULL)

Arguments

x

Input ExperimentSubset object.

subsetName

The name of the subset to fetch the assay from, or an assay seen in a subset written as "subset/assay".

subsetAssayName

character(1) The name of an assay seen in the subset subsetName: one stored with setSubsetAssay, or one linked from its parent. Default NULL, which returns the subset's slice of its parentAssay.

Value

Subset assay

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
getSubsetAssay(es, "subset1")
# store a changed copy of the subset's counts inside the subset
subset1Counts <- getSubsetAssay(es, "subset1")
es <- setSubsetAssay(es, "subset1", subset1Counts + 1, "plusOne")
getSubsetAssay(es, "subset1", subsetAssayName = "plusOne")

Take a subset out as a standalone experiment object

Description

Returns a subset as an object of the main object's class (for example a SingleCellExperiment), so that any tool written for that class can be run on the subset. Store what the tool added with setSubsetExperiment.

Usage

getSubsetExperiment(x, subsetName, parentData = TRUE)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
getSubsetExperiment(x, subsetName, parentData = TRUE)

## S4 method for signature 'SubsetSingleCellExperiment'
getSubsetExperiment(x, subsetName, parentData = TRUE)

## S4 method for signature 'SubsetSummarizedExperiment'
getSubsetExperiment(x, subsetName, parentData = TRUE)

## S4 method for signature 'SubsetSpatialExperiment'
getSubsetExperiment(x, subsetName, parentData = TRUE)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
getSubsetExperiment(x, subsetName, parentData = TRUE)

Arguments

x

Input ExperimentSubset object.

subsetName

character(1) The name of the subset.

parentData

logical(1) Include the main object's rowData and colData columns for the subset's rows and columns, as with parentRowData and parentColData. They are marked so that setSubsetExperiment doesn't store copies of them. A subset's own column hides the main object's column of the same name, with a message if their values differ. Default TRUE.

Value

An object of the main object's class with the subset's rows and columns and row and column names. Its assays are every assay the subset sees, its own and those linked from its parent, under their names, with the subset's primary assay first. Its rowData and colData are the subset's, after the main object's columns if parentData = TRUE. Its altExps are every altExp the subset sees, its own and those linked from the main object or a parent subset, cut to its columns (see ExperimentSubset-altExp). Its reducedDims and metadata are the subset's. Everything else, such as row ranges, row and column trees, spatial coordinates, images, colPairs and rowPairs, comes from the main object.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es, "subset1", rows = 1:100, cols = 1:50)
subset1 <- getSubsetExperiment(es, "subset1")
subset1

reducedDimNames

Description

A wrapper to the reducedDimNames from reducedDims method with additional support for subsets.

Usage

reducedDimNames(x, ...)

## S4 method for signature 'ANY'
reducedDimNames(x, ...)

Arguments

x

Input ExperimentSubset object or any object supported by reducedDimNames from reducedDims method.

...

Only subsetName, the name of the subset whose reducedDimNames to get, given by name. Leave it out for the main object's. A subset name by position, or any other argument, is an error.

Value

The reducedDimNames from the specified subset or same as reducedDimNames from reducedDims when subsetName is missing.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es, "subset1",
rows = c(1:50), cols = c(1:20),
parentAssay = "counts")
# two small reduced dimensions, one row per cell in the subset
set.seed(1)
pca1 <- matrix(rnorm(40), nrow = 20)
pca2 <- matrix(rnorm(40), nrow = 20)
reducedDims(es, subsetName = "subset1") <- list(PCA_1 = pca1, PCA_2 = pca2)
reducedDimNames(es, subsetName = "subset1")

reducedDimNames<-

Description

A wrapper to the reducedDimNames<- from reducedDims method with additional support for subsets.

Usage

reducedDimNames(x, subsetName) <- value

## S4 replacement method for signature 'ANY'
reducedDimNames(x, subsetName) <- value

Arguments

x

Input ExperimentSubset object or any object supported by reducedDimNames<- from reducedDims method.

subsetName

Specify the name of the subset to which the reducedDimNames<- should be set to. If missing, reducedDimNames<- from reducedDims method is called on the main object.

value

Input value same as reducedDimNames<- from reducedDims method.

Value

Input object with reducedDimNames<- set.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es, "subset1",
rows = c(1:50), cols = c(1:20),
parentAssay = "counts")
# two small reduced dimensions, one row per cell in the subset
set.seed(1)
pca1 <- matrix(rnorm(40), nrow = 20)
pca2 <- matrix(rnorm(40), nrow = 20)
reducedDims(es, subsetName = "subset1") <- list(PCA_1 = pca1, PCA_2 = pca2)
reducedDimNames(es, subsetName = "subset1") <- c("rDim1", "rDim2")

Method for storing new assays inside subsets in ExperimentSubset objects

Description

Store a new subset assay inside a specified subset in the input ExperimentSubset object.

Usage

setSubsetAssay(x, subsetName, inputMatrix, subsetAssayName, unlink = FALSE)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
setSubsetAssay(x, subsetName, inputMatrix, subsetAssayName, unlink = FALSE)

## S4 method for signature 'SubsetSingleCellExperiment'
setSubsetAssay(x, subsetName, inputMatrix, subsetAssayName, unlink = FALSE)

## S4 method for signature 'SubsetSummarizedExperiment'
setSubsetAssay(x, subsetName, inputMatrix, subsetAssayName, unlink = FALSE)

## S4 method for signature 'SubsetSpatialExperiment'
setSubsetAssay(x, subsetName, inputMatrix, subsetAssayName, unlink = FALSE)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
setSubsetAssay(x, subsetName, inputMatrix, subsetAssayName, unlink = FALSE)

Arguments

x

ExperimentSubset Specify the input object.

subsetName

character(1) Specify the name of the existing subset inside which the new subset assay should be stored.

inputMatrix

A matrix-like object (for example a matrix or dgCMatrix) to store as an assay in the subset.

subsetAssayName

character(1) Specify the name of the new assay against the inputMatrix parameter. It can't contain "/". A subset sees its parent's assays as linked assays, so a name linked from the parent (for example a main assay) needs unlink.

unlink

TRUE, FALSE or a character vector of assay names. Store the assay even though the subset sees an assay of that name linked from its parent: with TRUE, or with a character vector that contains subsetAssayName. The subset, and subsets made from it, then use this assay instead, and a message says what was unlinked; the parent's is unchanged. Default FALSE.

Value

Updated ExperimentSubset object with the new assay stored inside the specified subset.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es, "subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
counts1p <- assay(es, "subset1")
counts1p[,] <- counts1p[,] + 1
es <- setSubsetAssay(es, "subset1", counts1p, "scaledSubset1")
es

Store a standalone experiment object back into a subset

Description

Stores what a tool added to an object returned by getSubsetExperiment: new assays, rowData and colData columns, reducedDims, altExps and metadata.

Usage

setSubsetExperiment(x, subsetName, value, unlink = FALSE)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
setSubsetExperiment(x, subsetName, value, unlink = FALSE)

## S4 method for signature 'SubsetSingleCellExperiment'
setSubsetExperiment(x, subsetName, value, unlink = FALSE)

## S4 method for signature 'SubsetSummarizedExperiment'
setSubsetExperiment(x, subsetName, value, unlink = FALSE)

## S4 method for signature 'SubsetSpatialExperiment'
setSubsetExperiment(x, subsetName, value, unlink = FALSE)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
setSubsetExperiment(x, subsetName, value, unlink = FALSE)

Arguments

x

Input ExperimentSubset object.

subsetName

character(1) The name of the subset.

value

An object of the main object's class (not a subclass or a parent class) with the subset's dimensions and the subset's row and column names, in the same order. A tool that drops rows or columns is followed by createSubset instead.

unlink

TRUE, FALSE or a character vector of assay names. Store assays of value that have the name of an assay linked from the subset's parent but different values, as with setSubsetAssay: with TRUE, every such assay; with a character vector, only those it names. An assay of an altExp is named "altExpName/assayName", such as "ADT/counts". Any other such assay, of the main object or an altExp, is an error, and nothing is stored. A message names each assay that is unlinked. Names of assays that are not linked, or unchanged, are ignored, so unlink = "decontXcounts" stores a changed decontXcounts but stops if counts was changed too. Default FALSE.

Value

Updated ExperimentSubset object. Linked assays that are in value hold the same values as what the subset sees (whatever their dimnames, type or class) are not stored, and neither are the main object's rowData and colData columns added by getSubsetExperiment. altExps are stored as altExp<- stores them (see ExperimentSubset-altExp): only the assays and data that differ from a linked altExp, and a linked altExp missing from value stays linked. Everything else in value replaces the subset's own data: an own assay, reducedDim, altExp or column that value no longer has is removed from the subset, except an assay another subset was made from, which is an error. Nothing else is stored: not row ranges, row and column trees, spatial coordinates, images, colPairs, rowPairs or mainExpName.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es, "subset1", rows = 1:100, cols = 1:50)
subset1 <- getSubsetExperiment(es, "subset1")
# add a reducedDim and a colData column to the standalone object
reducedDim(subset1, "random") <- matrix(rnorm(100), nrow = 50)
subset1$group <- rep(c("a", "b"), 25)
# and store them in the subset
es <- setSubsetExperiment(es, "subset1", subset1)
reducedDimNames(es, subsetName = "subset1")

Count method for subset assays in ExperimentSubset objects

Description

Get the count of the total available subsets and the subset assays inside these subsets in an ExperimentSubset object.

Usage

subsetAssayCount(x)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetAssayCount(x)

## S4 method for signature 'SubsetSingleCellExperiment'
subsetAssayCount(x)

## S4 method for signature 'SubsetSummarizedExperiment'
subsetAssayCount(x)

## S4 method for signature 'SubsetSpatialExperiment'
subsetAssayCount(x)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetAssayCount(x)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

Value

A numeric value representing the sum of the subset count and subset assay count.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
assay(es, "subset1",
subsetAssayName = "subset1pAssay") <- assay(es, "subset1")[,] + 1
subsetAssayCount(es)

Name retrieval method for all subset assays in ExperimentSubset objects

Description

Retrieves the names of all the subsets as well as the subset assays.

Usage

subsetAssayNames(x, subsetName = NULL)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetAssayNames(x, subsetName = NULL)

## S4 method for signature 'SubsetSingleCellExperiment'
subsetAssayNames(x, subsetName = NULL)

## S4 method for signature 'SubsetSummarizedExperiment'
subsetAssayNames(x, subsetName = NULL)

## S4 method for signature 'SubsetSpatialExperiment'
subsetAssayNames(x, subsetName = NULL)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetAssayNames(x, subsetName = NULL)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) If given, list the assays seen in this subset instead: its own assays and those linked from its parent. Default NULL.

Value

A vector containing the names of the subsets followed by each assay stored in a subset as "subset/assay", or, with subsetName, the names of the assays seen in that subset.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es, "subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
assay(es, "subset1",
subsetAssayName = "subset1pAssay") <- assay(es, "subset1")[,] + 1
subsetAssayNames(es)
subsetAssayNames(es, subsetName = "subset1")

Accessor method for colData from subsets in ExperimentSubset objects

Description

Get colData from a subset.

Set colData to a subset.

Usage

subsetColData(x, subsetName, parentColData)

subsetColData(x, subsetName) <- value

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetColData(x, subsetName, parentColData)

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment'
subsetColData(x, subsetName) <- value

## S4 method for signature 'SubsetSingleCellExperiment'
subsetColData(x, subsetName, parentColData)

## S4 replacement method for signature 'SubsetSingleCellExperiment'
subsetColData(x, subsetName) <- value

## S4 replacement method for signature 'SubsetSummarizedExperiment'
subsetColData(x, subsetName) <- value

## S4 method for signature 'SubsetSummarizedExperiment'
subsetColData(x, subsetName, parentColData)

## S4 method for signature 'SubsetSpatialExperiment'
subsetColData(x, subsetName, parentColData)

## S4 replacement method for signature 'SubsetSpatialExperiment'
subsetColData(x, subsetName) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetColData(x, subsetName, parentColData)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) Name of the subset to set colData to.

parentColData

logical(1) Logical value indicating if parent colData should be combined or not. A subset's own column hides the main object's column of the same name, with a message if their values differ. Default FALSE.

value

Input DataFrame to store; a data.frame is converted to one, and NULL removes the subset's own colData columns. Its rownames must be NULL or the subset's column names, in the same order; other rownames are an error. Use subsetColnames<- to rename columns.

Value

The colData from input object.

Input object with colData stored.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
subsetColData(es, "subset1")

subsetColnames

Description

Get colnames from a subset in the ExperimentSubset object.

Set colnames to a subset in the ExperimentSubset object.

Usage

subsetColnames(x, subsetName)

subsetColnames(x, subsetName) <- value

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetColnames(x, subsetName)

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment'
subsetColnames(x, subsetName) <- value

## S4 method for signature 'SubsetSingleCellExperiment'
subsetColnames(x, subsetName)

## S4 replacement method for signature 'SubsetSingleCellExperiment'
subsetColnames(x, subsetName) <- value

## S4 method for signature 'SubsetSummarizedExperiment'
subsetColnames(x, subsetName)

## S4 replacement method for signature 'SubsetSummarizedExperiment'
subsetColnames(x, subsetName) <- value

## S4 method for signature 'SubsetSpatialExperiment'
subsetColnames(x, subsetName)

## S4 replacement method for signature 'SubsetSpatialExperiment'
subsetColnames(x, subsetName) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetColnames(x, subsetName)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment'
subsetColnames(x, subsetName) <- value

Arguments

x

Input ExperimentSubset object.

subsetName

Name of the subset to set colnames to.

value

Specify the colname values to replace.

Value

A vector of colnames.

Input object with colnames set to a subset.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
subsetColnames(es, "subset1")

Get or set the colTree of subsets in ExperimentSubset objects

Description

Get the column tree of a subset: its own, if it stores one; otherwise that of the nearest subset it was made from that stores one; otherwise the main object's. TreeSummarizedExperiment's colTree takes no subsetName, so subsets use subsetColTree.

subsetColTree<- stores a tree of the subset's own, linking each column to the node whose label is the column's name in the subset, without changing the main object or other subsets. Subsets made from it use the tree too, unless they store their own. NULL removes the subset's own tree. setSubsetExperiment also stores a column tree that a tool changed, but not the removal of one, as a subset always uses its own tree, a parent's or the main object's. A subset's own tree is its only column tree, so get it with whichTree = 1. rbind and cbind keep subsets' own trees; combineCols and combineRows return classes without trees (see ExperimentSubset-combine).

Usage

subsetColTree(x, subsetName, whichTree = 1)

subsetColTree(x, subsetName) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetColTree(x, subsetName, whichTree = 1)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment'
subsetColTree(x, subsetName) <- value

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) Name of the subset to get the tree of, or to store it in.

whichTree

The name or position of the tree to get, as in colTree. Default 1.

value

A phylo tree whose node labels include every column name of the subset, or NULL.

Value

For subsetColTree, a phylo tree, or NULL if there is none. For subsetColTree<-, the input object with the subset's tree stored.

Examples

# a small TreeSummarizedExperiment with a tree on its columns
data("tinyTree", package = "TreeSummarizedExperiment")
counts <- matrix(1:100, nrow = 10)
colnames(counts) <- tinyTree$tip.label
tse <- TreeSummarizedExperiment(assays = list(counts = counts),
                                colTree = tinyTree)
es <- ExperimentSubset(tse)
es <- createSubset(es, "subset1", cols = 1:5)
# store a tree with the same labels on other tips
ownTree <- tinyTree
ownTree$tip.label <- rev(tinyTree$tip.label)
subsetColTree(es, subsetName = "subset1") <- ownTree
subsetColTree(es, subsetName = "subset1")
subsetColLinks(es, subsetName = "subset1")

Subset count method for ExperimentSubset objects

Description

Get the total count of the available subsets (excluding subset assays) in an ExperimentSubset object.

Usage

subsetCount(x)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetCount(x)

## S4 method for signature 'SubsetSingleCellExperiment'
subsetCount(x)

## S4 method for signature 'SubsetSummarizedExperiment'
subsetCount(x)

## S4 method for signature 'SubsetSpatialExperiment'
subsetCount(x)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetCount(x)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

Value

A numeric value representing the total count of the subsets.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
subsetCount(es)

Get dimensions of subsets in ExperimentSubset objects

Description

Retrieves the dimensions of the specified subset in an ExperimentSubset object.

Usage

subsetDim(x, subsetName)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetDim(x, subsetName)

## S4 method for signature 'SubsetSingleCellExperiment'
subsetDim(x, subsetName)

## S4 method for signature 'SubsetSummarizedExperiment'
subsetDim(x, subsetName)

## S4 method for signature 'SubsetSpatialExperiment'
subsetDim(x, subsetName)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetDim(x, subsetName)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) Name of the subset to retrieve the dimensions from.

Value

A vector containing the dimensions of the specified subset i.e. the number of rows and the number of columns in the subset.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
subsetDim(es, "subset1")

Accessor method for imgData of subsets in ExperimentSubset objects

Description

Get the images of a subset: the rows of the main object's imgData whose sample_id is the sample of one or more of the subset's spots. They are looked up from the main object each time, so they are always current; subsets don't store images of their own.

Usage

subsetImgData(x, subsetName)

## S4 method for signature 'SubsetSpatialExperiment'
subsetImgData(x, subsetName)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) Name of the subset to get imgData from.

Value

A DataFrame of the subset's images, with the columns of imgData().

Examples

# a small SpatialExperiment with six spots in two samples, and an image
# of each sample
counts <- matrix(1:60, nrow = 10)
coords <- cbind(x = 1:6, y = 6:1)
sampleIds <- rep(c("A", "B"), each = 3)
image <- SpatialImage(as.raster(matrix(c(0, 1, 1, 0), nrow = 2)))
images <- DataFrame(sample_id = c("A", "B"), image_id = "lowres",
                    data = I(list(image, image)), scaleFactor = 1)
spe <- SpatialExperiment(assays = list(counts = counts),
                         sample_id = sampleIds,
                         spatialCoords = coords,
                         imgData = images)
es <- ExperimentSubset(spe)
# a subset of spots from sample B only
es <- createSubset(es, "sampleB", cols = 4:6)
subsetImgData(es, subsetName = "sampleB")

Get names of only the subsets in ExperimentSubset objects

Description

Retrieves the names of the available subsets (not the subset assays) in an ExperimentSubset object.

Usage

subsetNames(x)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetNames(x)

## S4 method for signature 'SubsetSingleCellExperiment'
subsetNames(x)

## S4 method for signature 'SubsetSummarizedExperiment'
subsetNames(x)

## S4 method for signature 'SubsetSpatialExperiment'
subsetNames(x)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetNames(x)

Arguments

x

ExperimentSubset Specify the input ES object.

Value

A vector of subset names.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
subsetNames(es)

Subset parent hierarchy retrieval method for ExperimentSubset objects

Description

Retrieves a complete 'subset to parent' link from a specified subset.

Usage

subsetParent(x, subsetName)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetParent(x, subsetName)

## S4 method for signature 'SubsetSingleCellExperiment'
subsetParent(x, subsetName)

## S4 method for signature 'SubsetSummarizedExperiment'
subsetParent(x, subsetName)

## S4 method for signature 'SubsetSpatialExperiment'
subsetParent(x, subsetName)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetParent(x, subsetName)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) Specify the name of the subset, or an assay stored in a subset as "subset/assay", against which the 'subset to parent link' should be retrieved.

Value

A list containing the 'subset to parent' link.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es, "subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
assay(es, "subset1",
subsetAssayName = "subset1pAssay") <- assay(es, "subset1")[,] + 1
subsetParent(es, "subset1/subset1pAssay")

An S4 class for RangedSummarizedExperiment objects with added support for subsets.

Description

An S4 class for RangedSummarizedExperiment objects with added support for subsets.

Usage

## S4 method for signature 'SubsetRangedSummarizedExperiment'
show(object)

Arguments

object

The object to print, with its subsets and their assays.

Value

show() prints the object and returns NULL invisibly.

Slots

subsets

A list of AssaySubset objects.


Accessor method for rowData from subsets in ExperimentSubset objects

Description

Get rowData from a subset.

Set rowData to a subset.

Usage

subsetRowData(x, subsetName, parentRowData)

subsetRowData(x, subsetName) <- value

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetRowData(x, subsetName, parentRowData)

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment'
subsetRowData(x, subsetName) <- value

## S4 method for signature 'SubsetSingleCellExperiment'
subsetRowData(x, subsetName, parentRowData)

## S4 replacement method for signature 'SubsetSingleCellExperiment'
subsetRowData(x, subsetName) <- value

## S4 replacement method for signature 'SubsetSummarizedExperiment'
subsetRowData(x, subsetName) <- value

## S4 method for signature 'SubsetSummarizedExperiment'
subsetRowData(x, subsetName, parentRowData)

## S4 method for signature 'SubsetSpatialExperiment'
subsetRowData(x, subsetName, parentRowData)

## S4 replacement method for signature 'SubsetSpatialExperiment'
subsetRowData(x, subsetName) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetRowData(x, subsetName, parentRowData)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) Name of the subset to set rowData to.

parentRowData

logical(1) Logical value indicating if parent rowData should be combined or not. A subset's own column hides the main object's column of the same name, with a message if their values differ. Default FALSE.

value

Input DataFrame to store; a data.frame is converted to one, and NULL removes the subset's own rowData columns. Its rownames must be NULL or the subset's row names, in the same order; other rownames are an error, since rows are matched by position. To store a table with other rownames, such as gene IDs for rows named by symbol, put its rows in the subset's order and set rownames(value) <- NULL first.

Value

The rowData from input object.

Input object with rowData stored.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
subsetRowData(es, "subset1")

subsetRownames

Description

Get rownames from a subset in the ExperimentSubset object.

Set rownames to a subset in the ExperimentSubset object.

Usage

subsetRownames(x, subsetName)

subsetRownames(x, subsetName) <- value

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetRownames(x, subsetName)

## S4 replacement method for signature 'SubsetRangedSummarizedExperiment'
subsetRownames(x, subsetName) <- value

## S4 method for signature 'SubsetSingleCellExperiment'
subsetRownames(x, subsetName)

## S4 replacement method for signature 'SubsetSingleCellExperiment'
subsetRownames(x, subsetName) <- value

## S4 method for signature 'SubsetSummarizedExperiment'
subsetRownames(x, subsetName)

## S4 replacement method for signature 'SubsetSummarizedExperiment'
subsetRownames(x, subsetName) <- value

## S4 method for signature 'SubsetSpatialExperiment'
subsetRownames(x, subsetName)

## S4 replacement method for signature 'SubsetSpatialExperiment'
subsetRownames(x, subsetName) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetRownames(x, subsetName)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment'
subsetRownames(x, subsetName) <- value

Arguments

x

Input ExperimentSubset object.

subsetName

Name of the subset to get rownames from or set them to.

value

Specify the rownames values to replace.

Value

A vector of rownames.

Input object with rownames set to a subset.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
subsetRownames(es, "subset1")

Get or set the rowTree of subsets in ExperimentSubset objects

Description

Get the row tree of a subset: its own, if it stores one; otherwise that of the nearest subset it was made from that stores one; otherwise the main object's. TreeSummarizedExperiment's rowTree takes no subsetName, so subsets use subsetRowTree.

subsetRowTree<- stores a tree of the subset's own, linking each row to the node whose label is the row's name in the subset, without changing the main object or other subsets. Subsets made from it use the tree too, unless they store their own. NULL removes the subset's own tree. setSubsetExperiment also stores a row tree that a tool changed, but not the removal of one, as a subset always uses its own tree, a parent's or the main object's. A subset's own tree is its only row tree, so get it with whichTree = 1. rbind and cbind keep subsets' own trees; combineCols and combineRows return classes without trees (see ExperimentSubset-combine).

Usage

subsetRowTree(x, subsetName, whichTree = 1)

subsetRowTree(x, subsetName) <- value

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetRowTree(x, subsetName, whichTree = 1)

## S4 replacement method for signature 'SubsetTreeSummarizedExperiment'
subsetRowTree(x, subsetName) <- value

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) Name of the subset to get the tree of, or to store it in.

whichTree

The name or position of the tree to get, as in rowTree. Default 1.

value

A phylo tree whose node labels include every rowname of the subset, or NULL.

Value

For subsetRowTree, a phylo tree, or NULL if there is none. For subsetRowTree<-, the input object with the subset's tree stored.

Examples

# a small TreeSummarizedExperiment with a tree on its rows
data("tinyTree", package = "TreeSummarizedExperiment")
counts <- matrix(1:100, nrow = 10)
rownames(counts) <- tinyTree$tip.label
tse <- TreeSummarizedExperiment(assays = list(counts = counts),
                                rowTree = tinyTree)
es <- ExperimentSubset(tse)
es <- createSubset(es, "subset1", rows = 1:5)
# the subset uses the main object's tree
subsetRowTree(es, subsetName = "subset1")
# store a tree with the same labels on other tips
ownTree <- tinyTree
ownTree$tip.label <- rev(tinyTree$tip.label)
subsetRowTree(es, subsetName = "subset1") <- ownTree
subsetRowLinks(es, subsetName = "subset1")
# the main object's links are unchanged
rowLinks(es)[1:5, ]

An S4 class for SingleCellExperiment objects with added support for subsets.

Description

An S4 class for SingleCellExperiment objects with added support for subsets.

Usage

## S4 method for signature 'SubsetSingleCellExperiment'
show(object)

Arguments

object

The object to print, with its subsets and their assays.

Value

show() prints the object and returns NULL invisibly.

Slots

subsets

A list of AssaySubset objects.


Get or set spatialCoords of subsets in ExperimentSubset objects

Description

Get spatialCoords from a subset, with subsetSpatialCoords(x, subsetName) or spatialCoords(x, subsetName = ). Without subsetName, spatialCoords() returns the main object's, as for SpatialExperiment.

subsetSpatialCoords(x, subsetName) <- value stores a subset's own spatialCoords, for example after a transformation, without changing the main object's. A subset with its own coordinates returns them from subsetSpatialCoords(), spatialCoords(x, subsetName = ) and getSubsetExperiment(), and subsets made from it see them, cut to their spots. A subset without its own coordinates sees those of the nearest subset it was made from that has them, or else the main object's.

Usage

subsetSpatialCoords(x, subsetName)

subsetSpatialCoords(x, subsetName) <- value

## S4 method for signature 'SubsetSpatialExperiment'
subsetSpatialCoords(x, subsetName)

## S4 replacement method for signature 'SubsetSpatialExperiment'
subsetSpatialCoords(x, subsetName) <- value

## S4 method for signature 'SubsetSpatialExperiment'
spatialCoords(x, ...)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) Name of the subset to get spatialCoords from, or to store them in.

value

A numeric matrix with one row for each spot in the subset and one or more columns. Its rownames must be NULL or the subset's column names, in the same order. NULL removes the subset's own coordinates, so it sees those of the subset it was made from, or the main object's, again.

...

For spatialCoords():

subsetName

character(1) Name of the subset to get spatialCoords from. Leave it out for the main object's.

Without subsetName, all arguments are passed on to the SpatialExperiment method.

Value

For subsetSpatialCoords() and spatialCoords(), the spatialCoords the subset sees.

For subsetSpatialCoords<-, the input object with the subset's spatialCoords stored.

Examples

# a small SpatialExperiment with six spots
counts <- matrix(1:60, nrow = 10)
coords <- cbind(x = 1:6, y = 6:1)
spe <- SpatialExperiment(assays = list(counts = counts),
                         spatialCoords = coords)
es <- ExperimentSubset(spe)
es <- createSubset(es, "subset1", cols = 2:4)
subsetSpatialCoords(es, "subset1")
# the same, through spatialCoords()
spatialCoords(es, subsetName = "subset1")
# a small SpatialExperiment with six spots
counts <- matrix(1:60, nrow = 10)
coords <- cbind(x = 1:6, y = 6:1)
spe <- SpatialExperiment(assays = list(counts = counts),
                         spatialCoords = coords)
es <- ExperimentSubset(spe)
es <- createSubset(es, "subset1", cols = 2:4)
# store coordinates moved 100 to the right
movedCoords <- subsetSpatialCoords(es, subsetName = "subset1")
movedCoords[, "x"] <- movedCoords[, "x"] + 100
subsetSpatialCoords(es, subsetName = "subset1") <- movedCoords
subsetSpatialCoords(es, subsetName = "subset1")
# the main object's coordinates are unchanged
spatialCoords(es)

Deprecated: spatialData of subsets in ExperimentSubset objects

Description

subsetSpatialData() and spatialData(x, subsetName =) are deprecated, and subsetSpatialData<- is defunct, because spatialData() and spatialData<- are deprecated in SpatialExperiment, which now keeps these columns in colData. Use subsetColData(x, subsetName) to get them, which returns all of the subset's colData columns, with parentColData = TRUE to include the main object's, and colData(x, subsetName = "name")$column <- values to add a column to a subset. The getters will be defunct in the next release.

Usage

subsetSpatialData(x, subsetName, parentSpatialData)

subsetSpatialData(x, subsetName) <- value

## S4 method for signature 'SubsetSpatialExperiment'
subsetSpatialData(x, subsetName, parentSpatialData)

## S4 method for signature 'SubsetSpatialExperiment'
spatialData(x, ...)

## S4 replacement method for signature 'SubsetSpatialExperiment'
subsetSpatialData(x, subsetName) <- value

Arguments

x

ExperimentSubset Input ExperimentSubset object.

subsetName

character(1) Name of the subset to set spatialData to.

parentSpatialData

logical(1) Logical value indicating if parent spatialData should be combined or not. Default FALSE.

value

Ignored: the setter is defunct.

...

For spatialData(): subsetName and parentSpatialData, as for subsetSpatialData(). Without subsetName, all arguments are passed on to the SpatialExperiment method.

Value

The spatialData from input object, with a deprecation warning. The setter fails with an error.

See Also

subsetColData


An S4 class for SpatialExperiment objects with added support for subsets.

Description

An S4 class for SpatialExperiment objects with added support for subsets.

Usage

## S4 method for signature 'SubsetSpatialExperiment'
show(object)

Arguments

object

The object to print, with its subsets and their assays.

Value

show() prints the object and returns NULL invisibly.

Slots

subsets

A list of AssaySubset objects.


An S4 class for SummarizedExperiment objects with added support for subsets.

Description

An S4 class for SummarizedExperiment objects with added support for subsets.

Usage

## S4 method for signature 'SubsetSummarizedExperiment'
show(object)

Arguments

object

The object to print, with its subsets and their assays.

Value

show() prints the object and returns NULL invisibly.

Slots

subsets

A list of AssaySubset objects.


Method for displaying 'child-parent' link structure of subsets in ExperimentSubset objects

Description

The function displays the content of an ExperimentSubset object including all available main assays, all subsets and the subset assays inside these subsets. This function also depicts how and in what order the subsets in the object are linked with their parents. Moreover, all supplementary data inside the subsets such as reducedDims and altExps are also displayed against each subset entry.

Usage

subsetSummary(x)

## S4 method for signature 'SubsetRangedSummarizedExperiment'
subsetSummary(x)

## S4 method for signature 'SubsetSingleCellExperiment'
subsetSummary(x)

## S4 method for signature 'SubsetSummarizedExperiment'
subsetSummary(x)

## S4 method for signature 'SubsetSpatialExperiment'
subsetSummary(x)

## S4 method for signature 'SubsetTreeSummarizedExperiment'
subsetSummary(x)

Arguments

x

ExperimentSubset Input ExperimentSubset object.

Value

Prints all the available subset information against the input ExperimentSubset object.

Examples

data(sce_chcl, package = "scds")
es <- ExperimentSubset(sce_chcl)
es <- createSubset(es,
"subset1",
rows = c(10,11,50,56,98,99,102,105,109, 200),
cols = c(20,21,40,45,90,99,100,123,166,299),
parentAssay = "counts")
assay(es, "subset1",
subsetAssayName = "subset1pAssay") <- assay(es, "subset1")[,] + 1
subsetSummary(es)

An S4 class for TreeSummarizedExperiment objects with added support for subsets.

Description

An S4 class for TreeSummarizedExperiment objects with added support for subsets.

Usage

## S4 method for signature 'SubsetTreeSummarizedExperiment'
show(object)

Arguments

object

The object to print, with its subsets and their assays.

Value

show() prints the object and returns NULL invisibly.

Slots

subsets

A list of AssaySubset objects.