Created
February 1, 2013 18:45
-
-
Save widdowquinn/4693207 to your computer and use it in GitHub Desktop.
Example code to generate three renderings of a modified metabolic map, highlighting a specific set of pathways.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import KGML_parser | |
| from KGML_scrape import retrieve_KEGG_pathway | |
| from KGML_vis import KGMLCanvas | |
| # Get list of pathway elements to enhance | |
| glyc_path = retrieve_KEGG_pathway('ko00010') | |
| tca_path = retrieve_KEGG_pathway('ko00020') | |
| enhance_list = [] | |
| for pathway in (glyc_path, tca_path): | |
| for e in pathway.entries.values(): | |
| enhance_list.extend(e.name.split()) | |
| enhance_list = set(enhance_list) | |
| # Get the pathway we want to render, and make all the lines | |
| # that are also in glycolysis or TCA pathways thicker | |
| met_pathway = retrieve_KEGG_pathway('ko01100') | |
| mod_list = [e for e in met_pathway.entries.values() if \ | |
| len(set(e.name.split()).intersection(enhance_list))] | |
| for e in mod_list: | |
| for g in e.graphics: | |
| g.width = 10 | |
| kgml_map = KGMLCanvas(met_pathway, show_maps=True) | |
| kgml_map.draw('ex3_thick.pdf') | |
| # Thin out any lines that aren't in the glycolysis/TCA pathways | |
| mod_list = [e for e in met_pathway.entries.values() if \ | |
| not len(set(e.name.split()).intersection(enhance_list)) \ | |
| and e.type != 'map'] | |
| for e in mod_list: | |
| for g in e.graphics: | |
| g.width = .4 | |
| kgml_map.draw('ex3_thin.pdf') | |
| # Or turn them grey, maybe: | |
| for e in mod_list: | |
| for g in e.graphics: | |
| g.fgcolor = '#CCCCCC' | |
| kgml_map.draw('ex3_grey.pdf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment