diff --git a/CHANGELOG.md b/CHANGELOG.md index 376a14adbd..0f8fe8ce64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [next] - ??? +### Added + - dash-bio posts in /doc/python/{alignment-chart.md,circos.md,clustergram.md,molecular-visualizations.md,volacano-plot.md} + ### Fixed - Fixed error when serializing dict with mix of string and non-string keys [#3380](https://github.com/plotly/plotly.py/issues/3380) diff --git a/doc/python/bio-alignment-chart.md b/doc/python/bio-alignment-chart.md new file mode 100644 index 0000000000..5ab71618ba --- /dev/null +++ b/doc/python/bio-alignment-chart.md @@ -0,0 +1,62 @@ +--- +jupyter: + jupytext: + notebook_metadata_filter: all + text_representation: + extension: .md + format_name: markdown + format_version: '1.3' + jupytext_version: 1.13.0 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 + language_info: + codemirror_mode: + name: ipython + version: 3 + file_extension: .py + mimetype: text/x-python + name: python + nbconvert_exporter: python + pygments_lexer: ipython3 + version: 3.9.7 + plotly: + display_as: bio + language: python + layout: base + name: Alignment Chart + order: 1 + page_type: u-guide + permalink: python/alignment-chart/ + thumbnail: thumbnail/alignment-chart.png +--- + +## Alignment Viewer (link to dash alignment section below) + +The Alignment Viewer (MSA) component is used to align multiple genomic or proteomic sequences from a FASTA or Clustal file. Among its extensive set of features, the multiple sequence alignment viewer can display multiple subplots showing gap and conservation info, alongside industry standard colorscale support and consensus sequence. No matter what size your alignment is, Alignment Viewer is able to display your genes or proteins snappily thanks to the underlying WebGL architecture powering the component. You can quickly scroll through your long sequence with a slider or a heatmap overview. + +Note that the AlignmentChart only returns a chart of the sequence, while AlignmentViewer has integrated controls for colorscale, heatmaps, and subplots allowing you to interactively control your sequences. + +## Bar Chart for conservation visualization + +```python +import plotly.express as px +import pandas as pd + +df = (pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/Dash_Bio/Genetic/gene_conservation.csv') + .set_index('0') + .loc[['consensus','conservation']] + .T) + +fig = px.bar(df, labels={ 'index': 'base' }, hover_name='consensus', y='conservation') +fig.show() +``` + +## Alignment Chart in dash_bio + +```python no_display=true +from IPython.display import IFrame +snippet_url = 'https://dash-gallery.plotly.host/python-docs-dash-snippets/' +IFrame(snippet_url + 'bio-alignmentchart', width='100%', height=630) +``` diff --git a/doc/python/bio-clustergram.md b/doc/python/bio-clustergram.md new file mode 100644 index 0000000000..d98b6a5826 --- /dev/null +++ b/doc/python/bio-clustergram.md @@ -0,0 +1,114 @@ +--- +jupyter: + jupytext: + notebook_metadata_filter: all + text_representation: + extension: .md + format_name: markdown + format_version: '1.3' + jupytext_version: 1.13.0 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 + language_info: + codemirror_mode: + name: ipython + version: 3 + file_extension: .py + mimetype: text/x-python + name: python + nbconvert_exporter: python + pygments_lexer: ipython3 + version: 3.9.7 + plotly: + display_as: bio + language: python + layout: base + name: Clustergram + order: 1 + page_type: u-guide + permalink: python/clustergram/ + thumbnail: thumbnail/clustergram.png +--- + +## Default Clustergram +A clustergram is a combination heatmap-dendrogram that is commonly used in gene expression data. The hierarchical clustering that is represented by the dendrograms can be used to identify groups of genes with related expression levels. The Dash Bio Clustergram component is a Python-based component that uses plotly.py to generate a figure. It takes as input a two-dimensional numpy array of floating-point values. Imputation of missing data and computation of hierarchical clustering both occur within the component itself. Clusters that meet or exceed a user-defined threshold of similarity comprise single traces in the corresponding dendrogram, and can be highlighted with annotations. The user can specify additional parameters to customize the metrics and methods used to compute parts of the clustering, such as the pairwise distance between observations and the linkage matrix. + +```python +import pandas as pd +import dash_bio + + +df = pd.read_csv( + 'https://raw.githubusercontent.com/plotly/datasets/master/Dash_Bio/Chromosomal/' + + 'clustergram_brain_cancer.csv', +) + +dash_bio.Clustergram( + data=df, + column_labels=list(df.columns.values), + row_labels=list(df.index), + height=800, + width=700 +) +``` + +## Dendrogram Cluster Colors/Line Widths +Change the colors of the dendrogram traces that are used to represent clusters, and configure their line widths. + + +```python +import pandas as pd +import dash_bio + +df = pd.read_csv( + 'https://raw.githubusercontent.com/plotly/datasets/master/Dash_Bio/Chromosomal/' + + 'clustergram_brain_cancer.csv', +) + +dash_bio.Clustergram( + data=df, + column_labels=list(df.columns.values), + row_labels=list(df.index), + height=800, + width=700, + color_list={ + 'row': ['#636EFA', '#00CC96', '#19D3F3'], + 'col': ['#AB63FA', '#EF553B'], + 'bg': '#506784' + }, + line_width=2 +) +``` + +## Relative Dendrogram Size +Change the relative width and height of, respectively, the row and column dendrograms compared to the width and height of the heatmap. + + +```python +import pandas as pd +import dash_bio + +df = pd.read_csv( + 'https://raw.githubusercontent.com/plotly/datasets/master/Dash_Bio/Chromosomal/' + + 'clustergram_brain_cancer.csv', +) + +dash_bio.Clustergram( + data=df, + column_labels=list(df.columns.values), + row_labels=list(df.index), + height=800, + width=700, + display_ratio=[0.1, 0.7] +) +``` + +## Clustergram with Dash + +```python no_display=true +from IPython.display import IFrame +snippet_url = 'https://dash-gallery.plotly.host/python-docs-dash-snippets/' +IFrame(snippet_url + 'bio-clustergram', width='100%', height=630) +``` diff --git a/doc/python/bio-manhattanplot.md b/doc/python/bio-manhattanplot.md new file mode 100644 index 0000000000..3da262735c --- /dev/null +++ b/doc/python/bio-manhattanplot.md @@ -0,0 +1,75 @@ +--- +jupyter: + celltoolbar: Tags + jupytext: + notebook_metadata_filter: all + text_representation: + extension: .md + format_name: markdown + format_version: '1.3' + jupytext_version: 1.13.0 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 + language_info: + codemirror_mode: + name: ipython + version: 3 + file_extension: .py + mimetype: text/x-python + name: python + nbconvert_exporter: python + pygments_lexer: ipython3 + version: 3.9.7 + plotly: + display_as: bio + language: python + layout: base + name: Manhattan Plot + order: 1 + page_type: u-guide + permalink: python/manhattan-plot/ + thumbnail: thumbnail/manhttan-plot.png +--- + +## Manhattan Plot +ManhattanPlot allows you to visualize genome-wide association studies (GWAS) efficiently. Using WebGL under the hood, you can interactively explore overviews of massive datasets comprising hundreds of thousands of points at once, or take a closer look at a small subset of your data. Hover data and click data are accessible from within the Dash app. + +```python +import pandas as pd +import dash_bio as dashbio + +df = pd.read_csv('https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/manhattan_data.csv') + + +dashbio.ManhattanPlot( + dataframe=df, +) +``` + +## Highlighted points color, and colors of the suggestive line and the genome-wide line. +Change the color of the points that are considered significant. + +```python +import pandas as pd +import dash_bio as dashbio + + +df = pd.read_csv('https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/manhattan_data.csv') + +dashbio.ManhattanPlot( + dataframe=df, + highlight_color='#00FFAA', + suggestiveline_color='#AA00AA', + genomewideline_color='#AA5500' +) +``` + +## ManhattanPlot with Dash + +```python no_display=true +from IPython.display import IFrame +snippet_url = 'https://dash-gallery.plotly.host/python-docs-dash-snippets/' +IFrame(snippet_url + 'bio-manhattanplot', width='100%', height=630) +``` diff --git a/doc/python/bio-volcano-plot.md b/doc/python/bio-volcano-plot.md new file mode 100644 index 0000000000..497d7e3307 --- /dev/null +++ b/doc/python/bio-volcano-plot.md @@ -0,0 +1,78 @@ +--- +jupyter: + celltoolbar: Tags + jupytext: + notebook_metadata_filter: all + text_representation: + extension: .md + format_name: markdown + format_version: '1.3' + jupytext_version: 1.13.0 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 + language_info: + codemirror_mode: + name: ipython + version: 3 + file_extension: .py + mimetype: text/x-python + name: python + nbconvert_exporter: python + pygments_lexer: ipython3 + version: 3.9.7 + plotly: + display_as: bio + language: python + layout: base + name: Volcano Plot + order: 1 + page_type: u-guide + permalink: python/volcano-plot/ + thumbnail: thumbnail/volcano-plot.png +--- + +## VolcanoPlot +Volcano Plot interactively identifies clinically meaningful markers in genomic experiments, i.e., markers that are statistically significant and have an effect size greater than some threshold. Specifically, volcano plots depict the negative log-base-10 p-values plotted against their effect size. + +```python +import pandas as pd +import dash_bio + + +df = pd.read_csv( + 'https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/' + + 'volcano_data1.csv' +) + +dash_bio.VolcanoPlot( + dataframe=df, +) +``` + +## Point Sizes And Line Widths +Change the size of the points on the scatter plot, and the widths of the effect lines and genome-wide line. + + +```python +import pandas as pd +import dash_bio as dashbio + +df = pd.read_csv('https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/volcano_data1.csv') + +dashbio.VolcanoPlot( + dataframe=df, + point_size=10, + effect_size_line_width=4, + genomewideline_width=2 +) +``` + +## VolcanoPlot with Dash + +```python no_display=true +from IPython.display import IFrame +snippet_url = 'https://dash-gallery.plotly.host/python-docs-dash-snippets/' +IFrame(snippet_url + 'bio-volcano', width='100%', height=630) +``` diff --git a/doc/python/getting-started.md b/doc/python/getting-started.md index 9a0d78297e..57216820f8 100644 --- a/doc/python/getting-started.md +++ b/doc/python/getting-started.md @@ -66,9 +66,14 @@ or `conda`: ``` $ conda install -c plotly plotly=5.3.1 ``` - This package contains everything you need to write figures to standalone HTML files. +You'll also likely want `dash` for adding widgets such as sliders, buttons, and dropdowns to your charts (see more below): + +``` +$ pip install dash +``` + > Note: **No internet connection, account, or payment is required to use plotly.py.** Prior to version 4, this library could operate in either an "online" or "offline" mode. The documentation tended to emphasize the online mode, where graphs get published to the Chart Studio web service. In version 4, all "online" functionality was removed from the `plotly` package and is now available as the separate, optional, `chart-studio` package (See below). **plotly.py version 4 is "offline" only, and does not include any functionality for uploading figures or data to cloud services.** @@ -78,7 +83,7 @@ fig = go.Figure(data=go.Bar(y=[2, 3, 1])) fig.write_html('first_figure.html', auto_open=True) ``` -### Plotly chart in Dash +### Plotly charts in Dash [Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`. @@ -106,6 +111,20 @@ or `conda`: $ conda install "jupyterlab>=3" "ipywidgets>=7.6" ``` +You'll ned `jupyter-dash` to add widgets such as sliders, dropdowns, and buttons to Plotly charts in JupyterLab. + +Install [`jupyter-dash`](https://github.com/plotly/jupyter-dash) using `pip`: + +``` +$ pip install jupyter-dash +``` + +or `conda`: + +``` +$ conda install -c conda-forge -c plotly jupyter-dash +``` + These packages contain everything you need to run JupyterLab... ``` diff --git a/doc/requirements.txt b/doc/requirements.txt index f3c0d3ecea..5c6bf05af9 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -33,3 +33,4 @@ pooch wget nbconvert==5.6.1 orjson +dash-bio