How to use the gseapy.enrichr function in gseapy

To help you get started, we’ve selected a few gseapy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sequana / sequana / sequana / enrichment.py View on Github external
def _enrichr(self, category, background=None, verbose=True):

        if background is None:
            background = self.background

        if isinstance(category, list):
            gene_list = category
        else:
            assert category in ['up', 'down', 'all']
            gene_list = list(self.rnadiff.dr_gene_lists[self.comparison][category])

        enr = gseapy.enrichr(
            gene_list=gene_list,
            gene_sets=self.gene_sets,
            verbose=verbose,
            background=background,
            outdir="test", no_plot=True)

        return enr
github greenelab / tad_pathways_pipeline / scripts / pathway_analysis.py View on Github external
# Load arguments
tad_gene_file = args.tad_genelist_file
output_name = args.output_name
output_dir = args.output_directory
gene_sets = args.gene_sets

# Save output file locations
out_dir = os.path.join(output_dir, output_name)

# Load data
gene_df = pd.read_table(tad_gene_file)
genes = gene_df.gene_name
output_results_file = "{}_enrichr_results.tsv".format(out_dir)

# Perform the enrichment analysis
enr = gp.enrichr(gene_list=genes,
                 description=output_name,
                 gene_sets=gene_sets,
                 outdir=out_dir,
                 cutoff=0.5)

# Output results
results_df = enr.results.sort_values(by='Combined Score', ascending=False)
results_df.to_csv(output_results_file, sep='\t', index=False)