-
Notifications
You must be signed in to change notification settings - Fork 8
Analysis Page
This page describes the programmatic flow and details about the analysis page (widget.metagenome_analysis.js) and is intended for programmers.
- Workflow
- Profile Loader
- Data Container
- Matrix Manipulation
- Visualization
- Export
- Plugins
- Recipes
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.
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.
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.
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
.
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.
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).
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
When the analysis page is called with a recipe parameter, it shows a different UI. The number parameter that is the value of the cgi parameter recipe is the recipe index. Recipe definitions are stored in the data/recipes
directory. They define which controls should be available, what defaults should be shown for the filters and other settings along with a textual description of what the user should do. The recipe UI has a feature to reset to its initial state and an option to extend to the advanced filter and visualization UI.