Skip to content

Commit

Permalink
gene_nmf: added ability to set pvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
marcdubybroad committed Aug 23, 2024
1 parent a8fc902 commit 219991f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/novelty/gene_nmf/gene_nmf_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@


# methods
def get_gene_nmf_novelty_for_gene_list(list_input_genes, log=False):
def get_gene_nmf_novelty_for_gene_list(list_input_genes, p_value_cutoff=P_VALUE_CUTOFF, log=False):
'''
'will process the gene nmf call for the gene list given and return the gene novelty
'''
map_result = {}

# get the calculated data
map_gene_novelty, list_input_translated = process_genes(list_input_genes=list_input_genes)
map_gene_novelty, list_input_translated = process_genes(list_input_genes=list_input_genes, p_value_cutoff=p_value_cutoff)

# log result
logger.info("got novelty result map of size: {}".format(len(map_gene_novelty)))
Expand All @@ -97,7 +97,7 @@ def get_gene_nmf_novelty_for_gene_list(list_input_genes, log=False):
return map_result


def process_genes(list_input_genes, log=False):
def process_genes(list_input_genes, p_value_cutoff, log=False):
'''
processes the input genes
'''
Expand All @@ -112,7 +112,7 @@ def process_genes(list_input_genes, log=False):

# do the calculations
list_factor, list_factor_genes, list_factor_gene_sets, gene_factor, gene_set_factor, map_gene_novelty = cutils.calculate_factors(matrix_gene_sets_gene_original=matrix_gene_sets,
p_value=P_VALUE_CUTOFF,
p_value=p_value_cutoff,
list_gene=list_input_translated,
list_system_genes=list_system_genes,
map_gene_index=map_gene_index, map_gene_set_index=map_gene_set_index,
Expand Down
20 changes: 20 additions & 0 deletions tests/test_gene_nmf_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,23 @@ def test_get_gene_nmf_novelty_for_gene_list():
assert len(map_result.get('gene_results')) == len(list_gene_test)



def test_get_gene_nmf_novelty_for_gene_list_and_pvalue():
"""
Test that the gene nmf adaptare novelty function works.
"""
# initialize
map_result = {}

# call method
map_result = adapter.get_gene_nmf_novelty_for_gene_list(list_input_genes=list_gene_test, p_value_cutoff=0.2, log=True)

# logger
logger.info("got map result of size: {}".format(len(map_result.get('gene_results'))))

# test
assert map_result is not None
assert map_result.get('gene_results') is not None
assert len(map_result.get('gene_results')) > 0
assert len(map_result.get('gene_results')) == len(list_gene_test)

0 comments on commit 219991f

Please sign in to comment.