FeatureSetEnrichmentState

FeatureSetEnrichmentState

This step tests for enrichment of particular feature sets in the set of top marker genes, based on marker rankings from MarkerDetectionState. It wraps the testFeatureSetEnrichment and scoreFeatureSet functions from scran.js.

This class uses the gesel package to download the default gene set databases for the relevant organisms. Its behavior can be tuned by setting global gesel variables, e.g., using the referenceDownload function.

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

Classes

FeatureSetEnrichmentState

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 feature_set_enrichment property of the parameters of runAnalysis.

Properties
Name Type Attributes Description
skip boolean

Whether to skip the preparation of feature set collections. If true, none of the other methods (e.g., computeEnrichment, computePerCellScores) should be called.

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, 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") supported by gesel. This is used internally to filter collections 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.

top_markers number

Number of top markers to use when testing for enrichment.

Returns:

The state is updated with new results.

computeEnrichment(markers, group, effect_size, summary) → {object}

Description:
  • Compute enrichment of top markers in each feature set. It is assumed that runAnalysis was already run on this FeatureSetEnrichmentState instance before calling this method.

Source:
Parameters:
Name Type Description
markers external:ScoreMarkersResults

Arbitrary marker detection results for an RNA modality, with the same order and identity of genes as from the upstream InputsState. This is most typically the output from MarkerDetectionState.fetchResults or equivalents from CustomSelectionsState.

group number

Index of the group of interest inside markers.

effect_size string

Effect size to use for ranking. This should be one of "cohen", "auc", "lfc" or "delta_detected".

summary string

Summary statistic to use for ranking. This should be one of "min", "mean" or "min_rank".

Returns:

Object containing the following properties:

  • set_ids: Int32Array of length equal to the number of sets, containing the set IDs. Each entry is an index into the arrays returned by fetchSetDetails.
  • counts: Int32Array of length equal to set_ids, containing the number of markers present in each set.
  • pvalues: Float64Array of length equal to counts, containing the enrichment p-values for each set.
  • num_markers: number of markers selected for testing.

Sets are guaranteed to be sorted by increasing p-value in pvalues.

Type
object

computePerCellScores(set_id) → {Object}

Description:
  • Compute per-cell scores for the activity of a feature set. It is assumed that runAnalysis was already run on this FeatureSetEnrichmentState instance before calling this method.

Source:
Parameters:
Name Type Description
set_id number

Feature set ID, defined as an index into the arrays returned by fetchSetDetails.

Returns:

Object containing:

  • indices: Int32Array containing the row indices of the genes in the set, relative to the RNA count matrix.
  • weights: Float64Array containing the weights of each gene in the set.
  • scores: Float64Array containing the feature set score for each cell.
Type
Object

fetchCollectionDetails() → {object}

Description:
  • Obtain the details about the feature set collections in the reference database. It is assumed that runAnalysis was already run on this FeatureSetEnrichmentState instance before calling this method.

Source:
Returns:

Object with the following properties:

  • names: Array of strings of length equal to the number of feature set collections, containing the names of the collections.
  • descriptions: Array of strings of length equal to names, containing the descriptions for all collections.
  • species: Array of strings of length equal to names, containing the taxonomy IDs for all collections.
Type
object

fetchFeatureSetIndices(set_id) → {Int32Array}

Description:
  • Extract row indices of the members of a desired feature set of interest. It is assumed that runAnalysis was already run on this FeatureSetEnrichmentState instance before calling this method.

Source:
Parameters:
Name Type Description
set_id number

Feature set ID, defined as an index into the arrays returned by fetchSetDetails.

Returns:

Array containing the row indices of the RNA count matrix corresponding to the genes in the specified set.

Type
Int32Array

fetchParameters() → {object}

Source:
Returns:

Object containing the parameters.

Type
object

fetchSetDetails() → {object}

Description:
  • Obtain the details about the feature sets in the reference database. It is assumed that runAnalysis was already run on this FeatureSetEnrichmentState instance before calling this method.

Source:
Returns:

Object with the following properties:

  • names: Array of strings of length equal to the number of feature sets across all collections, containing the names of those sets.
  • descriptions: Array of strings of length equal to names, containing the set descriptions.
  • sizes: Int32Array of length equal to names, containing the set sizes. Each set's size is defined as the number of features in the dataset that are successfully mapped to a member of the set.
  • collections: Int32Array of length equal to names, specifying the collection to which the set belongs. This is interpreted as the index of the arrays in fetchCollectionDetails.
Type
object

fetchUniverseSize() → {number}

Description:
  • Obtain the size of the universe of features that were successfully mapped to features in the reference database. It is assumed that runAnalysis was already run on this FeatureSetEnrichmentState instance before calling this method.

Source:
Returns:

Number of features from the input dataset that were successfully mapped to at least one gene in the reference database.

Type
number

free()

Description:
  • Frees all resources associated with this instance.

Source:

(static) defaults() → {object}

Source:
Returns:

Default parameters that may be modified and fed into compute.

Type
object