Skip to content

Analysis Page

Tobias Paczian edited this page Apr 12, 2018 · 21 revisions

This page describes the programmatic flow and details about the analysis page (widget.metagenome_analysis.js) and is intended for programmers.

Sections

  • Workflow
  • Profile Loader
  • Data Container
  • Matrix Manipulation
  • Visualization
  • Export
  • Plugins
  • Recipes

Workflow

When the page loads, background data is loaded containing all functional annotation spaces and the taxonomy reference. The user selects data-sets and data-sources via the listselect renderer that uses the MG-RAST API search resource. Upon selection an data container is created containing all metadata about the current analysis. Then a query for the selected profiles will be sent to the API. When a profile is downloaded it is put into a compressed format in memory.

The profiles themselves never get modified by any analysis. The container2matrix function generates a matrix from the profiles given the cutoffs and adds it to the container. Data containers can be exported as Analysis Objects. Other exports include FASTA, CSV and BIOM. A data container can also be visualized via one of the visualizations offered by the visualizationMapping function. It loads the visualization description from the data/graphs directory. These can be fed into the RendererController. Each description points to a data conversion method container2xxx that converts the data of the data container into the format required for the visualization. The base of most of these conversions is the container2matrix function after which the resulting matrix is modified. The visualizations use the svg2 library that has high level drawing functions for graphs of any kind.

There are three basic levels of navigation within a data-set. The visualization usually provides click events to drill down, the breadcrumbs bar to extend back up and the filter options. The settings of the data container are updated with the change and the rendering is repeated.

Plugins come with their own conversion method and open in a new window that gets sent the resulting data.

Profile Loader

The profile loader uses the renderer.listselect.js renderer for the UI. It queries the http://api.mg-rast.org/search resource with the authentication of the currently logged in user. In addition there is a data source selector. The result list is the used to issue calls to the profile resource of the API. The profiles are compressed into a memory saving format that can still be quickly parsed. The function and taxonomy ids from the profile are joined with , so not too many memory consuming arrays have to be created. The functions and taxonomy ids can be matched against the id -> string mapping loaded on page load.

Data Container

A data container represents a single analysis. It contains the metadata that defines the analysis, e.g. the data set ids and metadata, selected data sources and cutoffs. It also has the current visualization data (including settings) and the data matrix for the current settings.

Matrix Manipulation

The retina.js module offers a set of matrix manipulation functions that are used for performing normalization, log and histogram calculations on the matrix created by container2matrix.

Visualization

Most of the visualizations, with the exception of the table and the matrix view, are generated via the svg2.js module. It contains high level functions for generating graphs. The visualization functions can perform adjustments based on the data and the changes from the control panel in the UI. The graphics are controlled via the visualizationMapping and the changes are executed by the visualization method.

Export

The export functions take the data container as input and create the different formats for export. CSV and BIOM export take the data matrix and map the functional and taxonomic id against the textual strings. The FASTA export uses the MD5 information and sends a POST request to the API for the FASTA download. The image exports take the visualization information that is also stored in the data container and uses the retina image export function for the different graphical output formats (currently SVG and PNG).

Plugins

A plugin requires a data conversion method and some description data. The conversion method is passed data container and then creates the data format required for the plugin. The plugin widget must be called widget.plugin_PLUGINNAME.js and will be called on a new instance of plugin.html. The page automatically has stm enabled which is initialized with the attributes

  • plugin - the name of the plugin
  • info - a data structure containing the author and publication link that is automatically put into the header
  • transfer - the data for the plugin
Clone this wiki locally