{"id":18373531,"url":"https://github.com/shujiahuang/geneview","last_synced_at":"2026-03-15T08:54:00.909Z","repository":{"id":43577249,"uuid":"50284527","full_name":"ShujiaHuang/geneview","owner":"ShujiaHuang","description":"Genomics data visualization in Python by using matplotlib.","archived":false,"fork":false,"pushed_at":"2023-12-27T01:36:44.000Z","size":11303,"stargazers_count":65,"open_issues_count":2,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-19T11:44:28.202Z","etag":null,"topics":["bioinformatics","bioinformatics-tool","data-visualization","genomics-data-visualization","matplotlib","plotting","python","visualization"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShujiaHuang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-24T11:28:08.000Z","updated_at":"2025-05-30T03:30:21.000Z","dependencies_parsed_at":"2022-08-12T10:41:52.190Z","dependency_job_id":"c894d10c-e130-450d-80c4-28414d579212","html_url":"https://github.com/ShujiaHuang/geneview","commit_stats":{"total_commits":348,"total_committers":3,"mean_commits":116.0,"dds":0.008620689655172376,"last_synced_commit":"586e256deb5275c375ff6cb5f306da5eace9694f"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/ShujiaHuang/geneview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShujiaHuang%2Fgeneview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShujiaHuang%2Fgeneview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShujiaHuang%2Fgeneview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShujiaHuang%2Fgeneview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShujiaHuang","download_url":"https://codeload.github.com/ShujiaHuang/geneview/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShujiaHuang%2Fgeneview/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267179128,"owners_count":24048285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bioinformatics","bioinformatics-tool","data-visualization","genomics-data-visualization","matplotlib","plotting","python","visualization"],"created_at":"2024-11-06T00:10:44.407Z","updated_at":"2026-03-15T08:54:00.854Z","avatar_url":"https://github.com/ShujiaHuang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# geneview: A python package for visualizing genomics data\n\n[![PyPI Version](https://img.shields.io/pypi/v/geneview.svg)](https://pypi.org/project/geneview/)\n[![Python](https://img.shields.io/pypi/pyversions/geneview.svg?style=plastic)](https://badge.fury.io/py/geneview)\n![Tests](https://github.com/ShujiaHuang/geneview/workflows/CI/badge.svg)\n[![Code Coverage](https://codecov.io/gh/ShujiaHuang/geneview/branch/master/graph/badge.svg)](https://codecov.io/gh/ShujiaHuang/geneview)\n\n**geneview** is a library for making attractive and informative genomics graphics in Python.\nIt is built on top of [matplotlib](https://matplotlib.org/) and tightly integrated with the PyData \nstack, including support for `numpy` and `pandas` data structures. And now it is actively developed.\n\nSome of the features that geneview offers are:\n\n- High-level abstractions for structuring grids of plots that let you easily build complex visualizations.\n- Functions for visualizing general genomics plots.\n\n\n## Installation\n\nTo install the released version, just do\n\n```bash\npip install geneview\n```\n\nThis command will install `geneview` and all the dependencies.\n\n## Quick start\n\n### **Manhattan** and **Q-Q** plot\n\nWe use a PLINK2.x association output data `gwas.csv` which\nis in [geneview-data](https://github.com/ShujiaHuang/geneview-data) directory, \nas the input for the plots below. Here is the format preview of `gwas`:\n\n|**#CHROM**|**POS**|**ID**|**REF**|**ALT**|**A1**|**TEST**|**OBS_CT**|**BETA**|**SE**|**T_STAT**|**P**|\n|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|\n|chr1|904165|1\\_904165|G|A|A|ADD|282|-0.0908897|0.195476|-0.464967|0.642344|\n|chr1|1563691|1\\_1563691|T|G|G|ADD|271|0.447021|0.422194|1.0588|0.290715|\n|chr1|1707740|1\\_1707740|T|G|G|ADD|283|0.149911|0.161387|0.928888|0.353805|\n|chr1|2284195|1\\_2284195|T|C|C|ADD|275|-0.024704|0.13966|-0.176887|0.859739|\n|chr1|2779043|1\\_2779043|T|C|T|ADD|272|-0.111771|0.139929|-0.79877|0.425182|\n|chr1|2944527|1\\_2944527|G|A|A|ADD|276|-0.054472|0.166038|-0.32807|0.743129|\n|chr1|3803755|1\\_3803755|T|C|T|ADD|283|-0.0392713|0.128528|-0.305547|0.760193|\n|chr1|4121584|1\\_4121584|A|G|G|ADD|279|0.120902|0.127063|0.951511|0.342239|\n|chr1|4170048|1\\_4170048|C|T|T|ADD|280|0.250807|0.143423|1.74873|0.0815274|\n|chr1|4180842|1\\_4180842|C|T|T|ADD|277|0.209195|0.146122|1.43165|0.153469|\n|chr1|6053630|1\\_6053630|T|G|G|ADD|269|-0.210917|0.129069|-1.63414|0.103503|\n|chr1|7569602|1\\_7569602|C|T|C|ADD|281|-0.136834|0.13265|-1.03154|0.303249|\n|chr1|7575666|1\\_7575666|T|C|C|ADD|277|-0.231278|0.159448|-1.45049|0.14815|\n\n#### Manhattan plot with default parameters\n\nThe `manhattanplot()` function in **geneview** takes a data frame with\ncolumns containing the chromosomal name/id, chromosomal position,\nP-value and optionally the name of SNP(e.g. rsID in dbSNP).\n\nBy default, `manhattanplot()` looks for column names corresponding to\nthose outout by the plink2 association results, namely, `#CHROM`,\n`POS`, `P`, and `ID`, although different column names can be\nspecificed by user. Calling `manhattanplot()` function with a data frame\nof GWAS results as the single argument draws a basic manhattan plot,\ndefaulting to a darkblue and lightblue color scheme.\n\n```python\nimport matplotlib.pyplot as plt\nimport geneview as gv\n\n# load data\ndf = gv.load_dataset(\"gwas\")\n# Plot a basic manhattan plot with horizontal xtick labels and the figure will display in screen.\nax = gv.manhattanplot(data=df)\nplt.show()\n```\n\n![manhattan_plot.png](./examples/figures/manhattan_plot.png)\n\nRotate the x-axis tick label by setting `xticklabel_kws` to avoid label\noverlap:\n\n```python\nax = manhattanplot(data=df, xticklabel_kws={\"rotation\": \"vertical\"})\n```\n\n![manhattan_plot.png](./examples/figures/manhattan_plot_xviertical.png)\n\nOr rotate the labels 45 degrees by setting `xticklabel_kws={\"rotation\": 45}`.\n\nWhen run with default parameters, the `manhattanplot()` function draws\nhorizontal lines drawn at $-log_{10}{(1e-5)}$ for \"**suggestive**\"\nassociations and $-log_{10}{(5e-8)}$ for the \"**genome-wide\nsignificant**\" threshold. These can be move to different locations or\nturned off completely with the arguments `suggestiveline` and\n`genomewideline`, respectively.\n\n\n\n```python\nax = manhattanplot(data=df,\n                   suggestiveline=None,  # Turn off suggestiveline\n                   genomewideline=None,  # Turn off genomewideline\n                   xticklabel_kws={\"rotation\": \"vertical\"})\n```\n\n![manhattan_plot_xviertical_noline.png](./examples/figures/manhattan_plot_xviertical_noline.png)\n\nThe behavior of the `manhattanplot` function changes slightly when\nresults from only a single chromosome is used. Here, instead of plotting\nalternating colors and chromosome ID on the x-axis, the SNP\\'s position\non the chromosome is plotted on the x-axis:\n\n```python\n# plot only results of chromosome 8.\nmanhattanplot(data=df, CHR=\"chr8\", xlabel=\"Chromosome 8\")\n```\n\n![manhattan_plot_xviertical_noline.png](./examples/figures/manhattan_plot_chr8.png)\n\n`manhattanplot()` funcion has the ability to highlight SNPs with\nsignificant GWAS signal and annotate the Top SNP, which has the lowest\nP-value:\n\n\n```python\nax = manhattanplot(data=df,\n                   sign_marker_p=1e-6,  # highline the significant SNP with ``sign_marker_color`` color.\n                   is_annotate_topsnp=True,  # annotate the top SNP\n                   xticklabel_kws={\"rotation\": \"vertical\"})\n```\n\n![manhattan_anno_plot.png](./examples/figures/manhattan_plot_chr8.png)\n\nAdditionally, highlighting SNPs of interest can be combined with\nlimiting to a single chromosome to enable \\\"zooming\\\" into a particular\nregion containing SNPs of interest.\n\n![manhattan_anno_plot.png](./examples/figures/manhattan_anno_plot.png)\n\n#### Show a better manhattan plot\nFuther graphical parameters can be passed to the `manhattanplot()` function \nto control thing like plot title, point character, size, colors, etc. \nHere is the example:\n\n```python\nimport matplotlib.pyplot as plt\nimport geneview as gv\n\n# common parameters for plotting\nplt_params = {\n    \"pdf.fonttype\": 42,\n    \"font.sans-serif\": \"Arial\",\n    \"legend.fontsize\": 14,\n    \"axes.titlesize\": 18,\n    \"axes.labelsize\": 16,\n    \"xtick.labelsize\": 14,\n    \"ytick.labelsize\": 14\n}\nplt.rcParams.update(plt_params)\n\n# Create a manhattan plot\nf, ax = plt.subplots(figsize=(12, 4), facecolor=\"w\", edgecolor=\"k\")\nxtick = set([\"chr\" + i for i in list(map(str, range(1, 10))) + [\"11\", \"13\", \"15\", \"18\", \"21\", \"X\"]])\n_ = gv.manhattanplot(data=df,\n                     marker=\".\",\n                     sign_marker_p=1e-6,  # Genome wide significant p-value\n                     sign_marker_color=\"r\",\n                     snp=\"ID\",  # The column name of annotation information for top SNPs.\n\n                     title=\"Test\",\n                     xtick_label_set=xtick,\n                  \n                     xlabel=\"Chromosome\",\n                     ylabel=r\"$-log_{10}{(P)}$\",\n\n                     sign_line_cols=[\"#D62728\", \"#2CA02C\"],\n                     hline_kws={\"linestyle\": \"--\", \"lw\": 1.3},\n\n                     is_annotate_topsnp=True,\n                     ld_block_size=50000,  # 50000 bp\n                     text_kws={\"fontsize\": 12,\n                               \"arrowprops\": dict(arrowstyle=\"-\", color=\"k\", alpha=0.6)},\n                     ax=ax)\n```\n![manhattan.png](./examples/figures/manhattan.png)\n\n\n#### QQ plot with default parameters\n\nThe `qqplot()` function can be used to generate a Q-Q plot to visualize the \ndistribution of association \"P-value\". The `qqplot()` function takes a vector \nof P-values as its the only required argument.\n\n```python\n\nimport matplotlib.pyplot as plt\nimport geneview as gv\n\n# load data\ndf = gv.load_dataset(\"gwas\")\n# Plot a basic manhattan plot with horizontal xtick labels and the figure will display in screen.\nax = gv.qqplot(data=df[\"P\"])\nplt.show()\n\n```\n\n![qq.png](./examples/figures/qq.png)\n\n#### Show a better QQ plot\n\nFuther graphical parameters can be passed to ``qqplot()`` to control the plot \ntitle, axis labels, point characters, colors, points sizes, etc. Here is the \nexample:\n\n```python\nimport matplotlib.pyplot as plt\nimport geneview as gv\n\nf, ax = plt.subplots(figsize=(6, 6), facecolor=\"w\", edgecolor=\"k\")\n_ = gv.qqplot(data=df[\"P\"],\n              marker=\"o\",\n              title=\"Test\",\n              xlabel=r\"Expected $-log_{10}{(P)}$\",\n              ylabel=r\"Observed $-log_{10}{(P)}$\",\n              ax=ax)\n```\n\n- [More tutorials about GWAS](./docs/tutorial/gwas_plot.ipynb)\n\n### Admixture plot\nGenerate **Admixture** plot from the raw admixture output result:\n\n#### simple example for admixtureplot\n\n```python\nimport matplotlib.pyplot as plt\nfrom geneview import load_dataset\nfrom geneview import admixtureplot\n\nf, ax = plt.subplots(1, 1, figsize=(14, 2), facecolor=\"w\", constrained_layout=True, dpi=300)\nadmixtureplot(data=load_dataset(\"admixture_output.Q\"), \n              population_info=load_dataset(\"admixture_population.info\"),\n              ylabel_kws={\"rotation\": 45, \"ha\": \"right\"},\n              ax=ax)\n```\n![admixtureplot](./examples/figures/admixture.png)\n\nor\n\n```python\nimport matplotlib.pyplot as plt\nimport geneview as gv\n\nadmixture_output_fn = gv.load_dataset(\"admixture_output.Q\")\npopulation_group_fn = gv.load_dataset(\"admixture_population.info\")\n\n# define the order for population to plot\npop_group_1kg = [\"KHV\", \"CDX\", \"CHS\", \"CHB\", \"JPT\", \"BEB\", \"STU\", \"ITU\", \"GIH\", \"PJL\", \"FIN\", \n                 \"CEU\", \"GBR\", \"IBS\", \"TSI\", \"PEL\", \"PUR\", \"MXL\", \"CLM\", \"ASW\", \"ACB\", \"GWD\", \n                 \"MSL\", \"YRI\", \"ESN\", \"LWK\"]\n\nf, ax = plt.subplots(1, 1, figsize=(14, 2), facecolor=\"w\", constrained_layout=True, dpi=300)\ngv.popgen.admixtureplot(data=admixture_output_fn, \n                        population_info=population_group_fn,\n                        edgewidth=2.0,\n                        group_order=pop_group_1kg,\n                        shuffle_popsample_kws={\"frac\": 0.5},\n                        ylabel_kws={\"rotation\": 45, \"ha\": \"right\"},\n                        ax=ax)\n```\n\n![admixtureplot](./examples/figures/admixture.png)\n\n- [The format of input files and more details about admixtureplot](./docs/tutorial/admixture.ipynb)\n\n\n### Venn plots\n\n**Venn diagrams for 2, 3, 4, 5, 6 sets.**\n\n![Venn.png](./examples/figures/venn.png)\n\n#### Minimal venn plot example\n\n```python\nimport geneview as gv\n\ntable = {\n    \"Dataset 1\": {\"A\", \"B\", \"D\", \"E\"},\n    \"Dataset 2\": {\"C\", \"F\", \"B\", \"G\"},\n    \"Dataset 3\": {\"J\", \"C\", \"K\"}\n}\nax = gv.venn(table) \n\n```\n\n![venn.png](./examples/figures/venn3.png)\n\n#### Manual adjustment of petal labels\nIf necessary, the labels on the petals (i.e., various intersections in the \nVenn diagram) can be adjusted manually.\n\nFor this, `generate_petal_labels()` can be called first to get the \n`petal_labels` dictionary, which can be modified.\n\nAfter modification, pass petal_labels to functions `venn()`.\n\n```python\nfrom numpy.random import choice\nimport geneview as gv\n\ndataset_dict = {\n    name: set(choice(1000, 250, replace=False))\n    for name in list(\"ABCD\")\n}\n\npetal_labels = gv.generate_petal_labels(dataset_dict.values(), fmt=\"{logic}\\n({percentage:.1f}%)\") \nax = gv.venn(data=petal_labels, names=list(dataset_dict.keys()), legend_use_petal_color=True)\n\n```\n![venn4.png](./examples/figures/venn4.png)\n\n- [More tutorials about venn](./docs/tutorial/venn.ipynb)\n\n## Dependencies\n\n**Geneview** only supports Python 3 and no longer supports Python 2.\n\nInstallation requires [numpy](http://www.numpy.org/), \n[scipy](http://www.scipy.org/), \n[pandas](http://pandas.pydata.org/), and \n[matplotlib](http://matplotlib.org/). \nSome functions will use \n[statsmodels](http://statsmodels.sourceforge.net/).\n\n\nWe need the data structures: `DataFrame` and `Series` in **pandas**. \nIt's easy and worth to learn, click \n[here](http://pda.readthedocs.org/en/latest/chp5.html) to see more detail \ntutorial for these two data type.\n\n## License\n\nReleased under a GPL-3.0 license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshujiahuang%2Fgeneview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshujiahuang%2Fgeneview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshujiahuang%2Fgeneview/lists"}