enrichment_tool package

Example usage of EnrichmentTool class

First select studies to use:

In [1]: from DAE import vDB

In [2]: studies = vDB.get_studies('ALL WHOLE EXOME')

In [3]: denovo_studies = [st for st in studies if 'WE' ==
st.get_attr('study.type')]

In [4]: autism_studies = [st for st in denovo_studies if 'autism' ==
st.get_attr('study.phenotype')]

Then create a background model object:

In [5]: from enrichment_tool.background import SamochaBackground

In [6]: background = SamochaBackground()

After that create a counter object:

In [7]: from enrichment_tool.event_counters import GeneEventsCounter

In [8]: counter = GeneEventsCounter()

Create an enrichment tool:

In [9]: from enrichment_tool.tool import EnrichmentTool

In [10]: tool = EnrichmentTool(background, counter)

Select a gene set to work with:

In [11]: from DAE import get_gene_sets_symNS

In [12]: gt = get_gene_sets_symNS('main')

In [13]: gene_set = gt.t2G['chromatin modifiers'].keys()

And then we are ready to perform the actual calculations:

In [14]: res = tool.calc(autism_studies, 'prb', 'LGDs', gene_set)

The result is a dictionary. The keys in the dictionary are:

In [16]: res.keys()
Out[16]: ['rec', 'all', 'male', 'female']

Each value in the dictionary is an instance of the class EnrichmentResult:

In [19]: r = res['rec']

In [20]: len(r.events)
Out[20]: 39

In [21]: len(r.overlapped)
Out[21]: 9

In [22]: r.expected
Out[22]: 0.8992414922169882

In [23]: r.pvalue
Out[23]: 9.4660348870512223e-07

dae.enrichment_tool.background module

Created on Nov 7, 2016

@author: lubo

class dae.enrichment_tool.background.BackgroundBase(name, config)[source]

Bases: object

static backgrounds()[source]
cache_clear()[source]
is_cache_exist()[source]
property is_ready
class dae.enrichment_tool.background.BackgroundCommon(name, config)[source]

Bases: dae.enrichment_tool.background.BackgroundBase

calc_stats(effect_type, enrichment_events, gene_set, children_by_sex)[source]
class dae.enrichment_tool.background.CodingLenBackground(config, variants_db=None)[source]

Bases: dae.enrichment_tool.background.BackgroundCommon

property filename
load()[source]
class dae.enrichment_tool.background.SamochaBackground(config, variants_db=None)[source]

Bases: dae.enrichment_tool.background.BackgroundBase

calc_stats(effect_type, enrichment_results, gene_set, children_by_sex)[source]
property filename
load()[source]
class dae.enrichment_tool.background.SynonymousBackground(config, variants_db=None)[source]

Bases: dae.enrichment_tool.background.BackgroundCommon

TRANSMITTED_STUDY_NAME = 'w1202s766e611'
generate_cache()[source]
load()[source]
dae.enrichment_tool.background.poisson_test(observed, expected)[source]

dae.enrichment_tool.config module

Created on Nov 7, 2016

@author: lubo

class dae.enrichment_tool.config.EnrichmentConfigParser[source]

Bases: dae.configuration.config_parser_base.ConfigParserBase

FILTER_SELECTORS = {'background': 'selectedBackgroundValues', 'counting': 'selectedCountingValues'}
SECTION = 'enrichment'
SPLIT_STR_LISTS = ('peopleGroups', 'selectedBackgroundValues', 'selectedCountingValues', 'effect_types')
static enrichment_cache_file(config, name='')[source]
classmethod parse(config)[source]

Parse SECTION section from configuration if it is defined else parse all of the sections in the configuration.

Parameters

config (Box or dict) – configuration.

Returns

parsed configuration.

Return type

Box or dict or None

dae.enrichment_tool.event_counters module

Created on Nov 7, 2016

@author: lubo

class dae.enrichment_tool.event_counters.CounterBase[source]

Bases: object

static counters()[source]
events(variants)[source]
class dae.enrichment_tool.event_counters.EnrichmentResult(name)[source]

Bases: object

Represents result of enrichment tool calculations. Supported fields are:

name

events – list of events found

overlapped – list of overlapped events

expected – number of expected events

pvalue

class dae.enrichment_tool.event_counters.EventsCounter[source]

Bases: dae.enrichment_tool.event_counters.CounterBase

events(variants, children_by_sex, effect_types)[source]
class dae.enrichment_tool.event_counters.GeneEventsCounter[source]

Bases: dae.enrichment_tool.event_counters.CounterBase

events(variants, children_by_sex, effect_types)[source]
dae.enrichment_tool.event_counters.filter_denovo_one_event_per_family(vs, requested_effect_types)[source]

For each variant returns list of affected gene syms.

vs - generator for variants.

This functions receives a generator for variants and transforms each variant into list of gene symbols, that are affected by the variant.

The result is represented as list of lists.

dae.enrichment_tool.event_counters.filter_denovo_one_gene_per_events(vs, requested_effect_types)[source]
dae.enrichment_tool.event_counters.filter_denovo_one_gene_per_recurrent_events(vs, requsted_effect_types)[source]
dae.enrichment_tool.event_counters.filter_overlapping_events(events, gene_syms)[source]
dae.enrichment_tool.event_counters.get_sym_2_fn(vs, requested_effect_types)[source]
dae.enrichment_tool.event_counters.overlap_enrichment_result_dict(enrichment_results, gene_syms)[source]

dae.enrichment_tool.tool module

class dae.enrichment_tool.tool.EnrichmentTool(config, background, event_counter)[source]

Bases: object

calc(effect_types, gene_syms, variants, children_by_sex)[source]

Module contents