Skip to content

Commit 4045eef

Browse files
committed
Tidied up docstring for enrichment testing functions.
1 parent 72130a6 commit 4045eef

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

js/testGeneSetEnrichment.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import * as utils from "./utils.js";
1111
* Each entry of the array is a unique integer index identifying a marker gene in the common namespace, where each index lies in `[0, totalGenes)`.
1212
*
1313
* In other words, given a common namespace array `X` containing the gene names, the marker names can be obtained as `Array.from(markers).map(i => X[i])`.
14+
* See {@linkcode remapGeneSets} for more details.
1415
* @param {Array} geneSets - Array containing the gene sets.
1516
* Each entry corresponds to a single gene set and may be an Array or TypedArray.
1617
* Each array should contain unique indices for the genes belonging to the set.
1718
*
1819
* In other words, given a common namespace array `X` containing the gene names, the names of the genes in set `s` can be obtained as `Array.from(geneSets[s]).map(i => X[i])`.
20+
* See {@linkcode remapGeneSets} for more details.
1921
* @param {number} totalGenes - Total number of genes in the common namespace.
2022
* @param {object} [options={}] - Optional parameters.
2123
* @param {?number} [options.numberOfThreads=null] - Number of threads to use for computing the p-values, see {@linkcode hypergeometricTest}.
@@ -71,18 +73,19 @@ export function testGeneSetEnrichment(markers, geneSets, totalGenes, options = {
7173
* This involves defining a common namespace consisting of gene names that are shared in both namespaces,
7274
* and then mapping the gene sets to the common namespace.
7375
*
74-
* The `target_indices` property returned by this function can be used to generate the indices of `markers` in {@linkcode testGeneSetEnrichment}.
75-
* Given a function that determines whether a gene in the target namespace is a marker, we can populate `markers` as below:
76+
* The `target_indices` property returned by this function should be used to generate the indices of `markers=` in {@linkcode testGeneSetEnrichment}.
77+
* This is typically done by extracting the relevant marker statistics for all genes in the common namespace,
78+
* and then choosing the top markers with {@linkcode chooseTopMarkers}:
7679
*
7780
* ```
78-
* let markers = [];
79-
* target_indices.forEach((x, i) => {
80-
* if (is_marker(x)) { // in other words, 'targetGenes[x]' is a marker.
81-
* markers.push(i); // we want to store 'i' as this is the index into the common namespace.
82-
* }
83-
* });
81+
* let stats = marker_stats.auc(0); // statistics for all genes, typically from scran.scoreMarkers().
82+
* let stats_common = []; // subset to the statistics for genes in the common namespace.
83+
* target_indices.forEach(x => { stats_common_namespace.push(stats[x]); });
84+
* let markers_common = scran.chooseTopMarkers(stats_common, 1000);
8485
* ```
8586
*
87+
* The `sets` property returned by this function can be directly used as `geneSets=` in {@linkcode testGeneSetEnrichment}
88+
*
8689
* @param {Array} targetGenes - Array of strings containing the gene names in the target namespace.
8790
* Any `null` entries are considered to be incomparable.
8891
* @param {Array} referenceGenes - Array of strings containing the gene names in the reference namespace.
@@ -93,7 +96,7 @@ export function testGeneSetEnrichment(markers, geneSets, totalGenes, options = {
9396
*
9497
* @return {object} Object containing:
9598
*
96-
* - `target_indices`: an Int32Array of length equal to the number of common genes between `targetGenes` and `referenceGenes`.
99+
* - `target_indices`: an Int32Array of length equal to the size of the common namespace.
97100
* Each entry is an index into `targetGenes` to identify the gene in the common namespace,
98101
* i.e., the common namespace can be defined as `Array.from(target_indices).map(i => targetGenes[i])`.
99102
* - `reference_indices`: an Int32Array of length equal to the size of the common namespace.

0 commit comments

Comments
 (0)