### Install Reactome2py from Source Source: https://github.com/reactome/reactome2py/blob/main/README.md Install Reactome2py by cloning the repository and running the setup script. This is useful for development or when needing the latest unreleased version. ```shell git clone repo cd reactome2py python setup.py install ``` -------------------------------- ### Install Reactome2py using pip Source: https://github.com/reactome/reactome2py/blob/main/README.md Install the Reactome2py library using pip. This is the recommended method for most users. ```bash (sudo) pip install reactome2py ``` -------------------------------- ### Get Pathway Summary for Entities/Interactors Source: https://context7.com/reactome/reactome2py/llms.txt Returns found identifiers and interactors for a specific pathway within an analysis token result. Allows specifying the resource and filtering by 'all', 'entities', or 'interactors'. ```python from reactome2py import analysis # Get all found entities and interactors summary = analysis.token_pathway_summary( token='MjAyMzA1MTUxMTM3NjdfMQ==', pathway='R-HSA-162582', resource='TOTAL', by='all' # 'all', 'entities', or 'interactors' ) print(summary['expNames']) print(summary['found']) ``` -------------------------------- ### Get Participants of an Event Source: https://context7.com/reactome/reactome2py/llms.txt Retrieves PhysicalEntities and their ReferenceEntities participating in a specified event. Use when you need to identify the components of a Reactome event. ```python from reactome2py import content parts = content.participants(id='5205685') for p in parts[:3]: print(p['displayName']) print([r['identifier'] for r in p.get('refEntities', [])]) ``` -------------------------------- ### participants Source: https://context7.com/reactome/reactome2py/llms.txt Get participants of an event. ```APIDOC ## participants ### Description Returns PhysicalEntities and their ReferenceEntities that participate in a given event. ### Method `content.participants(id: str)` ### Parameters - **id** (str) - The stable ID of the event. ### Request Example ```python from reactome2py import content parts = content.participants(id='5205685') for p in parts[:3]: print(p['displayName']) print([r['identifier'] for r in p.get('refEntities', [])]) ``` ``` -------------------------------- ### Build and Run Reactome2py Docker Image Source: https://github.com/reactome/reactome2py/blob/main/README.md Build a Docker image for Reactome2py and run it interactively. This provides a containerized environment for using the library. ```shell (sudo) docker build -t :latest . (sudo) docker run -it --rm :latest ``` -------------------------------- ### Generate a full pathway analysis report Source: https://github.com/reactome/reactome2py/blob/main/demo/microbiologist-clinician.ipynb Creates a directory if it doesn't exist and then generates a comprehensive PDF report of the pathway analysis. This report can be customized with various parameters like resource, diagram profile, and species. ```python if not os.path.exists('full-report/'): os.makedirs('full-report/') analysis.report(token, path='full-report/', file='report.pdf', number='25', resource='TOTAL', diagram_profile='Modern', analysis_profile='Standard', fireworks_profile='Barium Lithium', species='Homo sapiens', chunk_size=128) ``` -------------------------------- ### orthology Source: https://context7.com/reactome/reactome2py/llms.txt Get orthology of a human pathway in a specified species. ```APIDOC ## orthology ### Description Get orthology of a human pathway in a specified species. ### Method `content.orthology(id: str, species: str)` ### Parameters - **id** (str) - The stable ID of the human pathway. - **species** (str) - The species ID for which to find orthologs. ### Request Example ```python from reactome2py import content ortho = content.orthology(id='R-HSA-6799198', species='49633') print(ortho['displayName']) print(ortho['stId']) ``` ``` -------------------------------- ### interactors_upload_content Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Paste file content and get a summary associated with a token. ```APIDOC ## interactors_upload_content ### Description Paste file content and get a summary associated with a token. ### Parameters * **name** (string) - Name which identifies the sample * **content** (string) - Paste custom interactors file content ### Returns Paste file content and get a summary associated with a token ``` -------------------------------- ### Download and Parse Reactome Pathway-to-Gene Mappings (GMT) Source: https://context7.com/reactome/reactome2py/llms.txt Downloads the Reactome GMT file and parses it into a list of dictionaries, mapping pathways to their associated HGNC gene symbols. Useful for pathway enrichment analysis. ```python from reactome2py import fiviz mappings = fiviz.gene_mappings() # Each entry: {'name': 'Pathway Name', 'stId': 'R-HSA-XXXX', 'genes': ['GENE1', 'GENE2', ...]} print(mappings[0]) # {'name': 'Apoptosis', 'stId': 'R-HSA-109581', 'genes': ['CASP3', 'CASP8', ...]} # Build a lookup: pathway stId -> gene list pathway_genes = {m['stId']: m['genes'] for m in mappings} print(pathway_genes['R-HSA-109581'][:5]) ``` -------------------------------- ### entities_complex Source: https://context7.com/reactome/reactome2py/llms.txt Get subunits of a complex. This function retrieves all subunit PhysicalEntities for a given Reactome complex, with optional recursive traversal. ```APIDOC ## entities_complex ### Description Retrieves all subunit PhysicalEntities for a given Reactome complex, with optional recursive traversal. ### Method `content.entities_complex(id: str, exclude_structures: bool = False) -> list` ### Parameters * **id** (str) - Required - The Reactome ID of the complex. * **exclude_structures** (bool) - Optional - Whether to exclude structural entities. Defaults to False. ### Response Example ```python from reactome2py import content subunits = content.entities_complex( id='R-HSA-5674003', exclude_structures=False ) for s in subunits[:3]: print(s['displayName'], s['schemaClass']) ``` ``` -------------------------------- ### Open Reactome analysis results in browser Source: https://github.com/reactome/reactome2py/blob/main/demo/microbiologist-clinician.ipynb Constructs a URL to view the analysis results directly on the Reactome website using the generated analysis token. ```python url = 'https://reactome.org/PathwayBrowser/#/DTAB=AN&ANALYSIS=' + token webbrowser.open(url) ``` -------------------------------- ### Export Pathway Diagram as Image Source: https://context7.com/reactome/reactome2py/llms.txt Downloads a pathway diagram in a specified image format (PNG, SVG, JPG, GIF) with optional analysis overlay. Specify file name and path for saving. ```python from reactome2py import content content.export_diagram( id='R-HSA-177929', ext='png', quality=8, diagram_profile='Modern', title=True, margin=15, file='signal_transduction', path='/diagrams/' ) # Saves /diagrams/signal_transduction.png ``` ```python # With analysis overlay content.export_diagram( id='R-HSA-177929', ext='svg', token='MjAyMzA1MTUxMTM3NjdfMQ==', analysis_profile='Standard', file='overlay_diagram', path='/diagrams/' ) ``` -------------------------------- ### Download Analysis Result as JSON (Python) Source: https://context7.com/reactome/reactome2py/llms.txt Downloads a full analysis result using a provided token. The 'reactome2py.analysis' module is required. Results can be returned as a Python dictionary or saved to a gzipped JSON file. ```python from reactome2py import analysis token = 'MjAyMzA1MTUxMTM3NjdfMQ==' # Return as Python dict result = analysis.result2json(token=token) print(result['pathways'][0]) # Save gzipped to disk analysis.result2json( token=token, path='/results/', file='egfr_result.json.gz', save=True, gzip=True ) ``` -------------------------------- ### Get Subunits of a Complex Source: https://context7.com/reactome/reactome2py/llms.txt Retrieves all subunit PhysicalEntities for a given Reactome complex. Supports optional recursive traversal and exclusion of structures. ```python from reactome2py import content subunits = content.entities_complex( id='R-HSA-5674003', exclude_structures=False ) for s in subunits[:3]: print(s['displayName'], s['schemaClass']) ``` -------------------------------- ### Fetch and export downstream pathway diagrams Source: https://github.com/reactome/reactome2py/blob/main/demo/microbiologist-clinician.ipynb Fetches downstream pathways that have diagrams, highlights reactions from the enrichment analysis token, and exports each diagram as a PNG file. This allows for detailed review and comparison of specific pathways. ```python fetch_downstream_pathways = [content.pathways_low_diagram(id=stId, species=None, all_forms=False) for stId in pathways_stId] downstream_pathways = [low_pathway for low_pathway in fetch_downstream_pathways if low_pathway is not None] has_diagram = [p[0]['hasDiagram'] for p in downstream_pathways] downstream_pathway_has_diagram = list(itertools.compress(downstream_pathways, has_diagram)) downstream_pathway_stId = [p[0]['stId'] for p in downstream_pathway_has_diagram] if not os.path.exists('diagrams/'): os.makedirs('diagrams/') [content.export_diagram(id=stId, ext='png', quality='5', flag_interactors=False, title=True, margin='15', ehld=True, diagram_profile='Modern', resource='Total', analysis_profile='Standard', token=token, flag=None, sel=[], exp_column=None, file="-".join([stId,'report']), path='diagrams/') for stId in downstream_pathway_stId] ``` -------------------------------- ### search_fireworks Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Performs a Solr query scoped to the fireworks widget for a given QueryObject, with options for query, species, types, start, and rows. ```APIDOC ## search_fireworks ### Description Performs a Apache Solr query (fireworks widget scoped) for a given QueryObject. ### Parameters * **query** (string) - Search term * **species** (string) - Species identifier (it can be the taxonomy id, species name or dbId) * **types** (list) - Types to filter by - python list of strings * **start** (any) - Start row * **rows** (any) - Number of rows to include ### Returns Json dictionary object ``` -------------------------------- ### token_pathways_summary Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves summary for multiple pathways using a token. ```APIDOC ## token_pathways_summary() ### Description Retrieves a summary for multiple pathways using a token. ### Method `reactome2py.analysis.token_pathways_summary` ### Parameters This function does not explicitly list parameters in the provided documentation. ``` -------------------------------- ### Get PSICQUIC Interactor Data for an Accession Source: https://context7.com/reactome/reactome2py/llms.txt Retrieves protein-protein interaction data from external PSICQUIC resources for a given accession. Allows querying specific resources like MINT. ```python from reactome2py import content # Get available PSICQUIC resources first resources = content.interactors_psicquic_resources() print([r['name'] for r in resources]) # Fetch interaction details from MINT interactions = content.interactors_psicquic_acc( resource='MINT', acc='Q13501', by='details' ) print(interactions['rows'][0]) ``` -------------------------------- ### Export fireworks visualization Source: https://github.com/reactome/reactome2py/blob/main/demo/microbiologist-clinician.ipynb Saves a 'fireworks' visualization of the pathways to a specified directory. This visualization helps in reviewing the overall scope of highlighted pathways. ```python if not os.path.exists('fireworks/'): os.makedirs('fireworks/') content.export_fireworks(species='9606', ext='png', file='fireworks_report', path='fireworks/', quality='10', flag=None, flag_interactors=False, sel=[], title=True, margin='15', resource='Total', diagram_profile='', coverage=False, token=token, exp_column=None) ``` -------------------------------- ### token_resources Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves available resources using a token. ```APIDOC ## token_resources() ### Description Retrieves information about available resources using a token. ### Method `reactome2py.analysis.token_resources` ### Parameters This function does not explicitly list parameters in the provided documentation. ``` -------------------------------- ### Get Static Interactor Details for an Accession Source: https://context7.com/reactome/reactome2py/llms.txt Fetches curated protein-protein interaction details from Reactome's built-in data for a UniProt accession. Useful for analyzing known interactions without external queries. ```python from reactome2py import content interactions = content.interactors_static_acc( acc='Q13501', by='details', page=1, page_size=10 ) print(interactions['columnNames']) for row in interactions['rows'][:3]: print(row['accA'], row['accB'], row['score']) ``` -------------------------------- ### List Pathways with SBGN Files Source: https://context7.com/reactome/reactome2py/llms.txt Retrieves pathway stable IDs for lower-level pathways that have SBGN files, excluding EHLD pathways. Useful for accessing pathways in the SBGN format. ```python from reactome2py import fiviz sbgn_list = fiviz.sbgn_stids() print(f"{len(sbgn_list)} pathways have SBGN files") print(sbgn_list[:3]) ``` -------------------------------- ### Get Orthology of Human Pathway in Sus scrofa Source: https://context7.com/reactome/reactome2py/llms.txt Retrieves orthologous pathways for a given human pathway ID in Sus scrofa. Requires the pathway's Reactome ID and the species ID for Sus scrofa. ```python ortho = content.orthology(id='R-HSA-6799198', species='49633') print(ortho['displayName']) print(ortho['stId']) ``` -------------------------------- ### Export Pathway as PDF Document Source: https://context7.com/reactome/reactome2py/llms.txt Exports a detailed PDF document for a pathway event, including diagram, summation, references, and edit history. Specify file name and path for saving. ```python from reactome2py import content content.export_document( id='R-HSA-177929', level='1', diagram_profile='Modern', file='pathway_doc', path='/reports/' ) # Saves /reports/pathway_doc.pdf ``` -------------------------------- ### Get Targets for a Specific Drug Source: https://context7.com/reactome/reactome2py/llms.txt Returns all known protein targets for a given drug name from specified sources like DrugCentral or Targetome. Requires specifying the Reactome release version, drug name, and data source. ```python from reactome2py import fiviz targets = fiviz.drug_targets( release='2019', drug='Gefitinib', source='drugcentral' ) for t in targets: print(t['gene'], t['interactionType']) ``` -------------------------------- ### Compare Species Pathways Source: https://context7.com/reactome/reactome2py/llms.txt Compares Homo sapiens pathways to another species using Reactome's species comparison tool. Requires a species ID and allows sorting by entities FDR with a specified order and p-value. ```python from reactome2py import analysis # Compare Homo sapiens vs. Mus musculus (dbId: 48892) result = analysis.compare_species( species='48892', sort_by='ENTITIES_FDR', order='ASC', p_value=0.05 ) print(result['pathways'][0]['name']) ``` -------------------------------- ### discover Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Discovers content within the reactome2py content module. ```APIDOC ## discover() ### Description Discovers content. ### Module reactome2py.content ``` -------------------------------- ### Export Pathway to SBGN or SBML Source: https://context7.com/reactome/reactome2py/llms.txt Exports a pathway or reaction in Systems Biology Graphical Notation (SBGN) or Systems Biology Markup Language (SBML) format. Specify file name and path for saving. ```python from reactome2py import content content.export_event( id='R-HSA-177929', format='sbgn', file='pathway_network', path='/exports/' ) # Saves /exports/pathway_network.sbgn ``` -------------------------------- ### token_pathways_reactions Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves reactions for multiple pathways using a token. ```APIDOC ## token_pathways_reactions() ### Description Retrieves reactions for multiple pathways using a token. ### Method `reactome2py.analysis.token_pathways_reactions` ### Parameters This function does not explicitly list parameters in the provided documentation. ``` -------------------------------- ### reactome2py.content.search_diagram_instance Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Searches for diagram instances. ```APIDOC ## search_diagram_instance() ### Description Searches for specific instances within diagrams. Specific search parameters and return types are not detailed in the source. ### Method GET ### Endpoint /search/diagram/instance ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### Download PDF Analysis Report Source: https://context7.com/reactome/reactome2py/llms.txt Downloads a formatted PDF report for an analysis token. Allows customization of the save path, filename, number of pathways, resource, diagram profile, analysis profile, and species. ```python from reactome2py import analysis analysis.report( token='MjAyMzA1MTUxMTM3NjdfMQ==', path='/results/', file='pathway_report.pdf', number=25, resource='TOTAL', diagram_profile='Modern', analysis_profile='Standard', species='Homo sapiens' ) ``` -------------------------------- ### token_pathway_summary Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves pathway summary using a token. ```APIDOC ## token_pathway_summary() ### Description Retrieves a summary of a pathway using a token. ### Method `reactome2py.analysis.token_pathway_summary` ### Parameters This function does not explicitly list parameters in the provided documentation. ``` -------------------------------- ### List All or Main Species Source: https://context7.com/reactome/reactome2py/llms.txt Returns the list of all or main species available in Reactome. Useful for identifying species taxonomy IDs for other API calls. ```python from reactome2py import content all_species = content.species(by='all') main_species = content.species(by='main') for s in main_species[:5]: print(s['taxId'], s['displayName']) # 9606 Homo sapiens # 10090 Mus musculus ``` -------------------------------- ### search_suggest Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Retrieves a list of suggestions for a given search term. ```APIDOC ## search_suggest ### Description This method retrieves a list of suggestions for a given search term. ### Parameters * **query** (string) - term to search ### Returns list of matched elements ``` -------------------------------- ### reactome2py.content.pathways_top_level Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves top-level pathways. ```APIDOC ## pathways_top_level() ### Description Retrieves a list of top-level pathways. Specific parameters and return types are not detailed in the source. ### Method GET ### Endpoint /pathways/top_level ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### export_fireworks Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Exports a pathway overview to a specified image format. ```APIDOC ## export_fireworks ### Description Exports a given pathway overview to the specified image format (png, jpg, jpeg, svg, gif). ### Parameters * **species** (string) - Optional - Species identifier (taxonomy id, species name, or dbId). Defaults to '9606'. * **ext** (string) - Optional - File extension defining the image format. Available extensions: png, jpg, jpeg, svg, gif. Defaults to 'png'. * **file** (string) - Optional - Name of the file. Defaults to 'report'. * **path** (string) - Optional - Absolute path to save the file. Defaults to an empty string. * **quality** (string) - Optional - Result image quality between 1 and 10. Defaults to '5'. * **flag** (string) - Optional - Gene name, protein or chemical identifier or Reactome identifier used to flag elements in the diagram. * **flag_interactors** (boolean) - Optional - Defines whether to take into account interactors for the flagging. Defaults to False. * **sel** (list) - Optional - Highlight element(s) selection in the diagram. Example: ['X', 'Y', 'Z']. Defaults to an empty list. * **title** (boolean) - Optional - Sets whether the name of the pathway is shown below. Defaults to True. * **margin** (string) - Optional - Defines the image margin between 0 and 20. Defaults to '15'. * **resource** (string) - Optional - The analysis resource for which the results will be overlaid on top of the given pathways overview. Defaults to 'Total'. * **diagram_profile** (string) - Optional - Diagram Color Profile. Available in: Copper, Copper plus, Barium lithium, Calcium salts. * **coverage** (boolean) - Optional - Set to true to overlay analysis coverage values. Defaults to False. * **token** (string) - Optional - The analysis token with the results to be overlaid on top of the given pathways overview. * **exp_column** (string) - Optional - Expression column. When the token is associated to an expression analysis, this parameter allows specifying the expression column for the overlay. ``` -------------------------------- ### token_resources Source: https://github.com/reactome/reactome2py/blob/main/docs/analysis.html Retrieves the resources summary associated with a given token. ```APIDOC ## token_resources ### Description Retrieves the resources summary associated with a given token. ### Parameters #### Path Parameters - **token** (string) - Required - The token associated with the data result - analysis Web-Service is token based, so for every analysis request a TOKEN is associated to the result ### Returns Json list object ``` -------------------------------- ### reactome2py.content.search_suggest Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Provides search suggestions. ```APIDOC ## search_suggest() ### Description Provides search suggestions based on a query. Specific parameters and return types are not detailed in the source. ### Method GET ### Endpoint /search/suggest ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### Retrieve Reactome Database Metadata Source: https://context7.com/reactome/reactome2py/llms.txt Fetches the current name and version of the Reactome database backing the Analysis Service. ```python from reactome2py import analysis print(analysis.db_name()) # e.g. "reactome" print(analysis.db_version()) # e.g. "79" ``` -------------------------------- ### Multi-Identifier Pathway Enrichment Analysis (Python) Source: https://context7.com/reactome/reactome2py/llms.txt Submits a comma-separated list of identifiers for pathway enrichment analysis. The 'reactome2py.analysis' module must be imported. Results include a token for retrieving full details and a summary of pathways. ```python from reactome2py import analysis result = analysis.identifiers( ids='EGF,EGFR,BRAF,TP53', interactors=True, page_size=10, page=1, species='Homo Sapiens', sort_by='ENTITIES_FDR', order='ASC', p_value=0.05, include_disease=False, projection=False ) token = result['summary']['token'] print(f"Analysis token: {token}") for pw in result['pathways'][:3]: print(pw['stId'], pw['name'], pw['entities']['fdr']) # R-HSA-162582 Signal Transduction 0.0001 # R-HSA-5633007 Regulation of TP53 0.0003 ``` -------------------------------- ### import_form Source: https://github.com/reactome/reactome2py/blob/main/docs/analysis.html Imports a posted JSON file into the service. The accepted format is the same as provided by the /#/download/{token}/result.json endpoint. The submitted file can be gzipped. ```APIDOC ## import_form ### Description Imports the posted json file into the service The accepted format is the same as provided by the method /#/download/{token}/result.json. Note: The submitted file can be gzipped. ### Parameters #### Path Parameters - **input_file** (file) - Required ### Returns Json list object ``` -------------------------------- ### token_pathway_reactions Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves pathway reactions using a token. ```APIDOC ## token_pathway_reactions() ### Description Retrieves reactions associated with a pathway using a token. ### Method `reactome2py.analysis.token_pathway_reactions` ### Parameters This function does not explicitly list parameters in the provided documentation. ``` -------------------------------- ### token_pathways_summary Source: https://github.com/reactome/reactome2py/blob/main/docs/analysis.html Queries analysis token and returns a summary of the contained identifiers and interactors for all pathways. ```APIDOC ## token_pathways_summary ### Description Queries analysis token and returns a summary of the contained identifiers and interactors for all pathways. ### Parameters #### Path Parameters - **token** (string) - Required - The token associated with the data result - analysis Web-Service is token based, so for every analysis request a TOKEN is associated to the result - **pathways** (string) - Required - The pathways stable identifier (stId - provided in the analysis result for each pathway) - **resource** (string) - Optional - The resource to sort TOTAL, UNIPORT, ENSEMBLE, CHEMBI, IUPHAR, MIRBASE, NCBI_PROTEIN, EMBL, COMPOUND, PUBCEM_COMPOUND ### Returns Json list object ``` -------------------------------- ### Retrieve Found Entities as DataFrame Source: https://context7.com/reactome/reactome2py/llms.txt Fetches all entities from a query that were found in Reactome pathways. Requires an analysis token and specifies the resource to query. ```python from reactome2py import analysis token = 'MjAyMzA1MTUxMTM3NjdfMQ==' df = analysis.found_entities(token=token, resource='TOTAL') print(df.head()) ``` -------------------------------- ### import_json Source: https://github.com/reactome/reactome2py/blob/main/docs/analysis.html Imports JSON data into the analysis service. The data should be in the format expected by the /#/download/{token}/result.json endpoint. The input file can be gzipped. ```APIDOC ## import_json ### Description Imports the posted json into the service. The accepted format is the same as provided by the method /#/download/{token}/result.json. Note: The provided file can be gzipped. ### Parameters #### Request Body - **input_json** (string) - Required - Identifiers to analyse followed by their expression (when applies) in json format in string ### Returns File or json object containing data on pathway, entities, statistics, etc. found in analysis overlap ``` -------------------------------- ### reactome2py.content.search_diagram_pathway_flag Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Searches for pathways with diagram flags. ```APIDOC ## search_diagram_pathway_flag() ### Description Searches for pathways that have specific diagram flags. Specific search parameters and return types are not detailed in the source. ### Method GET ### Endpoint /search/diagram/pathway_flag ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### import_url Source: https://github.com/reactome/reactome2py/blob/main/docs/analysis.html Imports JSON data from a URL into the analysis service. The data format should match that of the /#/download/{token}/result.json endpoint. The file at the URL can be gzipped. ```APIDOC ## import_url ### Description Imports the json file provided by the posted url into the service. The accepted format is the same as provided by the method /#/download/{token}/result.json. Note: The provided file can be gzipped. ### Parameters #### Request Body - **input_url** (string) - Required - A URL pointing to the json data to be analysed ### Returns File or json object containing data on pathway, entities, statistics, etc. found in analysis overlap ``` -------------------------------- ### reactome2py.content.references Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves reference information. ```APIDOC ## references() ### Description Retrieves reference information. Specific parameters and return types are not detailed in the source. ### Method GET ### Endpoint /references ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### discover Source: https://context7.com/reactome/reactome2py/llms.txt Schema.org dataset object for an event. Generates a schema.org-compliant JSON representation of a Reactome event (pathway or reaction), used primarily by search engines. ```APIDOC ## discover ### Description Generates a schema.org-compliant JSON representation of a Reactome event (pathway or reaction), used primarily by search engines. ### Method `content.discover(id: str) -> dict` ### Parameters * **id** (str) - Required - The Reactome ID of the event (pathway or reaction). ### Response Example ```python from reactome2py import content data = content.discover(id='R-HSA-446203') print(data['name']) # e.g. "Innate Immune System" print(data['@type']) # "Dataset" print(data['description']) ``` ``` -------------------------------- ### Download Pathway Hits as Pandas DataFrame (Python) Source: https://context7.com/reactome/reactome2py/llms.txt Retrieves pathway hits for a given analysis token as a pandas DataFrame or saves them to a CSV file. Requires the 'reactome2py.analysis' module and pandas. Specify the resource to use for retrieval. ```python from reactome2py import analysis token = 'MjAyMzA1MTUxMTM3NjdfMQ==' df = analysis.pathway2df(token=token, resource='TOTAL') print(df.columns.tolist()) # ['Pathway identifier', 'Pathway name', '#Entities found', '#Entities total', ...] print(df.head()) # Save to CSV analysis.pathway2df(token=token, path='/results/', file='pathways.csv', save=True) ``` -------------------------------- ### Retrieve Event Ancestor Paths Source: https://context7.com/reactome/reactome2py/llms.txt Fetches all paths from a given event up to the top-level pathways in the Reactome hierarchy. Returns a list of lists, where each inner list represents a path. ```python from reactome2py import content ancestors = content.event_ancestors(id='R-HSA-5673001') # Returns list of lists (each list is one path to top-level) for path in ancestors: print(' -> '.join([e['displayName'] for e in path])) ``` -------------------------------- ### reactome2py.content.pathways_low_diagram Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves pathways with low-level diagram information. ```APIDOC ## pathways_low_diagram() ### Description Retrieves pathways that have associated low-level diagram information. Specific parameters and return types are not detailed in the source. ### Method GET ### Endpoint /pathways/low/diagram ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### Full-Text Search Reactome Knowledgebase Source: https://context7.com/reactome/reactome2py/llms.txt Performs a Solr-backed full-text search across the Reactome knowledgebase with faceting and filtering support. Allows specifying query terms, species, types, and result clustering. ```python from reactome2py import content results = content.search_query( query='Biological oxidations', species=['Homo sapiens'], types=['Pathway'], cluster=True, rows=10 ) for entry in results['results'][0]['entries'][:3]: print(entry['stId'], entry['name']) ``` -------------------------------- ### Import necessary libraries Source: https://github.com/reactome/reactome2py/blob/main/demo/microbiologist-clinician.ipynb Imports the required modules from the reactome2py library and other standard Python libraries for analysis and file operations. ```python from reactome2py import content, analysis import pprint import webbrowser import itertools import os ``` -------------------------------- ### pathways_top_level Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Retrieves the list of all top-level pathways for a specified species. ```APIDOC ## pathways_top_level ### Description Retrieves the list of top level pathways for the given species. ### Parameters * **species** (string, optional) - Specifies the species by the taxonomy identifier (eg: 9606) or species name (eg: ‘Homo+sapiens’). Defaults to '9606'. ### Returns Json list object of all Reactome top level pathways. ``` -------------------------------- ### Generate Schema.org Dataset Object for Event Source: https://context7.com/reactome/reactome2py/llms.txt Generates a schema.org-compliant JSON representation of a Reactome event (pathway or reaction). Used by search engines. Requires an event ID. ```python from reactome2py import content data = content.discover(id='R-HSA-446203') print(data['name']) # e.g. "Innate Immune System" print(data['@type']) # "Dataset" print(data['description']) ``` -------------------------------- ### reactome2py.content.search_diagram Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Searches for diagrams. ```APIDOC ## search_diagram() ### Description Searches for diagrams within Reactome. Specific search parameters and return types are not detailed in the source. ### Method GET ### Endpoint /search/diagram ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### gene_mappings Source: https://context7.com/reactome/reactome2py/llms.txt Reactome pathway-to-gene mappings (GMT). ```APIDOC ## gene_mappings ### Description Downloads and parses the Reactome GMT file, returning a list of dictionaries mapping each pathway to its associated HGNC gene symbols. ### Method `fiviz.gene_mappings()` ### Request Example ```python from reactome2py import fiviz mappings = fiviz.gene_mappings() # Each entry: {'name': 'Pathway Name', 'stId': 'R-HSA-XXXX', 'genes': ['GENE1', 'GENE2', ...]} print(mappings[0]) # {'name': 'Apoptosis', 'stId': 'R-HSA-109581', 'genes': ['CASP3', 'CASP8', ...]}` # Build a lookup: pathway stId -> gene list pathway_genes = {m['stId']: m['genes'] for m in mappings} print(pathway_genes['R-HSA-109581'][:5]) ``` ``` -------------------------------- ### reactome2py.content.schema Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves schema information. ```APIDOC ## schema() ### Description Retrieves schema information for Reactome data. Specific parameters and return types are not detailed in the source. ### Method GET ### Endpoint /schema ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### search_query Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Performs a Solr query on the Reactome knowledgebase, with options for pagination, filtering by species, types, compartments, keywords, and clustering. ```APIDOC ## search_query ### Description This method performs a Solr query on the Reactome knowledgebase. Results can be provided in a paginated format. ### Parameters * **query** (string) - term to search * **species** (list) - list of species - python list of strings * **types** (list) - Types to filter by - python list of strings * **compartments** (list) - Compartments - python list of strings * **keywords** (list) - Keywords - python list of strings * **cluster** (boolean) - Cluster results * **start** (any) - Start row * **rows** (any) - number of rows to include ### Returns Json dictionary object ``` -------------------------------- ### URL-Based Pathway Enrichment Analysis (Python) Source: https://context7.com/reactome/reactome2py/llms.txt Submits identifiers from a URL for pathway enrichment analysis using the 'reactome2py.analysis' module. Requires the 'reactome2py.analysis' module. Specify the external URL containing the identifiers. ```python from reactome2py import analysis result = analysis.identifiers_url( external_url='https://example.com/my_gene_list.txt', interactors=False, species='Homo Sapiens', p_value=0.05 ) print(result['summary']['token']) ``` -------------------------------- ### export_event Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Exports a given pathway or reaction to SBGN or SBML format. ```APIDOC ## export_event ### Description Exports a given pathway or reaction to the format requested (SBGN or SBML). ### Parameters * **id** (string) - Required - DbId or StId of the requested pathway or reaction. * **format** (string) - Required - 'sbgn' or 'sbml'. * **file** (string) - Optional - Name of the file. Defaults to 'report'. * **path** (string) - Optional - Absolute path to save the file. Defaults to an empty string. ``` -------------------------------- ### reactome2py.content.references Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Retrieves a list of all reference entities for a given identifier. ```APIDOC ## reactome2py.content.references ### Description Retrieves a list containing all the reference entities for a given identifier. ### Parameters * **id** (string) - Identifier for a given entity ### Returns Json list object of all ReferenceEntities for a given identifier ``` -------------------------------- ### export_diagram Source: https://context7.com/reactome/reactome2py/llms.txt Export pathway diagram as image. Downloads a pathway diagram in a specified image format (PNG, SVG, JPG, GIF) with optional analysis overlay. ```APIDOC ## export_diagram ### Description Export pathway diagram as image. Downloads a pathway diagram in a specified image format (PNG, SVG, JPG, GIF) with optional analysis overlay. ### Method ```python content.export_diagram( id: str, ext: str, quality: int = None, diagram_profile: str = None, title: bool = None, margin: int = None, file: str = None, path: str = None, token: str = None, analysis_profile: str = None ) ``` ### Parameters #### Path Parameters - **id** (str) - Required - The stable ID of the pathway. - **ext** (str) - Required - The image format (e.g., 'png', 'svg', 'jpg', 'gif'). #### Query Parameters - **quality** (int) - Optional - The quality of the image (1-10). - **diagram_profile** (str) - Optional - The diagram profile to use. - **title** (bool) - Optional - Whether to include the title. - **margin** (int) - Optional - The margin around the diagram. - **file** (str) - Optional - The base filename for the exported image. - **path** (str) - Optional - The directory to save the image in. - **token** (str) - Optional - An analysis token for overlaying analysis results. - **analysis_profile** (str) - Optional - The analysis profile to use for overlay. ### Request Example ```python content.export_diagram( id='R-HSA-177929', ext='png', quality=8, diagram_profile='Modern', title=True, margin=15, file='signal_transduction', path='/diagrams/' ) ``` ### Response This function saves a file and does not return a value. ``` -------------------------------- ### reactome2py.content.discover Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Generates a JSON representation of a Reactome event (reaction or pathway) as a schema.org dataset object, useful for search engine indexing. ```APIDOC ## discover ### Description Generates a JSON representation of a Reactome event (reaction or pathway) as a schema.org dataset object, useful for search engine indexing. ### Parameters * **id** (string) - Optional - An event identifier, such as a pathway stable identifier (stId). Defaults to 'R-HSA-446203'. ### Returns Json dictionary object conforming to schema.org for an Event in Reactome knowledgebase. ``` -------------------------------- ### File-Based Pathway Enrichment Analysis (Python) Source: https://context7.com/reactome/reactome2py/llms.txt Reads identifiers from a local text file for pathway enrichment analysis. Requires the 'reactome2py.analysis' module. Supports projection to map non-human identifiers to Homo sapiens. ```python from reactome2py import analysis # identifiers.txt contains one identifier per line, or expression values: # EGFR 1.5 # BRAF -2.3 # TP53 0.8 result = analysis.identifiers_form( path='/data/identifiers.txt', interactors=False, species='Homo Sapiens', sort_by='ENTITIES_FDR', p_value=0.05, projection=True # project non-human identifiers to Homo sapiens ) print(result['summary']['token']) ``` -------------------------------- ### reactome2py.content.mapping Source: https://github.com/reactome/reactome2py/blob/main/docs/content.html Retrieves pathways or reactions for a given identifier. ```APIDOC ## reactome2py.content.mapping ### Description Retrieves pathways or reactions associated with a given identifier. It can map identifiers to the pathways they participate in or the reactions they are involved in. ### Parameters * **id** (string) - The identifier to be mapped. * **resource** (string) - The resource name for which the identifier is submitted (e.g., 'UniProt'). * **species** (string) - Species for which the result is filtered. Accepts taxonomy id, species name, or dbId. Defaults to '9606' (Homo sapiens) if the identifier points to a chemical and species is not provided. * **by** (string) - Specifies the mapping type: 'pathways' or 'reactions'. ### Returns * Json list object containing the mapped pathways or reactions. ``` -------------------------------- ### List Pathways with Enhanced High-Level Diagrams (EHLDs) Source: https://context7.com/reactome/reactome2py/llms.txt Retrieves a list of top-level pathway stable IDs that have Enhanced High Level Diagrams (EHLDs) available. Useful for identifying pathways with detailed visual representations. ```python from reactome2py import fiviz ehld_list = fiviz.ehld_stids() print(f"{len(ehld_list)} pathways have EHLDs") print(ehld_list[:5]) # ['R-HSA-1430728', 'R-HSA-162582', ...] ``` -------------------------------- ### List Top-Level Pathways for a Species Source: https://context7.com/reactome/reactome2py/llms.txt Retrieves all top-level pathways for a given species taxonomy ID. Useful for exploring the main branches of the Reactome hierarchy for a specific organism. ```python from reactome2py import content pathways = content.pathways_top_level(species='9606') # Homo sapiens for pw in pathways: print(pw['stId'], pw['displayName']) # R-HSA-1430728 Metabolism # R-HSA-162582 Signal Transduction # ... ``` -------------------------------- ### reactome2py.analysis.token Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Handles token-based analysis. ```APIDOC ## token() ### Description Handles token-based analysis operations. Specific parameters and return types are not detailed in the source. ### Method POST ### Endpoint /analysis/token ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### report Source: https://context7.com/reactome/reactome2py/llms.txt Download a PDF analysis report. This function downloads a formatted PDF report for an analysis token, covering the top pathways with diagrams and statistics. ```APIDOC ## report ### Description Downloads a formatted PDF report for an analysis token, covering the top pathways with diagrams and statistics. ### Method `analysis.report(token: str, path: str, file: str, number: int = 25, resource: str = 'TOTAL', diagram_profile: str = 'Modern', analysis_profile: str = 'Standard', species: str = 'Homo sapiens')` ### Parameters * **token** (str) - Required - Analysis token. * **path** (str) - Required - Directory to save the report. * **file** (str) - Required - Filename for the report. * **number** (int) - Optional - Number of top pathways to include. Defaults to 25. * **resource** (str) - Optional - Resource to use for analysis. Defaults to 'TOTAL'. * **diagram_profile** (str) - Optional - Profile for diagram generation. Defaults to 'Modern'. * **analysis_profile** (str) - Optional - Profile for analysis. Defaults to 'Standard'. * **species** (str) - Optional - Species for the report. Defaults to 'Homo sapiens'. ### Response Example ```python from reactome2py import analysis analysis.report( token='MjAyMzA1MTUxMTM3NjdfMQ==', path='/results/', file='pathway_report.pdf', number=25, resource='TOTAL', diagram_profile='Modern', analysis_profile='Standard', species='Homo sapiens' ) ``` ``` -------------------------------- ### compare_species Source: https://github.com/reactome/reactome2py/blob/main/docs/analysis.html Compares Homo sapiens to a specified species to identify pathway over-representation. Allows customization of sorting, filtering, and pagination. ```APIDOC ## compare_species ### Description Compares Homo sapiens to the specified species to identify pathway over-representation. ### Parameters * **species** (string) - The reactome dbId string of the species to compare to. Defaults to '48892' (Mus musculus). * **page_size** (string) - Page size. Defaults to '1'. * **page** (string) - Number of pages. Defaults to '1'. * **sort_by** (string) - How to sort the result. Available filters: TOTAL_ENTITIES, TOTAL_REACTIONS, TOTAL_INTERACTIONS, FOUND_ENTITIES, FOUND_INTERACTIONS, FOUND_REACTIONS, ENTITIES_RATIO, ENTITIES_PVALUE, ENTITIES_FDR, REACTIONS_RATIO. Defaults to 'ENTITIES_FDR'. * **order** (string) - Order ASC or DESC. Defaults to 'ASC'. * **resource** (string) - The resource to sort. Available options: TOTAL, UNIPORT, ENSEMBLE, CHEMBI, IUPHAR, MIRBASE, NCBI_PROTEIN, EMBL, COMPOUND, PUBCEM_COMPOUND. Defaults to 'TOTAL'. * **p_value** (string) - Defines the pValue threshold. Only hit pathways with pValue equal to or below the threshold will be returned. Defaults to '1'. ### Returns Json dictionary object. ``` -------------------------------- ### db_version Source: https://github.com/reactome/reactome2py/blob/main/docs/analysis.html Retrieves the version number of the current Reactome database. ```APIDOC ## db_version ### Description Returns the version number of the current database. ### Returns String of the version number of current database. ``` -------------------------------- ### reactome2py.content.search_query Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Performs a general search query. ```APIDOC ## search_query() ### Description Performs a general search query across Reactome data. Specific search parameters and return types are not detailed in the source. ### Method GET ### Endpoint /search/query ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ``` -------------------------------- ### reactome2py.content.species Source: https://github.com/reactome/reactome2py/blob/main/docs/genindex.html Retrieves information about species. ```APIDOC ## species() ### Description Retrieves information about different species available in Reactome. Specific parameters and return types are not detailed in the source. ### Method GET ### Endpoint /species ### Parameters None specified in source. ### Request Example None specified in source. ### Response #### Success Response (200) Details not specified in source. ```