Overview¶
by Kozo Nishida and Alexander Pico
pywikipathways 0.0.2
WikiPathways is a well-known repository for biological pathways that provides unique tools to the research community for content creation, editing and utilization [1].
Python is a powerful programming language and environment for statistical and exploratory data analysis.
pywikipathways leverages the WikiPathways API to communicate between Python and WikiPathways, allowing any pathway to be queried, interrogated and downloaded in both data and image formats. Queries are typically performed based on “Xrefs”, standardized identifiers for genes, proteins and metabolites. Once you can identified a pathway, you can use the WPID (WikiPathways identifier) to make additional queries.
Prerequisites¶
All you need is this pywikipathways package! To install pywikipathways, run
[ ]:
!pip install pywikipathways
[4]:
import pywikipathways as pwpw
Getting started¶
Lets first get oriented with what WikiPathways contains. For example, here’s how you check to see which species are currently supported by WikiPathways:
[5]:
pwpw.list_organisms()
[5]:
['Unspecified',
'Acetobacterium woodii',
'Anopheles gambiae',
'Arabidopsis thaliana',
'Bacillus subtilis',
'Beta vulgaris',
'Bos taurus',
'Caenorhabditis elegans',
'Canis familiaris',
'Clostridium thermocellum',
'Danio rerio',
'Daphnia magna',
'Daphnia pulex',
'Drosophila melanogaster',
'Escherichia coli',
'Equus caballus',
'Gallus gallus',
'Glycine max',
'Gibberella zeae',
'Homo sapiens',
'Hordeum vulgare',
'Mus musculus',
'Mycobacterium tuberculosis',
'Oryza sativa',
'Pan troglodytes',
'Populus trichocarpa',
'Rattus norvegicus',
'Saccharomyces cerevisiae',
'Solanum lycopersicum',
'Sus scrofa',
'Vitis vinifera',
'Xenopus tropicalis',
'Zea mays',
'Plasmodium falciparum',
'Brassica napus']
You should see 30 or more species listed. This list is useful for subsequent queries that take an organism argument, to avoid misspelling.
Next, let’s see how many pathways are available for Human:
[6]:
hs_pathways = pwpw.list_pathways('Homo sapiens')
[7]:
hs_pathways
[7]:
id | url | name | species | revision | |
---|---|---|---|---|---|
0 | WP100 | https://www.wikipathways.org/index.php/Pathway... | Glutathione metabolism | Homo sapiens | 107114 |
1 | WP106 | https://www.wikipathways.org/index.php/Pathway... | Alanine and aspartate metabolism | Homo sapiens | 114258 |
2 | WP107 | https://www.wikipathways.org/index.php/Pathway... | Translation factors | Homo sapiens | 117851 |
3 | WP111 | https://www.wikipathways.org/index.php/Pathway... | Electron transport chain: OXPHOS system in mit... | Homo sapiens | 117097 |
4 | WP117 | https://www.wikipathways.org/index.php/Pathway... | GPCRs, other | Homo sapiens | 117743 |
... | ... | ... | ... | ... | ... |
1327 | WP734 | https://www.wikipathways.org/index.php/Pathway... | Serotonin receptor 4/6/7 and NR3C signaling | Homo sapiens | 117826 |
1328 | WP75 | https://www.wikipathways.org/index.php/Pathway... | Toll-like receptor signaling pathway | Homo sapiens | 119233 |
1329 | WP78 | https://www.wikipathways.org/index.php/Pathway... | TCA cycle (aka Krebs or citric acid cycle) | Homo sapiens | 119082 |
1330 | WP80 | https://www.wikipathways.org/index.php/Pathway... | Nucleotide GPCRs | Homo sapiens | 111167 |
1331 | WP98 | https://www.wikipathways.org/index.php/Pathway... | Prostaglandin synthesis and regulation | Homo sapiens | 117172 |
1332 rows × 5 columns
Yikes! That is a lot of information. Let’s break that down a bit:
[8]:
help(pwpw.list_pathways)
Help on function list_pathways in module pywikipathways.list_pathways:
list_pathways(organism='')
List Pathways
Retrieve list of pathways per species, including WPID, name,
species, URL and latest revision number.
Args:
organism (str): A particular species.
Returns:
pandas.DataFrame: A dataframe of pathway information.
Examples:
>>> list_pathways('Mus musculus')
id url name species revision
0 WP1 https://www.wikipathways.org/index.php/Pathway... Statin pathway Mus musculus 117947
1 WP10 https://www.wikipathways.org/index.php/Pathway... IL-9 signaling pathway Mus musculus 117067
2 WP103 https://www.wikipathways.org/index.php/Pathway... Cholesterol biosynthesis Mus musculus 116834
3 WP108 https://www.wikipathways.org/index.php/Pathway... Selenium metabolism / selenoproteins Mus musculus 117940
4 WP113 https://www.wikipathways.org/index.php/Pathway... TGF-beta signaling pathway Mus musculus 116497
... ... ... ... ... ...
230 WP79 https://www.wikipathways.org/index.php/Pathway... Tryptophan metabolism Mus musculus 104913
231 WP85 https://www.wikipathways.org/index.php/Pathway... Focal adhesion Mus musculus 116710
232 WP87 https://www.wikipathways.org/index.php/Pathway... Nucleotide metabolism Mus musculus 116529
233 WP88 https://www.wikipathways.org/index.php/Pathway... Toll-like receptor signaling Mus musculus 116521
234 WP93 https://www.wikipathways.org/index.php/Pathway... IL-4 signaling pathway Mus musculus 117991
235 rows × 5 columns
[9]:
hs_pathways.shape
[9]:
(1332, 5)
Ok. The help docs tell us that for each Human pathway we are getting a lot of information. A pandas.DataFrame.shape might be all you really want to know. Or if you’re interested in just one particular piece of information, check out these functions:
[10]:
help(pwpw.list_pathway_ids)
Help on function list_pathway_ids in module pywikipathways.list_pathways:
list_pathway_ids(organism='')
List Pathway WPIDs
Retrieve list of pathway WPIDs per species.
Basically returns a subset of list_pathways result.
Args:
organism (str): A particular species.
Returns:
pandas.Series: A series of WPIDs.
Examples:
>>> list_pathway_ids('Mus musculus')
0 WP1
1 WP10
2 WP103
3 WP108
4 WP113
...
230 WP79
231 WP85
232 WP87
233 WP88
234 WP93
Name: id, Length: 235, dtype: object
[11]:
help(pwpw.list_pathway_names)
Help on function list_pathway_names in module pywikipathways.list_pathways:
list_pathway_names(organism='')
List Pathway Names
Retrieve list of pathway names per species.
Basically returns a subset of list_pathways result.
Args:
organism (str): A particular species.
Returns:
pandas.Series: A series of names.
Examples:
>>> list_pathway_names('Mus musculus')
0 Statin pathway
1 IL-9 signaling pathway
2 Cholesterol biosynthesis
3 Selenium metabolism / selenoproteins
4 TGF-beta signaling pathway
...
230 Tryptophan metabolism
231 Focal adhesion
232 Nucleotide metabolism
233 Toll-like receptor signaling
234 IL-4 signaling pathway
Name: name, Length: 235, dtype: object
[12]:
help(pwpw.list_pathway_urls)
Help on function list_pathway_urls in module pywikipathways.list_pathways:
list_pathway_urls(organism='')
List Pathway URLs
Retrieve list of pathway URLs per species.
Basically returns a subset of list_pathways result.
Args:
organism (str): A particular species.
Returns:
pandas.Series: A series of URLs.
Examples:
>>> list_pathway_urls('Mus musculus')
0 https://www.wikipathways.org/index.php/Pathway...
1 https://www.wikipathways.org/index.php/Pathway...
2 https://www.wikipathways.org/index.php/Pathway...
3 https://www.wikipathways.org/index.php/Pathway...
4 https://www.wikipathways.org/index.php/Pathway...
...
230 https://www.wikipathways.org/index.php/Pathway...
231 https://www.wikipathways.org/index.php/Pathway...
232 https://www.wikipathways.org/index.php/Pathway...
233 https://www.wikipathways.org/index.php/Pathway...
234 https://www.wikipathways.org/index.php/Pathway...
Name: url, Length: 235, dtype: object
These return simple lists containing just a particular piece of information for each pathway result.
Finally, there’s another way to find pathways of interest: by Xref. An Xref is simply a standardized identifier form an official source. WikiPathways relies on BridgeDb [2] to provide dozens of Xref sources for genes, proteins and metabolites. See the full list at https://github.com/bridgedb/datasources/blob/main/datasources.tsv
With pywikipathways, the approach is simple. Take a supported identifier for a molecule of interest, e.g., an official gene symbol from HGNC, “TNF” and check the system code for the datasource, e.g., HGNC = H (this comes from the second column in the datasources.txt table linked to above), and then form your query:
[13]:
tnf_pathways = pwpw.find_pathways_by_xref('TNF','H')
[14]:
tnf_pathways
[14]:
score | id | url | name | species | revision | |
---|---|---|---|---|---|---|
0 | 0.38982576 | WP5071 | https://www.wikipathways.org/index.php/Pathway... | PPAR-gamma pathway | Homo sapiens | 116510 |
1 | 0.38982576 | WP5073 | https://www.wikipathways.org/index.php/Pathway... | PPAR Beta/Delta pathway | Homo sapiens | 115726 |
2 | 0.38982576 | WP5115 | https://www.wikipathways.org/index.php/Pathway... | Network map of SARS-CoV-2 signaling pathway | Homo sapiens | 119638 |
3 | 0.27564844 | WP176 | https://www.wikipathways.org/index.php/Pathway... | Folate metabolism | Homo sapiens | 118404 |
4 | 0.27564844 | WP2328 | https://www.wikipathways.org/index.php/Pathway... | Allograft Rejection | Homo sapiens | 106557 |
... | ... | ... | ... | ... | ... | ... |
80 | 0.27564844 | WP5088 | https://www.wikipathways.org/index.php/Pathway... | Prostaglandin signaling | Homo sapiens | 119639 |
81 | 0.27564844 | WP5093 | https://www.wikipathways.org/index.php/Pathway... | Opioid receptor pathway annotation | Homo sapiens | 119684 |
82 | 0.27564844 | WP5094 | https://www.wikipathways.org/index.php/Pathway... | Orexin receptor pathway | Homo sapiens | 119637 |
83 | 0.27564844 | WP5098 | https://www.wikipathways.org/index.php/Pathway... | T-cell activation SARS-CoV-2 | Homo sapiens | 119538 |
84 | 0.27564844 | WP2513 | https://www.wikipathways.org/index.php/Pathway... | Nanoparticle triggered regulated necrosis | Homo sapiens | 119820 |
85 rows × 6 columns
Ack! That’s a lot of information. We provide not only the pathway information, but also the search result score in case you want to rank results, etc. Again, if all you’re interested in is WPIDs, names or URLs, then there are these handy alternatives that will just return simple lists:
[15]:
help(pwpw.find_pathway_ids_by_xref)
Help on function find_pathway_ids_by_xref in module pywikipathways.find_pathways_by_xref:
find_pathway_ids_by_xref(identifier, system_code)
Find Pathway WPIDs By Xref
Retrieve list of pathway WPIDs containing the query Xref by
identifier and system code.
Note:
there will be multiple listings of the same pathway if the
Xref is present mutiple times.
Args:
identifier (str): The official ID specified by a data source or system
system_code (str): The BridgeDb code associated with the data source or system,
e.g., En (Ensembl), L (Entrez), Ch (HMDB), etc. See column two of
https://github.com/bridgedb/datasources/blob/main/datasources.tsv.
Returns:
pandas.Series: A series of WPIDs.
Examples:
>>> find_pathway_ids_by_xref('ENSG00000232810','En')
0 WP2813
1 WP4341
2 WP4673
3 WP1584
4 WP2571
...
82 WP5055
83 WP5093
84 WP5115
85 WP5094
86 WP5098
Name: id, Length: 87, dtype: object
[16]:
help(pwpw.find_pathway_names_by_xref)
Help on function find_pathway_names_by_xref in module pywikipathways.find_pathways_by_xref:
find_pathway_names_by_xref(identifier, system_code)
Find Pathway Names By Xref
Retrieve list of pathway names containing the query Xref by
identifier and system code.
Note:
there will be multiple listings of the same pathway if the
Xref is present mutiple times.
Args:
identifier (str): The official ID specified by a data source or system
system_code (str): The BridgeDb code associated with the data source or system,
e.g., En (Ensembl), L (Entrez), Ch (HMDB), etc. See column two of
https://github.com/bridgedb/datasources/blob/main/datasources.tsv.
Returns:
pandas.Series: A series of names.
Examples:
>>> find_pathway_names_by_xref('ENSG00000232810','En')
0 Mammary gland development pathway - Embryonic ...
1 Non-genomic actions of 1,25 dihydroxyvitamin D3
2 Male infertility
3 Type II diabetes mellitus
4 Polycystic kidney disease pathway
...
82 Burn wound healing
83 Opioid receptor pathway annotation
84 Network map of SARS-CoV-2 signaling pathway
85 Orexin receptor pathway
86 T-cell activation SARS-CoV-2
Name: name, Length: 87, dtype: object
[17]:
help(pwpw.find_pathway_urls_by_xref)
Help on function find_pathway_urls_by_xref in module pywikipathways.find_pathways_by_xref:
find_pathway_urls_by_xref(identifier, system_code)
Find Pathway URLs By Xref
Retrieve list of pathway URLs containing the query Xref by
identifier and system code.
Note:
there will be multiple listings of the same pathway if the
Xref is present mutiple times.
Args:
identifier (str): The official ID specified by a data source or system
system_code (str): The BridgeDb code associated with the data source or system,
e.g., En (Ensembl), L (Entrez), Ch (HMDB), etc. See column two of
https://github.com/bridgedb/datasources/blob/main/datasources.tsv.
Returns:
pandas.Series: A series of URLs.
Examples:
>>> find_pathway_urls_by_xref('ENSG00000232810','En')
0 https://www.wikipathways.org/index.php/Pathway...
1 https://www.wikipathways.org/index.php/Pathway...
2 https://www.wikipathways.org/index.php/Pathway...
3 https://www.wikipathways.org/index.php/Pathway...
4 https://www.wikipathways.org/index.php/Pathway...
...
82 https://www.wikipathways.org/index.php/Pathway...
83 https://www.wikipathways.org/index.php/Pathway...
84 https://www.wikipathways.org/index.php/Pathway...
85 https://www.wikipathways.org/index.php/Pathway...
86 https://www.wikipathways.org/index.php/Pathway...
Name: url, Length: 87, dtype: object
Be aware: a simple len function may be misleading here since a given pathway will be listed multiple times if the Xref is present mutiple times.
My favorite pathways¶
At this point, we should have one or more pathways identified from the queries above. Let’s assume we identified ‘WP554’, the Ace Inhibitor Pathway (https://wikipathways.org/instance/WP554). We will use its WPID (WP554) in subsequent queries.
First off, we can get information about the pathway (if we didn’t already collect it above):
[18]:
pwpw.get_pathway_info('WP554')
[18]:
{'id': 'WP554',
'url': 'https://www.wikipathways.org/index.php/Pathway:WP554',
'name': 'ACE inhibitor pathway',
'species': 'Homo sapiens',
'revision': '118788'}
Next, we can get all the Xrefs contained in the pathway, mapped to a datasource of our choice. How convenient! We use the same system codes as described above. So, for example, if we want all the genes listed as Entrez Genes from this pathway:
[19]:
pwpw.get_xref_list('WP554','L')
[19]:
['10159',
'1215',
'1511',
'1585',
'1636',
'183',
'185',
'186',
'3827',
'4142',
'4306',
'4846',
'59272',
'5972',
'623',
'624',
'7040']
Alternatively, if we want them listed as Ensembl IDs instead, then…
[20]:
pwpw.get_xref_list('WP554', 'En')
[20]:
['ENSG00000092009',
'ENSG00000100448',
'ENSG00000100739',
'ENSG00000105329',
'ENSG00000113889',
'ENSG00000130234',
'ENSG00000130368',
'ENSG00000135744',
'ENSG00000143839',
'ENSG00000144891',
'ENSG00000151623',
'ENSG00000159640',
'ENSG00000164867',
'ENSG00000168398',
'ENSG00000179142',
'ENSG00000180772',
'ENSG00000182220']
And, if we want the metabolites, drugs and other small molecules associated with the pathways, then we’d simply provide the system code of a chemical database, e.g., Ch (HMBD), Ce (ChEBI) or Cs (Chemspider):
[21]:
pwpw.get_xref_list('WP554', 'Ch')
[21]:
['HMDB0000016',
'HMDB0000037',
'HMDB0000464',
'HMDB0001035',
'HMDB00016',
'HMDB00037',
'HMDB0004246',
'HMDB00464',
'HMDB0061196',
'HMDB01035',
'HMDB04246',
'HMDB61196']
[22]:
pwpw.get_xref_list('WP554', 'Ce')
[22]:
['16973',
'2718',
'2719',
'27584',
'29108',
'3165',
'35457',
'55438',
'80128',
'80129',
'CHEBI:16973',
'CHEBI:2718',
'CHEBI:2719',
'CHEBI:27584',
'CHEBI:29108',
'CHEBI:3165',
'CHEBI:35457',
'CHEBI:55438',
'CHEBI:80128',
'CHEBI:80129']
[23]:
pwpw.get_xref_list('WP554', 'Cs')
[23]:
['102770', '110354', '150504', '23150106', '24774738', '266', '388341', '5932']
It’s that easy!
Give me more¶
We also provide methods for retrieving pathways as data files and as images. The native file format for WikiPathways is GPML, a custom XML specification. You can retrieve this format by…
[24]:
gpml = pwpw.get_pathway('WP554')
[26]:
gpml[:1000]
[26]:
'<?xml version="1.0" encoding="UTF-8"?>\n<Pathway xmlns="http://pathvisio.org/GPML/2013a" Name="ACE inhibitor pathway" Organism="Homo sapiens">\n <Comment Source="WikiPathways-description">The core of this pathway was elucidated over a century ago and involves the conversion of angiotensinogen to angiotensin I (Ang I) by renin, its subsequent conversion to angiotensin II (Ang II) by angiotensin converting enzyme. Ang II activates the angiotensin II receptor type 1 to induce aldosterone synthesis, increasing water and salt resorption and potassium excretion in the kidney and increasing blood pressure.\n\nSource: PharmGKB (https://www.pharmgkb.org/pathway/PA2023)\n\nProteins on this pathway have targeted assays available via the [https://assays.cancer.gov/available_assays?wp_id=WP554 CPTAC Assay Portal]</Comment>\n <BiopaxRef>b93</BiopaxRef>\n <Graphics BoardWidth="991.0" BoardHeight="651.0"/>\n <DataNode TextLabel="NOS3" GraphId="ab119" Type="GeneProduct">\n <Attribute Key="org.pathvisio.mo'
WikiPathways also provides a monthly data release archived at http://data.wikipathways.org. The archive includes GPML, GMT and SVG collections by organism and timestamped. There’s a Python function for grabbing files from the archive…
[27]:
pwpw.download_pathway_archive()
organism argument is not specified. Open http://data.wikipathways.org/current/gpml with your web browser and specify the organism.
This will simply print the archive URL so you can look around (in case you don’t know what you are looking for). By default, it prints the latest collection of GPML files. However, if you provide an organism, then it will download that file to your current working directory or specified destpath. For example, here’s how you’d get the latest GMT file for mouse:
[28]:
pwpw.download_pathway_archive(organism="Mus musculus", format="gmt")
[28]:
'wikipathways-20210810-gmt-Mus_musculus.gmt'
And if you might want to specify an archive date so that you can easily share and reproduce your script at any time in the future and get the same result. Remember, new pathways are being added to WikiPathways every month and existing pathways are improved continuously!
[29]:
pwpw.download_pathway_archive(date="20171010", organism="Mus musculus", format="gmt")
[29]:
'wikipathways-20171010-gmt-Mus_musculus.gmt'
References¶
Pico AR, Kelder T, Iersel MP van, Hanspers K, Conklin BR, Evelo C: WikiPathways: Pathway editing for the people. PLoS Biol 2008, 6:e184+.
Iersel M van, Pico A, Kelder T, Gao J, Ho I, Hanspers K, Conklin B, Evelo C: The BridgeDb framework: Standardized access to gene, protein and metabolite identifier mapping services. BMC Bioinformatics 2010, 11:5+.