subset: Functions to subset ClusterExperiment Objects

subsetR Documentation

Functions to subset ClusterExperiment Objects

Description

These functions are used to subset ClusterExperiment objects, either by removing samples, genes, or clusterings

Usage

## S4 method for signature 'ClusterExperiment'
removeClusterings(x, whichClusters)

## S4 method for signature 'ClusterExperiment'
removeClusters(
  x,
  whichCluster,
  clustersToRemove,
  makePrimary = FALSE,
  clusterLabels = NULL
)

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

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

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

## S4 method for signature 'ClusterExperiment'
subsetByCluster(
  x,
  clusterValue,
  whichCluster = "primary",
  matchTo = c("name", "clusterIds")
)

Arguments

x

a ClusterExperiment object.

whichClusters

argument that can be either numeric or character vector indicating the clusterings to be used. See details of getClusterIndex.

whichCluster

argument that can be a single numeric or character value indicating the single clustering to be used. Giving values that result in more than one clustering will result in an error. See details of getClusterIndex.

clustersToRemove

numeric vector identifying the clusters to remove (whose samples will be reassigned to -1 value).

makePrimary

whether to make the added cluster the primary cluster (only relevant if y is a vector)

clusterLabels

label(s) for the clusters being added. If y a matrix, the column names of that matrix will be used by default, if clusterLabels is not given.

i, j

A vector of logical or integer subscripts, indicating the rows and columns to be subsetted for i and j, respectively.

...

The arguments transformation, clusterTypes and clusterInfo to be passed to the constructor for signature SingleCellExperiment,matrix.

drop

A logical scalar that is ignored.

clusterValue

values of the cluster to match to for subsetting

matchTo

whether to match to the cluster name ("name") or internal cluster id ("clusterIds")

Details

removeClusterings removes the clusters given by whichClusters. If the primaryCluster is one of the clusters removed, the primaryClusterIndex is set to 1 and the dendrogram and coclustering matrix are discarded and orderSamples is set to 1:NCOL(x).

removeClusters creates a new cluster that unassigns samples in cluster clustersToRemove (in the clustering defined by whichClusters) and assigns them to -1 (unassigned)

Note that when subsetting the data, the dendrogram information and the co-clustering matrix are lost.

Value

A ClusterExperiment object.

removeClusterings returns a ClusterExperiment object, unless all clusters are removed, in which case it returns a SingleCellExperiment object.

subsetByCluster subsets the object by clusters in a clustering and returns a ClusterExperiment object with only those samples

Examples

#load CE object
data(rsecFluidigm)
# remove the mergeClusters step from the object
clusterLabels(rsecFluidigm)
test<-removeClusterings(rsecFluidigm,whichClusters="mergeClusters")
clusterLabels(test)
tableClusters(rsecFluidigm)
test<-removeClusters(rsecFluidigm,whichCluster="mergeClusters",clustersToRemove=c("m01","m04"))
tableClusters(test,whichCluster="mergeClusters")

epurdom/clusterExperiment documentation built on Oct. 12, 2022, 5:27 a.m.