Skip to content

Commit

Permalink
Propagate background gene sets into ORA functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bgyori committed Jan 24, 2025
1 parent 730e04d commit 4b2fc93
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/indra_cogex/analysis/gene_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def discrete_analysis(
)

if background_gene_list:
background_gene_ids, _ = list(parse_gene_list(background_gene_list))
background_genes, _ = parse_gene_list(background_gene_list)
background_gene_ids = list(background_genes)
else:
background_gene_ids = None

Expand All @@ -97,7 +98,8 @@ def discrete_analysis(
if analysis_name in {"go", "wikipathways", "reactome", "phenotype"}:
analysis_result = analysis_func(
client=client, gene_ids=gene_set, method=method, alpha=alpha,
keep_insignificant=keep_insignificant
keep_insignificant=keep_insignificant,
background_gene_ids=background_gene_ids
)
else:
# Run INDRA analysis if enabled
Expand Down
20 changes: 16 additions & 4 deletions src/indra_cogex/client/enrichment/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ def go_ora(
if not background_gene_ids
else len(background_gene_ids)
)
return _do_ora(get_go(client=client), query=gene_ids, count=count, **kwargs)
bg_genes = frozenset(background_gene_ids) if background_gene_ids else None
return _do_ora(get_go(client=client, background_gene_ids=bg_genes),
query=gene_ids, count=count, **kwargs)


def wikipathways_ora(
Expand Down Expand Up @@ -249,8 +251,10 @@ def wikipathways_ora(
if not background_gene_ids
else len(background_gene_ids)
)
bg_genes = frozenset(background_gene_ids) if background_gene_ids else None
return _do_ora(
get_wikipathways(client=client), query=gene_ids, count=count, **kwargs
get_wikipathways(client=client, background_gene_ids=bg_genes),
query=gene_ids, count=count, **kwargs
)


Expand Down Expand Up @@ -285,7 +289,9 @@ def reactome_ora(
if not background_gene_ids
else len(background_gene_ids)
)
return _do_ora(get_reactome(client=client), query=gene_ids, count=count, **kwargs)
bg_genes = frozenset(background_gene_ids) if background_gene_ids else None
return _do_ora(get_reactome(client=client, background_gene_ids=bg_genes),
query=gene_ids, count=count, **kwargs)


@autoclient()
Expand Down Expand Up @@ -321,8 +327,10 @@ def phenotype_ora(
if not background_gene_ids
else len(background_gene_ids)
)
bg_genes = frozenset(background_gene_ids) if background_gene_ids else None
return _do_ora(
get_phenotype_gene_sets(client=client), query=gene_ids, count=count, **kwargs
get_phenotype_gene_sets(client=client, background_gene_ids=bg_genes),
query=gene_ids, count=count, **kwargs
)


Expand Down Expand Up @@ -367,11 +375,13 @@ def indra_downstream_ora(
if not background_gene_ids
else len(background_gene_ids)
)
bg_genes = frozenset(background_gene_ids) if background_gene_ids else None
return _do_ora(
get_entity_to_regulators(
client=client,
minimum_evidence_count=minimum_evidence_count,
minimum_belief=minimum_belief,
background_gene_ids=bg_genes
),
query=gene_ids,
count=count,
Expand Down Expand Up @@ -420,11 +430,13 @@ def indra_upstream_ora(
if not background_gene_ids
else len(background_gene_ids)
)
bg_genes = frozenset(background_gene_ids) if background_gene_ids else None
return _do_ora(
get_entity_to_targets(
client=client,
minimum_evidence_count=minimum_evidence_count,
minimum_belief=minimum_belief,
background_gene_ids=bg_genes
),
query=gene_ids,
count=count,
Expand Down

0 comments on commit 4b2fc93

Please sign in to comment.