Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_df(self):
"""Test getting the genes out of the csv file."""
fc_df = read_fold_change_df(FOLD_CHANGES_EXAMPLE)
significant_genes = filter_p_value(fc_df)
gene_sets = gsea_gmt_parser(GMT_EXAMPLE)
self.assertEqual(significant_genes, {'C', 'A'})
self.assertEqual(gene_sets, {'pathway1': ['A', 'B', 'C', 'D'], 'pathway2': ['E', 'F', 'G', 'H']})
enriched_pathways_df = perform_hypergeometric_test(
significant_genes,
{('pathway1', 'kegg'): ['A', 'B', 'C', 'D'], ('pathway2', 'kegg'): ['E', 'F', 'G', 'H']},
apply_threshold=True,
)
self.assertIsInstance(enriched_pathways_df, pd.DataFrame)
self.assertEqual(enriched_pathways_df.shape, (1, 4))
:return: | a dictionary where key is a gene set and values are:
| { es: enrichment score,
| nes: normalized enrichment score,
| p: P-value,
| fdr: FDR,
| size: gene set size,
| matched_size: genes matched to the data,
| genes: gene names from the data set }
"""
assert len(data) > 1
assert permutation_type in ["phenotype", "gene_set"]
data = pd.read_table(data)
classes = gsea_cls_parser(cls)[2]
gmt = gsea_gmt_parser(gene_sets)
gmt.sort()
#Ecompute ES, NES, pval, FDR, RES
if rank_metric is None:
dat = ranking_metric(data,method= method,classes = classes ,ascending=ascending)
results,hit_ind,RES = gsea_compute(data = dat, gene_list = None,rankings = None,
n=permutation_n,gmt = gmt, weighted_score_type=weighted_score_type,
permutation_type=permutation_type)
else:
dat = pd.read_table(rank_metric)
results,hit_ind,RES = gsea_compute(data = None, gene_list = rank_metric['gene_name'],rankings = rank_metric['rank'].values,
n=permutation_n,gmt = gmt, weighted_score_type=weighted_score_type,
permutation_type=permutation_type)
res = {}
for gs, gseale in zip(gmt.keys(), list(results)):