Matrix

Matrix

An interface to the wobbegong representation of a matrix. This is either a row-major dense matrix or a compressed sparse row matrix.

Constructor

new Matrix(summary, path, fetch_range)

Source:
Parameters:
Name Type Description
summary object

A summary of the matrix contents, according to the wobbegong specifications.

path string

Path to the matrix directory. This may be a relative or absolute path, depending on how the files are hosted.

fetch_range function

A function that accepts file (a path to a file inside path), start and end. It should retrieve bytes from file in the interval [start, end) and return a Uint8Array containing those bytes. It may also return a promise that resolves to such a Uint8Array.

Classes

Matrix

Methods

numberOfColumns() → {number}

Source:
Returns:

Number of columns.

Type
number

numberOfRows() → {number}

Source:
Returns:

Number of rows.

Type
number

(async) row(i, optionsopt) → {object|Array|Int32Array|Float64Array}

Source:
Parameters:
Name Type Attributes Default Description
i number

Row index.

options object <optional>
{}

Further options.

Properties
Name Type Attributes Default Description
missing string <optional>
"null"

How to handle missing values for integer arrays, see the corresponding option in decodeIntegers.

asDense string <optional>
false

Whether to return the row's contents as a dense array with explicit zeros. Only relevant if sparse returns true.

Returns:

If asDense = true or sparse is false, an array of length equal to the number of columns is returned, containing the contents of row i in dense form.

Otherwise, an object is returned containing value, an array of the values of the structural non-zero elements of row i; and index, a Int32Array of column indices for each entry of value. All indices are guaranteed to be sorted and unique.

Type
object | Array | Int32Array | Float64Array

sparse() → {boolean}

Source:
Returns:

Whether this matrix is sparse.

Type
boolean

statistic(name, optionsopt) → {object|Array|Int32Array|Float64Array}

Description:
  • Retrieve a statistic by name.

Source:
Parameters:
Name Type Attributes Default Description
name string

Name of the statistic, as described in statisticNames.

options object <optional>
{}

Further options.

Properties
Name Type Attributes Default Description
type boolean <optional>
false

Whether to include the type of the statistic.

missing string <optional>
"null"

How to handle missing values for integer arrays, see the corresponding option in decodeIntegers.

Returns:

If type = false, an array containing the statistic i. If type = true, this is instead an object containing type, a string with the statistic's type; and value, an array with the statistic itself.

Type
object | Array | Int32Array | Float64Array

statisticNames(optionsopt) → {Array}

Description:
  • List available statistics. Each matrix is guaranteed to have at least:

    • row_sum, the summed value within each row.
    • column_sum, the summed value within each column.
    • row_nonzero, the number of non-zero entries within each row.
    • column_nonzero, the number of non-zero entries within each column.
Source:
Parameters:
Name Type Attributes Default Description
options object <optional>
{}

Further options.

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

Whether to include the types of the statistics.

Returns:

Names of the available statistics. If types = true, each entry is an object specifying the name and type of the column; otherwise, each entry is a string.

Type
Array

type() → {string}

Source:
Returns:

Type of the matrix, typically either boolean, integer or double.

Type
string