CellLabellingState

CellLabellingState

Cell labelling involves assigning cell type labels to clusters using the SingleR algorithm, based on pre-formatted reference expression profiles. This wraps labelCells and related functions from scran.js.

In theory, we could do this at the single-cell level, but we use clusters instead to expedite the computation and simplify interpretation. If multiple references are requested, we will use each for assignment before attempting to choose the best label for each cluster across references.

Methods not documented here are not part of the stable API and should not be used by applications.

Classes

CellLabellingState

Members

availableReferences :object

Description:
  • Available references for each species. Each key is a taxonomy ID and each value is an array of strings containing the names of references for that species.

Source:

Available references for each species. Each key is a taxonomy ID and each value is an array of strings containing the names of references for that species.

Type:
  • object

Methods

(async) compute(parameters)

Description:
  • This method should not be called directly by users, but is instead invoked by runAnalysis.

Source:
Parameters:
Name Type Description
parameters object

Parameter object, equivalent to the cell_labelling property of the parameters of runAnalysis.

Properties
Name Type Attributes Description
references Array <nullable>

Array of strings specifying the names of the reference datasets, see availableReferences for more details. If null, all reference datasets from all species are used.

guess_ids boolean

Automatically choose feature-based parameters based on the feature annotation for the RNA modality. If true, the column of the annotation that best matches human/mouse Ensembl/symbols is identified and used to set species, gene_id_column and gene_id_type.

species Array

Array of strings specifying zero, one or more species involved in this dataset. Each entry should be a taxonomy ID (e.g. "9606", "10090") as specified in availableReferences. This is used internally to filter references to the entries relevant to these species. Ignored if guess_ids = true.

gene_id_column string | number <nullable>

Name or index of the column of the RNA entry of InputsState.fetchFeatureAnnotations containing the identity of each gene. If null, identifiers are taken from the row names. Ignored if guess_ids = true.

gene_id_type string

Type of feature identifier in gene_id_column. This should be one of "ENSEMBL", "SYMBOL" or "ENTREZ" Ignored if guess_ids = true.

Returns:

The object is updated with the new results.

computeLabels(x, optionsopt) → {object}

Source:
Parameters:
Name Type Attributes Default Description
x external:ScranMatrix | external:ScoreMarkersResults

A matrix of (normalized or unnormalized) expression values, with genes in rows and cells/clusters in columns. Alternatively, an object containing marker results, e.g., as computed by MarkerDetectionState.

In both cases, the identity of genes should correspond to that in the upstream InputsState.

options object <optional>
{}

Optional parameters.

Properties
Name Type Attributes Default Description
group Array | TypedArray <optional>
<nullable>
null

Array of length equal to the number of columns of x, containing grouping assignments. If provided, the average expression profile of each group is used for cell type labelling. This is only used if x is a ScranMatrix.

Returns:

Object containing:

  • per_reference: an object where each key is the name of a reference dataset and its value is an array. Each array is of length equal to the number of columns of x (if matrix), groups in x (if marker results), or groups in group. Each entry is an object containing best, the name of the best label assigned to a column/group in this reference; and all, an object where each key is a label in this reference dataset and its value is the score for assigning that label to this column/group.
  • (optional) integrated: an array of length equal to the number of columns/groups. Each entry is an object containing best, the name of the best reference for this column/group; and all, an object where each key is the name of a reference dataset and its value is the score for this column/group. This property is only reported if multiple references are used.
  • (optional) groups: an array of length equal to the number of groups, containing the identity of each group. Only reported if an input group is supplied and x is a ScranMatrix.
Type
object

fetchNumberOfSharedFeatures() → {object}

Source:
Returns:

Object where each key is the name of a reference and each value is the number of shared features between the test and reference daatasets.

Type
object

fetchParameters() → {object}

Source:
Returns:

Object containing the parameters.

Type
object

fetchParameters() → {object}

Source:
Returns:

Object containing the parameters.

Type
object

(static) defaults() → {object}

Source:
Returns:

Default parameters that may be modified and fed into compute.

Type
object

(static) flush()

Description:
  • Flush all cached references.

    By default, compute will cache the loaded references in a global cache for re-use across CellLabellingState instances. These cached references are not tied to any single instance and will not be removed by garbage collectors or by freeAnalysis. Rather, this function should be called to release the relevant memory.

Source:

(static) setDownload(fun)

Description:
  • Specify a function to download references for the cell labelling step.

Source:
Parameters:
Name Type Description
fun function

Function that accepts a single string containing a URL and returns any value that can be used in the SimpleFile constructor. This is most typically a Uint8Array of that URL's contents, but it can also be a path to a locally cached file on Node.js.

Returns:

fun is set as the global downloader for this step. The previous value of the downloader is returned.