Methods
aggregateAcrossCells(x, groups, optionsopt) → {AggregateAcrossCellsResults}
- Source:
Aggregate per-cell expression profiles for each group of cells. This is typically used to summarize data into per-cluster expression profiles for easier inspection.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | Some expression matrix, typically containing normalized log-expression values. |
|||||||||||||||||
groups |
Int32Array | Int32WasmArray | Array containing group IDs for each cell.
This should have length equal to the number of cells and contain all values from 0 to |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the aggregation results.
buildNeighborSearchIndex(x, optionsopt) → {BuildNeighborSearchIndexResults}
- Source:
Build the nearest neighbor search index.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
RunPcaResults | Float64WasmArray | Array | TypedArray | Numeric coordinates of each cell in the dataset. For array inputs, this is expected to be in column-major format where the rows are the variables and the columns are the cells. For a RunPcaResults input, we extract the principal components. |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Index object to use for neighbor searches.
buildSnnGraph(x, optionsopt) → {BuildSnnGraphResults}
- Source:
Build a shared nearest graph where each cell is a node. Edges are formed between cells that share one or more nearest neighbors, weighted by the number or rank of those shared neighbors.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
BuildNeighborSearchIndexResults | FindNearestNeighborsResults | A pre-built neighbor search index from Alternatively, a pre-computed set of neighbor search results from {linkcode findNearestNeighbors}.
The number of neighbors should be equal to |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the graph.
- Type
- BuildSnnGraphResults
cbind(inputs) → {ScranMatrix}
Combine matrices by column, where all matrices contain data for the same features, in the same order.
Parameters:
Name | Type | Description |
---|---|---|
inputs |
Array | Array of one or more ScranMatrix objects. All of these should have the same number and order of features. |
Returns:
A ScranMatrix containing the matrices after combining them by column.
- Type
- ScranMatrix
cbindWithNames(inputs, names) → {object}
Combine matrices by column, after subsetting each matrix to the intersection of common features.
Parameters:
Name | Type | Description |
---|---|---|
inputs |
Array | Array of one or more ScranMatrix objects. |
names |
Array | Array of length equal to |
Returns:
An object containing:
matrix
, a ScranMatrix containing the combined matrices.indices
, an Int32Array of length equal to the number of rows inmatrix
. This contains the index of the row in the first entry ofinputs
corresponding to each row ofmatrix
, i.e., the gene at thei
-th row ofmatrix
is the same as the gene at theindices[i]
-th row ofinputs[0]
. This is guaranteed to be sorted.names
, an array of names identifying the rows ofmatrix
. This is constructed by indexing the first entry ofnames
withindices
.
- Type
- object
centerSizeFactors(sizeFactors, optionsopt) → {Float64Array|Float64WasmArray}
- Source:
Center size factors in preparation for log-transformation.
This is usually called by normalizeCounts
internally, but can also be directly called by users to reconstitute the size factors used in the log-normalized matrix.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sizeFactors |
TypedArray | WasmArray | Array of non-negative size factors, one per cell. |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Array containing the centered size factors.
If buffer
is supplied, the function returns buffer
if asTypedArray = false
, or a view on buffer
if asTypedArray = true
.
- Type
- Float64Array | Float64WasmArray
chooseHvgs(x, optionsopt) → {Uint8Array|Uint8WasmArray}
- Source:
Choose the highly variable genes from variance modelling statistics.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
TypedArray | ModelGeneVariancesResults | A TypedArray of statistics, where larger values correspond to higher variability; or a ModelGeneVariancesResults object, in which case the residuals are used as the statistics. |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Array of length equal to the number of genes.
Highly variable genes are marked with a value of 1 and all other genes have values of zero.
If buffer
is supplied, the function returns buffer
if asTypedArray = false
, or a view on buffer
if asTypedArray = true
.
- Type
- Uint8Array | Uint8WasmArray
chooseTemporaryPath(optionsopt) → {string}
- Source:
Choose a temporary file path on the system's default temporary directory (Node.js) or on the virtual file system (browser). This can be used to enable environment-agnostic creation of temporary files.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Temporary file path.
- Type
- string
clusterGraph(x, optionsopt) → {ClusterMultiLevelResults|ClusterWalktrapResults|ClusterLeidenResults}
- Source:
Cluster cells using community detection on the SNN graph.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
BuildSnnGraphResults | The shared nearest neighbor graph constructed by |
||||||||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the clustering results.
The class of this object depends on the choice of method
.
- Type
- ClusterMultiLevelResults | ClusterWalktrapResults | ClusterLeidenResults
clusterKmeans(x, clusters, optionsopt) → {ClusterKmeansResults}
- Source:
Cluster cells using k-means. A variety of initialization and refinement algorithms can be used here, see the kmeans documentation for more details.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
RunPcaResults | Float64WasmArray | Array | TypedArray | Numeric coordinates of each cell in the dataset. For array inputs, this is expected to be in column-major format where the rows are the variables and the columns are the cells. For a RunPcaResults input, we extract the principal components. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
clusters |
number | Number of clusters to create. This should not be greater than the number of cells. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the clustering results.
- Type
- ClusterKmeansResults
computeClrm1Factors(x, optionsopt) → {Float64Array|Float64WasmArray}
- Source:
Compute size factors to remove composition biases from ADT data using the CLRm1 strategy.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | The count matrix, usually after filtering. |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters.
If Properties
|
Returns:
Array of length equal to the number of columns in x
, containing the CLRm1 size factors for all cells.
Note that the factors are not centered and should be passed to centerSizeFactors
before calling normalizeCounts
.
If buffer
is supplied, the function returns buffer
if asTypedArray = false
, or a view on buffer
if asTypedArray = true
.
- Type
- Float64Array | Float64WasmArray
convertToFactor(x, optionsopt) → {object}
- Source:
Convert an arbitrary array into a R-style factor, with integer indices into an array of levels.
This is useful for formatting grouping or blocking vectors for scoreMarkers
, modelGeneVar
, etc.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
Array | TypedArray | Array of values to be converted into a factor. Note that TypedArray views on Wasm-allocated buffers should only be provided if |
||||||||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing:
ids
: an Int32WasmArray or Int32Array of length equal tox
, containing the index intolevels
for each cell.levels
: an array of unique levels, such thatArray.from(ids).map(i => levels[i])
returns the same contents asx
(aside from invalid values). If an inputlevels
is supplied, this is returned directly.
If buffer
was supplied, it is used as the value of the ids
property.
- Type
- object
createBigUint64WasmArray(length) → {BigUint64WasmArray}
Helper function to create a BigUint64WasmArray from the wasmarrays.js package.
Parameters:
Name | Type | Description |
---|---|---|
length |
number | Length of the array. |
Returns:
BigUint64WasmArray on the scran.js Wasm heap.
- Type
- BigUint64WasmArray
createBlock(ncells, optionsopt) → {Int32WasmArray}
Create a blocking factor for a set of contiguous blocks, usually to accompany the output of cbind
on matrices representing different batches.
This can be used as the blocking factor in functions such as modelGeneVar
or scoreMarkers
.
Note that no protection is provided against empty blocks; if this is a possibility, use dropUnusedBlock
on the output of this function.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ncells |
Array | TypedArray | Array of integers specifying the number of cells in each block. Note that TypedArray views on Wasm-allocated buffers should only be provided if |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Array containing the blocking factor. Each value specifies the block of origin for each cell.
If buffer
was supplied, it is used as the return value.
- Type
- Int32WasmArray
createFloat32WasmArray(length) → {Float32WasmArray}
Helper function to create a Float32WasmArray from the wasmarrays.js package.
Parameters:
Name | Type | Description |
---|---|---|
length |
number | Length of the array. |
Returns:
Float32WasmArray on the scran.js Wasm heap.
- Type
- Float32WasmArray
createFloat64WasmArray(length) → {Float64WasmArray}
Helper function to create a Float64WasmArray from the wasmarrays.js package.
Parameters:
Name | Type | Description |
---|---|---|
length |
number | Length of the array. |
Returns:
Float64WasmArray on the scran.js Wasm heap.
- Type
- Float64WasmArray
createInt32WasmArray(length) → {Int32WasmArray}
Helper function to create a Int32WasmArray from the wasmarrays.js package.
Parameters:
Name | Type | Description |
---|---|---|
length |
number | Length of the array. |
Returns:
Int32WasmArray on the scran.js Wasm heap.
- Type
- Int32WasmArray
createNewHdf5File(path) → {H5File}
Create a new HDF5 file.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path to the file. |
Returns:
A new file is created at path
.
A H5File object is returned.
- Type
- H5File
createUint8WasmArray(length) → {Uint8WasmArray}
Helper function to create a Uint8WasmArray from the wasmarrays.js package.
Parameters:
Name | Type | Description |
---|---|---|
length |
number | Length of the array. |
Returns:
Uint8WasmArray on the scran.js Wasm heap.
- Type
- Uint8WasmArray
delayedArithmetic(x, operation, value, optionsopt) → {ScranMatrix}
- Source:
Apply delayed arithmetic to a ScranMatrix object.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | A ScranMatrix object. |
||||||||||||||||||||||
operation |
string | The operation to perform, one of |
||||||||||||||||||||||
value |
number | Array | WasmArray | TypedArray | The other operand in the arithmetic operation.
If a scalar, this is applied element-wise to each entry of |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
A ScranMatrix containing the delayed arithmetic operation on x
.
If inPlace = true
, this is a reference to x
, otherwise it is a new ScranMatrix.
- Type
- ScranMatrix
delayedMath(x, operation, optionsopt) → {ScranMatrix}
- Source:
Apply delayed math to a ScranMatrix object.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | A ScranMatrix object. |
|||||||||||||||||
operation |
string | The operation to perform, one of |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
A ScranMatrix containing the delayed math operation on x
.
If inPlace = true
, this is a reference to x
, otherwise it is a new ScranMatrix.
- Type
- ScranMatrix
dropUnusedLevels(x) → {Array}
- Source:
Reindex the factor indices to remove unused levels.
This is done by adjusting the indices such that every index from [0, N)
is represented at least once, where N
is the number of (used) levels.
Parameters:
Name | Type | Description |
---|---|---|
x |
Int32WasmArray | TypedArray | Array | Array of factor indices such as that produced by |
Returns:
x
is modified in place to remove unused levels.
An array (denoted here as y
) is returned that represents the mapping between the original and modified IDs,
i.e., running x.map(i => y[i])
will recover the input x
.
This is most commonly used to create a new array of levels, i.e., y.map(i => old_levels[i])
will drop the unused levels.
- Type
- Array
emptySuggestAdtQcFiltersResults(numberOfSubsets, numberOfBlocks) → {SuggestAdtQcFiltersResults}
- Source:
Create an empty SuggestAdtQcFiltersResults object, to be filled with custom results.
This is typically used to generate a convenient input into later filterCells
calls.
Parameters:
Name | Type | Description |
---|---|---|
numberOfSubsets |
number | Number of feature subsets. |
numberOfBlocks |
number | Number of blocks in the dataset. |
Returns:
Object with allocated memory to store QC filters, but no actual values.
emptySuggestCrisprQcFiltersResults(numberOfBlocks) → {SuggestCrisprQcFiltersResults}
- Source:
Create an empty SuggestCrisprQcFiltersResults object, to be filled with custom results.
This is typically used to generate a convenient input into later filterCells
calls.
Parameters:
Name | Type | Description |
---|---|---|
numberOfBlocks |
number | Number of blocks in the dataset. |
Returns:
Object with allocated memory to store QC filters, but no actual values.
emptySuggestRnaQcFiltersResults(numberOfSubsets, numberOfBlocks) → {SuggestRnaQcFiltersResults}
- Source:
Create an empty SuggestRnaQcFiltersResults object, to be filled with custom results.
Parameters:
Name | Type | Description |
---|---|---|
numberOfSubsets |
number | Number of feature subsets. |
numberOfBlocks |
number | Number of blocks in the dataset. |
Returns:
Object with allocated memory to store QC filters, but no actual values.
existsFile(path) → {boolean}
Check if a file exists on the native file system (Node.js) or the virtual file system (browser).
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path to the file on the relevant file system. |
Returns:
Whether the file exists.
- Type
- boolean
extractHdf5MatrixDetails(file, name) → {object}
Extract the format and dimensions of a HDF5 matrix.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | Path to the HDF5 file. For browsers, the file should have been saved to the virtual filesystem. |
name |
string | Name of the dataset inside the file. This can be a HDF5 Dataset for dense matrices or a HDF5 Group for sparse matrices. For the latter, both H5AD and 10X-style sparse formats are supported. |
Returns:
An object containing:
rows
, the number of rows in the matrix.columns
, the number of columns.format
, whether the matrix is dense, CSR or CSC.integer
, whether the matrix data is stored as integers or doubles.
- Type
- object
extractHdf5ObjectNames(path, optionsopt) → {object}
Extract object names from a HDF5 file.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
path |
string | Path to a HDF5 file.
For web applications, this should be saved to the virtual filesystem with |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Nested object where the keys are the names of the HDF5 objects and values are their types.
HDF5 groups are represented by nested Javascript objects in the values;
these nested objects are empty if recursive = false
.
HDF5 datasets are represented by strings specifying the data type - i.e., "integer"
, "float"
, "string"
or "other"
.
- Type
- object
extractMatrixMarketDimensions(buffer, optionsopt) → {object}
Extract dimensions and other details from a MatrixMarket file.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
buffer |
Uint8WasmArray | Array | TypedArray | string | Byte array containing the contents of a Matrix Market file with non-negative counts. This can be raw text or Gzip-compressed. Alternatively, this can be a string containing a file path to a MatrixMarket file.
On browsers, this should be a path in the virtual filesystem, typically created with |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
An object containing the number of rows
, columns
and lines
in the matrix.
- Type
- object
filterCells(x, filters) → {ScranMatrix}
- Source:
Filter out low-quality cells.
Parameters:
Name | Type | Description |
---|---|---|
x |
ScranMatrix | The count matrix. |
filters |
Uint8WasmArray | Array | TypedArray | An array of length equal to the number of columns in |
Returns:
A matrix of the same type as x
, filtered by column to only retain cells in filters
.
- Type
- ScranMatrix
findNearestNeighbors(x, k, optionsopt) → {FindNearestNeighborsResults}
- Source:
Find the nearest neighbors for each cell.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
NeighborSearchIndex | The neighbor search index built by |
||||||||||||
k |
number | Number of neighbors to find. |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the search results.
free(xnullable)
Try to free a scran.js object's memory (typically involving some memory allocated on the Wasm heap) by calling its free
method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
x |
object |
<nullable> |
Instance of a scran.js or wasmarrays.js class to be freed.
May also be |
Returns:
The output of x.free()
- unless x
is undefined or null
, in which case nothing is performed.
guessFeatures(features, optionsopt) → {object}
- Source:
Guess the identity of the features from their names.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
features |
Array | Array of strings containing feature identifiers, typically Ensembl IDs or gene symbols.
Elements may also be |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
An object containing:
species
, the inferred species as a string. This can be either"human"
or"mouse"
, or an NCBI taxonomy ID (one of 6239, 10116, 9541, 7227, 7955, 9598). IfforceTaxonomy = true
, human and mouse are replaced with 9606 and 10090, respectively.type
: the feature identifier type. This can either be"ensembl"
or"symbol"
.confidence
: the percentage of entries inx
that are consistent with the inferred identity.
- Type
- object
heapSize() → {number}
Returns:
The current size of the Wasm heap, typically used for diagnostic reporting.
- Type
- number
hypergeometricTest(markersInSet, numberOfMarkers, geneSetSize, numberOfGenes, optionsopt) → {Float64Array|Float64WasmArray}
- Source:
Perform a hypergeometric test, typically for over-enrichment of markers across gene sets. This can be computed for multiple gene sets by providing arrays as some or all of the arguments. If multiple arrays are supplied, they must be of the same length.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
markersInSet |
number | Array | TypedArray | WasmArray | Number of detected markers that are also in the gene set. |
|||||||||||||||||||||||||||
numberOfMarkers |
number | Array | TypedArray | WasmArray | Total number of detected markers. |
|||||||||||||||||||||||||||
geneSetSize |
number | Array | TypedArray | WasmArray | Size of the gene set. |
|||||||||||||||||||||||||||
numberOfGenes |
number | Array | TypedArray | WasmArray | Total number of genes. |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
An array of length equal to that of the supplied arrays (or 1, if no arrays are supplied).
The i-th entry contains the p-value for enrichment computed using the i-th entry of each supplied array.
If buffer
is supplied, the function returns buffer
if asTypedArray = false
, or a view on buffer
if asTypedArray = true
.
- Type
- Float64Array | Float64WasmArray
initialize(optionsopt) → {boolean}
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
The Wasm bindings are initialized and true
is returned.
If the bindings were already initialized (e.g., by a previous call), nothing is done and false
is returned.
- Type
- boolean
initializeDenseMatrixFromDenseArray(numberOfRows, numberOfColumns, values, optionsopt) → {ScranMatrix}
Initialize a dense matrix from a dense array.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
numberOfRows |
number | Number of rows in the matrix. |
|||||||||||||||||
numberOfColumns |
number | Number of columns in the matrix. |
|||||||||||||||||
values |
WasmArray | Array | TypedArray | Values of all elements in the matrix.
This is generally expected to contain non-negative integers; otherwise, users should set |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Matrix containing dense data.
- Type
- ScranMatrix
initializeSparseMatrixFromDenseArray(numberOfRows, numberOfColumns, values, columnMajor, optionsopt) → {ScranMatrix}
Initialize a sparse matrix from a dense array in column-major format.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
numberOfRows |
number | Number of rows in the matrix. |
||||||||||||||||||||||
numberOfColumns |
number | Number of columns in the matrix. |
||||||||||||||||||||||
values |
WasmArray | Array | TypedArray | Values of all elements in the matrix.
This is generally expected to contain non-negative integers; otherwise, users should set |
||||||||||||||||||||||
columnMajor |
boolean | Whether |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Matrix containing sparse data.
- Type
- ScranMatrix
initializeSparseMatrixFromHdf5(file, name, optionsopt) → {ScranMatrix}
- Source:
Initialize a (potentially layered) sparse matrix from a HDF5 file,
either as a 2-dimensional dataset (initializeSparseMatrixFromHdf5Dataset
)
or as a group containing compressed sparse vectors (initializeSparseMatrixFromHdf5Group
).
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file |
string | Path to the HDF5 file. For browsers, the file should have been saved to the virtual filesystem. |
|||||||||||||||||||||||||||
name |
string | Name of the matrix inside the file.
This can be a HDF5 Dataset for dense matrices or a HDF5 Group for sparse matrices.
For the latter, we expect the |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Matrix containing sparse data.
- Type
- ScranMatrix
initializeSparseMatrixFromHdf5Dataset(file, name, optionsopt) → {ScranMatrix}
Initialize a (potentially layered) sparse matrix from a 2-dimensional dataset in a HDF5 file.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file |
string | Path to the HDF5 file. For browsers, the file should have been saved to the virtual filesystem. |
||||||||||||||||||||||||||||||||
name |
string | Name of the 2-dimensional Dataset containing the matrix. |
||||||||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Matrix containing sparse data.
- Type
- ScranMatrix
initializeSparseMatrixFromHdf5Group(file, name, numberOfRows, numberOfColumns, byRow, optionsopt) → {ScranMatrix}
Initialize a (potentially layered) sparse matrix from a group in a HDF5 file.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file |
string | Path to the HDF5 file. For browsers, the file should have been saved to the virtual filesystem. |
|||||||||||||||||||||||||||
name |
string | Name of the HDF5 group containing the matrix.
For the latter, we expect the |
|||||||||||||||||||||||||||
numberOfRows |
number | Number of rows in the sparse matrix. |
|||||||||||||||||||||||||||
numberOfColumns |
number | Number of columns in the sparse matrix. |
|||||||||||||||||||||||||||
byRow |
boolean | Whether the matrix is in the compressed sparse row format. |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Matrix containing sparse data.
- Type
- ScranMatrix
initializeSparseMatrixFromMatrixMarket(buffer, optionsopt) → {ScranMatrix}
Initialize a sparse matrix from a buffer containing a MatrixMarket file.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
buffer |
Uint8WasmArray | Array | TypedArray | string | Byte array containing the contents of a Matrix Market file with non-negative counts. This can be raw text or Gzip-compressed. Alternatively, this can be a string containing a file path to a MatrixMarket file.
On browsers, this should be a path in the virtual filesystem, typically created with |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Matrix containing sparse data.
- Type
- ScranMatrix
initializeSparseMatrixFromRds(x, optionsopt) → {ScranMatrix}
- Source:
Initialize a sparse matrix from an R object loaded from an RDS file.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
RdsObject | Handle to an object inside an RDS file.
This should be an integer/numeric matrix, |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Matrix containing sparse data.
- Type
- ScranMatrix
initializeSparseMatrixFromSparseArrays(numberOfRows, numberOfColumns, values, indices, pointers, optionsopt) → {ScranMatrix}
Initialize a sparse matrix from the usual compressed sparse arrays.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
numberOfRows |
number | Number of rows in the matrix. |
||||||||||||||||||||||
numberOfColumns |
number | Number of columns in the matrix. |
||||||||||||||||||||||
values |
WasmArray | Values of the non-zero elements.
This is generally expected to contain non-negative integers; otherwise, users should set |
||||||||||||||||||||||
indices |
WasmArray | Row indices of the non-zero elements.
This should be of the same length as |
||||||||||||||||||||||
pointers |
WasmArray | Pointers specifying the start of each column in |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Matrix containing sparse data.
- Type
- ScranMatrix
initializeTsne(x, optionsopt) → {TsneStatus}
- Source:
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
BuildNeighborSearchIndexResults | FindNearestNeighborsResults | A pre-built neighbor search index from Alternatively, a pre-computed set of neighbor search results from {linkcode findNearestNeighbors}.
The number of neighbors should be equal to |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the initial status of the t-SNE algorithm.
- Type
- TsneStatus
initializeUmap(x, optionsopt) → {UmapStatus}
- Source:
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
BuildNeighborSearchIndexResults | FindNearestNeighborsResults |
Alternatively, a pre-computed set of neighbor search results for all cells (see |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the initial status of the UMAP algorithm.
- Type
- UmapStatus
integrateLabelCells(x, integrated, assigned, optionsopt) → {IntegrateLabelCellsResults}
- Source:
Integrate cell labels across multiple reference datasets.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | Float64WasmArray | The count matrix, or log-normalized matrix, containing features in the rows and cells in the columns. If a Float64WasmArray is supplied, it is assumed to contain a column-major dense matrix. |
|||||||||||||||||||||||||||
integrated |
IntegratedLabelCellsReferences | An integrated set of reference datasets, typically generated by |
|||||||||||||||||||||||||||
assigned |
Array | An array of length equal to the number of references in |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Integrated labelling results for each cell in x
.
integrateLabelCellsReferences(testFeatures, loadedReferences, referenceFeatures, trainedReferences, optionsopt) → {IntegratedLabelCellsReference}
- Source:
Prepare a classifier that integrates multiple reference datasets. This allows users to choose the best label for a test cell based on its classifications in multiple references.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
testFeatures |
Array | An array of feature identifiers (usually strings) of length equal to the number of rows in the test matrix.
Each entry should contain a single identifier for the corresponding row of the test matrix.
Any |
||||||||||||
loadedReferences |
Array | Array of LoadedLabelCellsReference objects, typically created with |
||||||||||||
referenceFeatures |
Array | Array of length equal to |
||||||||||||
trainedReferences |
Array | Array of TrainedLabelCellsReference objects, typically generated by calling |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the integrated references.
- Type
- IntegratedLabelCellsReference
labelCells(x, reference, optionsopt) → {LabelCellsResults}
- Source:
Label cells based on similarity in expression to a reference dataset. This uses the SingleR algorithm for cell type annotation.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | Float64WasmArray | The count matrix, or log-normalized matrix, containing features in the rows and cells in the columns. If a Float64WasmArray is supplied, it is assumed to contain a column-major dense matrix. |
|||||||||||||||||||||||||||
reference |
BuildLabelledReferenceResults | A built reference dataset, typically generated by |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Labelling results for each cell in x
.
- Type
- LabelCellsResults
loadHdf5Dataset(path, name) → {object}
Load a dataset from a HDF5 file.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path to a HDF5 file.
For web applications, this should be saved to the virtual filesystem with |
name |
string | Name of a dataset inside the HDF5 file. |
Returns:
An object containing:
dimensions
, an array containing the dimensions of the dataset.contents
, a Int32Array, Float64Array or array of strings, depending on the type of the dataset.
- Type
- object
loadLabelCellsReferenceFromBuffers(ranks, markers, labels) → {LoadedLabelCellsReference}
- Source:
Load a reference dataset for annotation in {@linkecode labelCells}. The reference should be represented by several files, the contents of which are described in the singlepp_loaders documentation.
Parameters:
Name | Type | Description |
---|---|---|
ranks |
Uint8Array | Uint8WasmArray | Buffer containing the Gzipped CSV file containing a matrix of ranks. Each line corresponds to a sample and contains a comma-separated vector of ranks across all features. All lines should contain the same number of entries. This is effectively a row-major matrix where rows are samples and columns are features. (Advanced users may note that this is transposed in C++.) |
markers |
Uint8Array | Uint8WasmArray | Buffer containing the Gzipped GMT file containing the markers for each pairwise comparison between labels.
For |
labels |
Uint8Array | Uint8WasmArray | Buffer containing the Gzipped text file containing the label for each sample.
Each line should contain an integer representing a particular label, from |
Returns:
Object containing the reference dataset.
maximumThreads() → {number}
Maximum number of threads available for computation.
This depends on the value specified during module initialization in initialize
.
Returns:
Maximum number of available threads.
- Type
- number
mnnCorrect(x, block, optionsopt) → {Float64Array|Float64WasmArray}
- Source:
Perform mutual nearest neighbor (MNN) correction on a low-dimensional representation to remo This is used to remove batch effects prior to downstream analyses like clustering, check out the mnncorrect for details.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
RunPcaResults | TypedArray | Array | Float64WasmArray | A matrix of low-dimensional results where rows are dimensions and columns are cells.
If this is a RunPcaResults object, the PCs are automatically extracted.
Otherwise, the matrix should be provided as an array in column-major form, with specification of |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
block |
Int32WasmArray | Array | TypedArray | Array containing the block assignment for each cell.
This should have length equal to the number of cells and contain all values from 0 to |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Further optional parameters. Properties
|
Returns:
Array of length equal to x
, containing the batch-corrected low-dimensional coordinates for all cells.
Corrected values are organized using the column-major layout, where rows are dimensions and columns are cells.
If buffer
is supplied, the function returns buffer
if asTypedArray = false
, or a view on buffer
if asTypedArray = true
.
- Type
- Float64Array | Float64WasmArray
modelGeneVariances(x, optionsopt) → {ModelGeneVariancesResults}
- Source:
Model the mean-variance trend across genes.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | The normalized log-expression matrix. |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the variance modelling results.
normalizeCounts(x, optionsopt) → {ScranMatrix}
- Source:
Compute log-transformed normalized expression values.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | The count matrix, usually after filtering. |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
A matrix of the same type as x
containing normalized expression values.
If log = true
, the values in the matrix are log-transformed.
- Type
- ScranMatrix
perCellAdtQcMetrics(x, subsetsnullable, optionsopt) → {PerCellAdtQcMetricsResults}
- Source:
Compute the per-cell QC metrics from an ADT count matrix.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | The ADT count matrix. |
||||||||||||
subsets |
Array |
<nullable> |
Array of arrays of boolean values specifying the feature subsets.
Each internal array corresponds to a subset and should be of length equal to the number of rows.
Each entry of each internal array specifies whether the corresponding row of Alternatively, each internal array may be any TypedArray or TypedWasmArray. Each array should be of length equal to the number of rows and values are interpreted as booleans. Alternatively |
|||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the ADT-based QC metrics.
perCellCrisprQcMetrics(x, optionsopt) → {PerCellCrisprQcMetricsResults}
- Source:
Compute per-cell QC metrics from the CRISPR guide count matrix.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | The count matrix for CRISPR guides. |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the QC metrics.
perCellRnaQcMetrics(x, subsetsnullable, optionsopt) → {PerCellRnaQcMetricsResults}
- Source:
Compute per-cell QC metrics from the RNA count matrix.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | The RNA count matrix for genes. |
||||||||||||
subsets |
Array |
<nullable> |
Array of arrays of boolean values specifying the feature subsets.
Each internal array corresponds to a subset and should be of length equal to the number of rows.
Each entry of each internal array specifies whether the corresponding row of Alternatively, each internal array may be any TypedArray or TypedWasmArray. Each array should be of length equal to the number of rows and values are interpreted as booleans. Alternatively |
|||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the QC metrics.
perplexityToNeighbors(perplexity) → {number}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
perplexity |
number | Perplexity to use in the t-SNE algorithm. |
Returns:
Appropriate number of neighbors to use in the nearest neighbor search.
- Type
- number
possibleCopy(x, copy) → {TypedArray|WasmArray}
Possibly copy an array out of the Wasm heap, avoiding potential invalidation at the cost of some efficiency.
Parameters:
Name | Type | Description |
---|---|---|
x |
TypedArray | Array of data, possibly on the scran.js Wasm heap. |
copy |
string | boolean | Copying mode to use. |
Returns:
The return value depends on the value of copy
:
- If
copy = true
, a TypedArray copy ofx
is created withx.slice()
and returned. This is a good default to avoid invalidation of TypedArray views on the heap upon reallocation, by creating a Javascript-owned copy for downstream use. - If
copy = false
,x
is returned directly. This avoids making any copy but runs the risk of invalidation when the Wasm heap is resized; it should only be used when no further Wasm allocations are performed within the lifetime ofx
. - If
copy = "view"
, a WasmArray view is created fromx
and returned. This avoids any copy and is robust to invalidation but requires an extraWasmArray.array()
call to create a TypedArray.
- Type
- TypedArray | WasmArray
rbind(inputs) → {ScranMatrix}
Combine matrices by row, where all matrices contain data for the same cells, in the same order.
Parameters:
Name | Type | Description |
---|---|---|
inputs |
Array | Array of one or more ScranMatrix objects. All of these should have the same number and order of cells. |
Returns:
A ScranMatrix containing the matrices after combining them by row.
- Type
- ScranMatrix
readFile(path) → {Uint8Array}
Read a byte array from a path on the native file system (Node.js) or the virtual file system (browser).
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path to a file on the relevant file system. |
Returns:
Binary contents of the file.
- Type
- Uint8Array
readRds(buffer) → {RdsDetails}
Read the contents of an RDS file.
Parameters:
Name | Type | Description |
---|---|---|
buffer |
Uint8WasmArray | Array | TypedArray | string | Byte array containing the contents of an RDS file. This can be raw text or Gzip-compressed. Alternatively, this can be a string containing a file path to a MatrixMarket file. |
Returns:
Details of the file.
- Type
- RdsDetails
realizeFile(file, optionsopt) → {Object}
- Source:
Realize a file so that it can be read by scran.js functions across both Node.js and browsers.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file |
string | Uint8Array | In general, a Uint8Array buffer containing the file contents. For Node.js, this may also be a string containing a path to a file. |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object with the following properties:
path
: a string containing the path to the file on the local filesystem (Node.js) or virtual file system (browsers). For Node.js,file
is returned directly if it is already a path; otherwise, a new file will be created in the system's default temporary directory.flush
: a function to be called to remove any temporary file created by this function. For Node.js, this will be a no-op iffile
is already a path.
- Type
- Object
remapGeneSets(targetGenes, referenceGenes, referenceGeneSets) → {object}
- Source:
Remap gene sets from a "reference" gene namespace to a "target" namespace. This involves defining a common namespace consisting of gene names that are shared in both namespaces, and then mapping the gene sets to the common namespace.
The target_indices
property returned by this function can be used to generate the indices of markers
in testGeneSetEnrichment
.
Given a function that determines whether a gene in the target namespace is a marker, we can populate markers
as below:
let markers = [];
target_indices.forEach((x, i) => {
if (is_marker(x)) { // in other words, 'targetGenes[x]' is a marker.
markers.push(i); // we want to store 'i' as this is the index into the common namespace.
}
});
Parameters:
Name | Type | Description |
---|---|---|
targetGenes |
Array | Array of strings containing the gene names in the target namespace.
Any |
referenceGenes |
Array | Array of strings containing the gene names in the reference namespace.
Any |
referenceGeneSets |
Array | Array of gene sets.
Each entry corresponds to a set and is an Array/TypedArray containing integer indices of genes belonging to that set.
Indices are relative to |
Returns:
Object containing:
target_indices
: an Int32Array of length equal to the number of common genes betweentargetGenes
andreferenceGenes
. Each entry is an index intotargetGenes
to identify the gene in the common namespace, i.e., the common namespace can be defined asArray.from(target_indices).map(i => targetGenes[i])
.reference_indices
: an Int32Array of length equal to the size of the common namespace. Each entry is an index intoreferenceGenes
to identify the gene in the common namespace. i.e., the common namespace can be defined asArray.from(reference_indices).map(i => referenceGenes[i])
(which is guaranteed to be the same as the corresponding operation ontarget_indices
).sets
: an Array of Int32Arrays containing the membership of each gene set. Each integer is an index into the common namespace defined bytarget_indices
andreference_indices
.
- Type
- object
removeFile(path)
Remove a file from the native file system (Node.js) or the virtual file system (browser).
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path to the file on the relevant file system. |
Returns:
Deletes the specified file from the relevant file system.
If path
does not exist, this function is a no-op.
resetLevels(x, newLevels, optionsopt)
- Source:
Change the levels of a factor, updating the indices appropriately.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
object | Factor object produced by |
|||||||||||||||||
newLevels |
Array | Array of new levels.
This should be a superset of |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
x
is modified by reference such that x.levels
is set to newLevels
.
x.ids
is updated so that the indices now refer to the appropriate value in newLevels
.
runPca(x, optionsopt) → {RunPcaResults}
Run a principal components analysis on the log-expression matrix. This is usually done on a subset of features, and possibly with some kind of blocking on a per-cell batch factor.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | The log-normalized expression matrix. |
|||||||||||||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the computed PCs.
- Type
- RunPcaResults
runTsne(x, optionsopt) → {object}
- Source:
Run the t-SNE algorithm to the specified number of iterations.
This is a wrapper around initializeTsne
and run
.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
BuildNeighborSearchIndexResults | FindNearestNeighborsResults | A pre-built neighbor search index from Alternatively, a pre-computed set of neighbor search results from {linkcode findNearestNeighbors}.
The number of neighbors should be equal to |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing coordinates of the t-SNE embedding, see TsneStatus.extractCoordinates
for more details.
- Type
- object
runUmap(x, optionsopt) → {object}
- Source:
Run the UMAP algorithm.
This is a wrapper around initializeUmap
and run
.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
BuildNeighborSearchIndexResults | FindNearestNeighborsResults | A pre-built neighbor search index from Alternatively, a pre-computed set of neighbor search results from {linkcode findNearestNeighbors}.
The number of neighbors should be equal to |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing coordinates of the UMAP embedding, see UmapStatus.extractCoordinates
for more details.
- Type
- object
scaleByNeighbors(embeddings, numberOfCells, optionsopt) → {Float64Array|Float64WasmArray}
- Source:
Scale embeddings based on the variation between neighboring cells. This aims to equalize the noise across embeddings for the same population of cells across different data modalities, allowing them to be combined into a single embedding for coordinated downstream analyses. Check out the mumosa documentation for more details.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
embeddings |
Array | Array of Float64WasmArrays containing column-major matrices where rows are dimensions and columns are cells. All entries of this array should contain data for the same number and ordering of cells. |
||||||||||||||||||||||||||||||||||||||||||
numberOfCells |
number | Number of cells in all embeddings. |
||||||||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Array containing the combined embeddings in column-major format, i.e., dimensions in rows and cells in columns.
If buffer
is supplied, the function returns buffer
if asTypedArray = false
, or a view on buffer
if asTypedArray = true
.
- Type
- Float64Array | Float64WasmArray
scoreGsdecon(x, features, optionsopt) → {object}
- Source:
Compute per-cell scores for the activity of a feature set using the gsdecon method.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | Log-normalized expression matrix. |
|||||||||||||||||||||||||||
features |
Uint8Array | Uint8WasmArray | TypedArray | Array | An array of length equal to the number of rows in |
|||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing:
weights
, a Float64Array containing per-gene weights for each feature in the set.scores
, a Float64Array containing the per-cell scores for each column ofx
.
- Type
- object
scoreMarkers(x, groups, optionsopt) → {ScoreMarkersResults}
- Source:
Score genes as potential markers for each group of cells.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | Log-normalized expression matrix. |
|||||||||||||||||||||||||||||||||||||
groups |
Int32WasmArray | Array | TypedArray | Array containing the group assignment for each cell.
This should have length equal to the number of cells and contain all values from 0 to |
|||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the marker scoring results.
- Type
- ScoreMarkersResults
splitRows(matrix, split, optionsopt) → {object|MultiMatrix}
Split a ScranMatrix by row.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
matrix |
ScranMatrix | A ScranMatrix object. |
|||||||||||||||||
split |
object | Object specifying how rows should be split. Each value should be an Array/TypedArray of 0-based row indices. |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object with the same keys as split
where each value is a ScranMatrix for the corresponding subset of rows.
Alternatively, this is wrapped in a MultiMatrix if createMultiMatrix = true
.
- Type
- object | MultiMatrix
subsetColumns(x, indices, optionsopt) → {ScranMatrix}
Slice a ScranMatrix by its columns.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | The matrix of interest. |
||||||||||||
indices |
Array | Column indices to extract.
Al indices must be a non-negative integer less than |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
A new ScranMatrix containing the subset of columns from mat
specified by indices
.
If inPlace = true
, this is a reference to x
, otherwise it is a new ScranMatrix.
- Type
- ScranMatrix
subsetFactor(x, subset, optionsopt) → {object}
- Source:
Subset a factor, possibly also dropping its unused levels.
This is typically based on the same filtering vector as filterCells
.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
object | An object representing a factor, containing the following properties:
This is typically produced by |
||||||||||||||||||||||
subset |
Array | TypedArray | WasmArray | Array specifying the subset to retain or filter out, depending on If If If Note that TypedArray views on Wasm-allocated buffers should only be provided if |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
An object like x
, containing:
ids
: An Int32Array or Int32WasmArray of integer indices, subsetted from those inx.ids
.levels
: Array of levels that can be indexed by entries of the outputids
. Ifdrop = true
, this may be a subset ofx.levels
where every entry is represented at least once in the outputids
.
If buffer
is supplied, the returned ids
will be set to buffer
.
- Type
- object
subsetRows(x, indices, optionsopt) → {ScranMatrix}
Slice a ScranMatrix by its rows.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | The matrix of interest. |
||||||||||||
indices |
Array | Row indices to extract.
All indices must be non-negative integers less than |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
A ScranMatrix containing the subset of rows from mat
specified by indices
.
If inPlace = true
, this is a reference to x
, otherwise it is a new ScranMatrix.
- Type
- ScranMatrix
suggestAdtQcFilters(metrics, optionsopt) → {SuggestAdtQcFiltersResults}
- Source:
Define filters based on the per-cell QC metrics from the ADT count matrix.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
metrics |
PerCellAdtQcMetricsResults | Per-cell QC metrics, usually computed by |
||||||||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the filtering results.
suggestCrisprQcFilters(metrics, optionsopt) → {SuggestCrisprQcFiltersResults}
- Source:
Define filters based on the per-cell QC metrics for CRISPR guide counts.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
metrics |
PerCellCrisprQcMetricsResults | Per-cell QC metrics, usually computed by |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the filtering results.
suggestRnaQcFilters(metrics, optionsopt) → {SuggestRnaQcFiltersResults}
- Source:
Define filters based on the per-cell QC metrics computed from an RNA count matrix.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
metrics |
PerCellRnaQcMetricsResults | Per-cell QC metrics, usually computed by |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the filtering results.
terminate()
Returns:
All worker threads are terminated and the module is deleted from the cache. This is useful for releasing thread resources at the end of the analysis when scran.js functions are no longer required. Of course, workers will automatically shut down on program exit anyway, so calling this function is not essential.
testGeneSetEnrichment(markers, geneSets, totalGenes, optionsopt) → {object}
- Source:
Test for gene set enrichment among markers using the hypergeometricTest
function.
We assume that all gene names have already been converted into integer indices before running this function;
i.e., genes are represented as indices into a "common namespace" consisting of an array of unique gene names.
See remapGeneSets
for more details.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
markers |
Array | TypedArray | Array of marker identities.
Each entry of the array is a unique integer index identifying a marker gene in the common namespace, where each index lies in In other words, given a common namespace array |
||||||||||||
geneSets |
Array | Array containing the gene sets. Each entry corresponds to a single gene set and may be an Array or TypedArray. Each array should contain unique indices for the genes belonging to the set. In other words, given a common namespace array |
||||||||||||
totalGenes |
number | Total number of genes in the common namespace. |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing:
count
: Int32Array containing the number of markers present in each set.size
: Int32Array containing the size of each set.pvalue
: Float64Array containing the p-value for enrichment in each set.
- Type
- object
trainLabelCellsReference(testFeatures, loadedReference, referenceFeatures, optionsopt) → {TrainedLabelCellsReference}
- Source:
Train a reference dataset for annotation in labelCells
.
The build process involves harmonizing the identities of the features available in the test dataset compared to the reference.
Specifically, a feature must be present in both datasets in order to be retained.
Of those features in the intersection, only the top
markers from each pairwise comparison are ultimately used for classification.
Needless to say, testFeatures
should match up to the rows of the ScranMatrix that is actually used for annotation in labelCells
.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
testFeatures |
Array | An array of feature identifiers (usually strings) of length equal to the number of rows in the test matrix.
Each entry should contain the identifier for the corresponding row of the test matrix.
Any |
|||||||||||||||||
loadedReference |
LoadedLabelCellsReference | A reference dataset, typically loaded with |
|||||||||||||||||
referenceFeatures |
Array | An array of feature identifiers (usually strings) of length equal to the number of features in |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
Object containing the built reference dataset.
transpose(x, optionsopt) → {ScranMatrix}
- Source:
Transpose a ScranMatrix object.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | A ScranMatrix object. |
||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
A ScranMatrix containing the transposition of x
.
If inPlace = true
, this is a reference to x
, otherwise it is a new ScranMatrix.
- Type
- ScranMatrix
truncateNearestNeighbors(x, k) → {FindNearestNeighborsResults}
- Source:
Truncate existing neighbor search results to the k
nearest neighbors for each cell.
This is exactly or approximately equal to calling findNearestNeighbors
with the new k
,
depending on whether approximate = false
or approximate = true
was used to build the search index, respectively.
Parameters:
Name | Type | Description |
---|---|---|
x |
FindNearestNeighborsResults | Existing neighbor search results from |
k |
number | Number of neighbors to retain. If this is larger than the number of available neighbors, all neighbors are retained. |
Returns:
Object containing the truncated search results.
wasmArraySpace() → {number}
Returns:
Integer containing the wasmarrays.js identifier for scran.js's memory space.
This can be used with createWasmArray()
and related functions from wasmarrays.js.
- Type
- number
writeFile(path, buffer)
Write a byte array to a path on the native file system (Node.js) or to the virtual file system (browser).
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path to the output file on the relevant file system. |
buffer |
Uint8Array | Buffer to write to file. |
Returns:
buffer
is written to the binary file path
.
writeSparseMatrixToHdf5(x, path, name, optionsopt)
- Source:
Write a sparse ScranMatrix into HDF5 file, in the form of its compressed sparse components.
This can be considered the reverse operation of initializeSparseMatrixFromHDF5
.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
ScranMatrix | An input sparse matrix. |
|||||||||||||||||
path |
string | Path to the HDF5 file. A new file will be created if no file is present. |
|||||||||||||||||
name |
string | Name of the group inside the HDF5 file in which to save |
|||||||||||||||||
options |
object |
<optional> |
{}
|
Optional parameters. Properties
|
Returns:
x
is written to path
at name
.