CustomSelectionsState

CustomSelectionsState

Applications can perform marker detection on custom selections of cells. This allows users to dynamically select cells on a UI and quickly obtain a list of distinguishing markers for that selection. This wraps the scoreMarkers function from scran.js.

Users should not construct these instances manually; instead, they are automatically assembled by createAnalysis. Similarly, users should not directly call the compute method, which is instead invoked by runAnalysis.

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

Classes

CustomSelectionsState

Methods

addSelection(id, selection, optionsopt)

Description:
  • Add a custom selection and compute its markers. It is assumed that runAnalysis was already run on this instance before calling this method.

Source:
Parameters:
Name Type Attributes Description
id string

A unique identifier for the new custom selection.

selection Array | TypedArray

The indices of the cells in the selection. Indices should refer to positions of cells in the QC-filtered matrix, not the original matrix.

options object <optional>

Optional parameters.

Properties
Name Type Attributes Default Description
copy boolean <optional>
true

Whether to make a copy of selection before storing it inside this object. If false, it is assumed that the caller makes no further modifications to the passed selection.

Returns:

The custom selection is added to the state and calculation of its markers is performed. Nothing is returned.

compute(parameters)

Source:
Parameters:
Name Type Description
parameters object

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

Properties
Name Type Description
lfc_threshold number

Log-fold change threshold to use when computing the Cohen's d and AUC for each pairwise comparison.

compute_auc boolean

Whether to compute the AUCs. Setting this to false will skip AUC calculations and improve speed and memory efficiency.

Returns:

The state is updated by removing stale selections if the QC filter was altered.

computeVersus(left, right) → {object}

Description:
  • Extract markers for a pairwise comparison between two selections for more detailed examination of the differences between them.

Source:
Parameters:
Name Type Description
left string

Identifier of one selection in which to find upregulated markers.

right string

Identifier of another selection to be compared against left.

Returns:

Object containing:

  • results: object containing the marker statistics for the comparison between two clusters. Each key is a modality name and each value is a ScoreMarkersResults object.
  • left: index of the group corresponding to the left selection in each ScoreMarkersResults object. e.g., Cohen's d for the RNA markers of the left selection are defined as output.results.RNA.cohen(output.left).
  • right: index of the group corresponding to the right selection in each ScoreMarkersResults object. e.g., Cohen's d for the RNA markers of the right selection are defined as output.results.RNA.cohen(output.right).
Type
object

fetchParameters() → {object}

Source:
Returns:

Object containing the parameters.

Type
object

fetchResults(id) → {object}

Source:
Parameters:
Name Type Description
id string

An identifier for the desired selection.

Returns:

Object containing the markers for the desired selection. Each key is a modality name while each value is a ScoreMarkersResults object, containing the marker detection results across all features of the corresponding modality. The set of cells in the selection is denoted as group 1, while all cells outside of the selection are denoted as group 0.

Type
object

fetchSelectionIndices(id, optionsopt) → {Array|TypedArray}

Description:
  • Retrieve the indices for a selection of interest.

Source:
Parameters:
Name Type Attributes Description
id string

The identifier for the selection.

options object <optional>

Optional parameters.

Properties
Name Type Attributes Default Description
copy boolean <optional>
true

Whether to make a copy of selection before returning it. If false, it is assumed that the caller does not modify the selection.

Returns:

Array of indices in the requested selection. Note that indices are relative to the filtered matrix - use CellFilteringState.undoFiltering to convert them to indices on the original dataset.

Type
Array | TypedArray

fetchSelections(optionsopt, forceopt, nullable) → {object}

Description:
  • Retrieve indices for all selections.

Source:
Parameters:
Name Type Attributes Default Description
options object <optional>

Optional parameters.

Properties
Name Type Attributes Default Description
copy boolean <optional>
true

Whether to make a copy of selection before returning it. If false, it is assumed that the caller does not modify the selection.

force string <optional>
<nullable>
null

Whether to force each selection to be an "Array" or "Int32Array". If null, the existing type of each selection is used.

Returns:

Object where the keys are the selection names and the values are arrays of indices for each selection. Each array is a copy and can be modified without affecting the CustomSelectionsState. See fetchSelectionIndices for more details on the interpretation of the indices.

Type
object

free()

Description:
  • Frees all resources associated with this instance.

Source:

removeSelection(id)

Description:
  • Remove a custom selection and its results from the state.

Source:
Parameters:
Name Type Description
id string

An identifier for the selection to be removed.

Returns:

The specified selection and its results are removed from the state. Nothing is returned.

(static) defaults() → {object}

Source:
Returns:

Default parameters that may be modified and fed into compute.

Type
object