Class: DecompositionModel

DecompositionModel(data, md_headers, metadata) → {DecompositionModel}

DecompositionModel

Models all the ordination data to be plotted.

Constructor

new DecompositionModel(data, md_headers, metadata) → {DecompositionModel}

Parameters:
Name Type Description
data object

An object with the following attributes (keys):

  • name A string containing the abbreviated name of the ordination method.
  • ids An array of strings where each string is a sample identifier
  • coords A 2D Array of floats where each row contains the coordinates of a sample. The rows are in ids order.
  • names A 1D Array of strings where each element is the name of one of the dimensions in the model.
  • pct_var An Array of floats where each position contains the percentage explained by that axis
  • low A 1D Array of floats where each row contains the coordinates of a sample. The rows are in ids order.
  • high A 1D Array of floats where each row contains the coordinates of a sample. The rows are in ids order.
md_headers Array.<float>

An Array of string where each string is a metadata column header

metadata Array.<string>

A 2D Array of strings where each row contains the metadata values for a given sample. The rows are in ids order. The columns are in md_headers order.

Source:
Throws:

In any of the following cases:

  • The number of coordinates does not match the number of samples.
  • If there's a coordinate in coords that doesn't have the same length as the rest.
  • The number of samples is different than the rows provided as metadata.
  • Not all metadata rows have the same number of fields.
Type
Error
Returns:
Type
DecompositionModel

Members

abbreviatedName :string

Abbreviated name of the ordination method used to create the data.

Type:
  • string
Source:

axesNames :Array.<string>

Names of the axes in the ordination

Type:
  • Array.<string>
Source:

dimensionRanges :Object

Minimum and maximum values for each axis in the ordination. More concretely this object has a min and a max attributes, each with a list of floating point arrays that describe the minimum and maximum for each axis.

Type:
  • Object
Source:

dimensions :integer

Number of dimensions in this decomposition model

Type:
  • integer
Source:

edges :Array.<Array>

Array of pairs of Plottable objects.

Type:
  • Array.<Array>
Source:

ids :Array.<string>

List of sample name identifiers.

Type:
  • Array.<string>
Source:

length :integer

Number of plottables in this decomposition model

Type:
  • integer
Source:

md_headers :Array.<string>

Column names for the metadata in the samples.

Type:
  • Array.<string>
Source:

percExpl :Array.<float>

Percentage explained by each of the axes in the ordination.

Type:
  • Array.<float>
Source:

type :string

Model's type of the data, can be either 'scatter' or 'arrow'

Type:
  • string
Source:

Methods

apply(func) → {Array.<Object>}

Executes the provided func passing all the plottables as parameters.

Parameters:
Name Type Description
func function

The function to call for each plottable. It should accept a single parameter which will be the plottable.

Source:
Returns:

An array with the results of executing func over all plottables.

Type
Array.<Object>

getPlottableByID(id) → {Plottable}

Retrieve the plottable object with the given id.

Parameters:
Name Type Description
id string

A string with the plottable.

Source:
Returns:

The plottable object for the given id.

Type
Plottable

getPlottableByIDs(idArray) → {Array.<Plottable>}

Retrieve all the plottable objects with the given ids.

Parameters:
Name Type Description
idArray Array.<integer>

an Array of strings where each string is a plottable id.

Source:
Returns:

An Array of plottable objects for the given ids.

Type
Array.<Plottable>

getPlottablesByMetadataCategoryValue(category, value) → {Array.<Plottable>}

Retrieve all the plottable objects under the metadata header value.

Parameters:
Name Type Description
category string

A string with the metadata header.

value string

A string with the value under the metadata category.

Source:
Returns:

An Array of plottable objects for the given category value pair.

Type
Array.<Plottable>

getUniqueValuesByCategory(category) → {Array.<string>}

Retrieve the available values for a given metadata category

Parameters:
Name Type Description
category string

A string with the metadata header.

Source:
Returns:

An array of the available values for the given metadata header sorted first alphabetically and then numerically.

Type
Array.<string>

hasConfidenceIntervals() → {Boolean}

Whether or not the plottables have confidence intervals

Source:
Returns:

true if the plottables have confidence intervals, false otherwise.

Type
Boolean

isArrowType()

Method to determine if this is an arrow decomposition

Source:

isScatterType()

Method to determine if this is a scatter decomposition

Source:

toString() → {string}

Helper method to convert a DecompositionModel into a string.

Source:
Returns:

String representation describing the Decomposition object.

Type
string