Hello,
I need to some help/guidance to convert some Python code to post and get data from a website (https://maayanlab.cloud/Enrichr/help#api) designed to determine if there is enrichment in a gene list or some biological pathways. I am not familiar enough with the syntax needed to interact with REST API using the 'new HTTP request' to pull this off.
The ability to get info from that services will be merged into an addin designed to perform some basic gene expression analysis. I'm trying to avoid having to rely on Python within JMP because I want to avoid having the addin users install Python on their machine if they don't have to.
Step 1 - Post a gene list to service - The Python code is below
import json
import requests
ENRICHR_URL = 'http://maayanlab.cloud/Enrichr/addList'
genes_str = '\n'.join([
'PHF14', 'RBM3', 'MSL1', 'PHF21A', 'ARL10', 'INSR', 'JADE2', 'P2RX7',
'LINC00662', 'CCDC101', 'PPM1B', 'KANSL1L', 'CRYZL1', 'ANAPC16', 'TMCC1',
'CDH8', 'RBM11', 'CNPY2', 'HSPA1L', 'CUL2', 'PLBD2', 'LARP7', 'TECPR2',
'ZNF302', 'CUX1', 'MOB2', 'CYTH2', 'SEC22C', 'EIF4E3', 'ROBO2',
'ADAMTS9-AS2', 'CXXC1', 'LINC01314', 'ATF7', 'ATP5F1'
])
description = 'Example gene list'
payload = {
'list': (None, genes_str),
'description': (None, description)
}
response = requests.post(ENRICHR_URL, files=payload)
if not response.ok:
raise Exception('Error analyzing gene list')
data = json.loads(response.text)
print(data)
This will generate a userListId which will be used to retrieve the data from the analysis
Step 2 - Get a list of Biological Pathways that showing some gene enrichment from the service - The Python code is below:
import json
import requests
ENRICHR_URL = 'http://maayanlab.cloud/Enrichr/enrich'
query_string = '?userListId=%s&backgroundType=%s'
user_list_id = 363320
gene_set_library = 'KEGG_2015'
response = requests.get( ENRICHR_URL + query_string % (user_list_id, gene_set_library) )
if not response.ok:
raise Exception('Error fetching enrichment results')
data = json.loads(response.text)
print(data)
In the example above - 3 things should ideally happen:
- (The HTTP request should be looping through multiple gene_set libraries (gene_set_library= {"KEGG_2015", "Panther_2016", "WikiPathways_2016", " Reactome_2016"} //many more libraries are available)
- The Json that is retrieved does not appear to be easily parsed and needs to have headers (Rank, Term name, P-value, Z-score, Combined score, Overlapping genes, Adjusted p-value, Old p-value, Old adjusted p-value) associated with it
- Each Json file retrieved should be concatenated into a JMP table
I hope there is someone out there looking for a little challenge and is willing to give it a shot.
Best Regards,
Sebastien