API Documentation

Backend

This module is a flask backend providing a REST api to add interactivity to the report.

The backend needs to be able to restore the phenotype database functionality and be able to generate plots.

These methods will return json to the report. Alternatively, they will return the native python objects. This way, the functionality will all be here and everything that’s related to the report’s content and formatting will be in the report module.

class forward.backend.Backend(experiment_name)[source]

Class that provides all api functionality to be used for both report creation and the rest api.

get_bonferonni(task_name, alpha)[source]

Get the Bonferonni adjusted alpha for a given task.

get_configuration()[source]

Return the YAML configuration file.

get_outcome_vector(variable, transformation=None, nan=True)[source]

Get an outcome vector (y).

Parameters:
  • variable (Numpy-like array) – The variable to query.
  • transformation (str) – The name of the transformation to apply (e.g. log)
  • nan (bool) – If False, the returned vector will be stripped of NaN values.

Note

This is parsed from the hdf5 file that is automatically created.

Get information on the exclusions based on phenotype correlation.

get_results(task, filters=[], order_by=None, ascending=True)[source]

Get the results for a specific analysis.

get_task_info(task)[source]

Get the serialized information associated with a task.

get_tasks()[source]

Get a list of task names that were conducted in this experiment.

get_variable_corrplot()[source]

Get the correlation matrix and the row/column names.

get_variable_histogram(variable, transformation=None, **kwargs)[source]

Get the bin counts for a given variable.

This returns the numpy histogram’s function values.

get_variable_normal_qqplot(variable, transformation=None)[source]

Get scatter values for a normal QQ plot associated with a variable.

get_variables(var_type=None, order_by=None, ascending=True)[source]

Get the variables that were analysed in the experiment.

Parameters:
  • var_type (str) – Restrict to “discrete” or “continuous” variables (optional, default is None).
  • order_by – Key of the Variable instance for results ordering.
  • ascending (bool) – Flag to determine sorting order.
get_variants(add_maf=False)[source]

Get a list of variants and related fields.

p_value_qq_plot(task)[source]

Return the scatter data and confidence bands.

This is assuming we’re expecting a uniform distribution. We also take a log transform to accentuate small differences.

out = {
    "ci": [(ci_low, ci_high)],
    "outcomes": ["phen1", "phen2", ...],
    "expected": [exp1, exp2, ...],
    "lines": {
        "phen1": [obs1, obs2, ...],
        "phen2": [obs1, obs2, ...],
        ...
    }
}
forward.backend.api_get_yaml_configuration()[source]

Returns a pygmentized version of the configuration file.

forward.backend.initialize_application(experiment_name)[source]

Initialize database connection and bind to the application context.