Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dash-bio docs posts #3409

Merged
merged 33 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
645ee13
Fixed crash when serializing dict with mix of string and int keys
jonmmease Sep 15, 2021
69ddc67
CHANGELOG
jonmmease Sep 15, 2021
21c7f70
Test fix
jonmmease Sep 15, 2021
46a87bd
Remove layout string test
jonmmease Sep 15, 2021
c25e710
Fix deepcopy/pickle tests
jonmmease Sep 15, 2021
ce0ed07
Merge pull request #3386 from plotly/json_remove_sort_keys
nicolaskruchten Sep 16, 2021
65a8c07
dash bio test
olayway Oct 2, 2021
cd3f780
created DashBio posts for graphing-library-docs
olayway Oct 3, 2021
77638d0
rebasing from correct branch
olayway Oct 3, 2021
6a1ee59
corrected jupyter-dash package name in requirements.txt
olayway Oct 3, 2021
f219ebb
docs:bio:volcano: simplified examles, replaced jupyter-dash example w…
smallstepman Oct 18, 2021
93ed64a
docs:bio: volcano - add `no_display=true` to iframe cell
smallstepman Oct 18, 2021
a38ed99
docs:bio: merged clustergram and circos files, replace jupyter-dash w…
smallstepman Oct 18, 2021
f4ff867
docs:bio: remove molecular-visualizations
smallstepman Oct 18, 2021
f78857b
docs:bio: drop documentation for volcanoplot
smallstepman Oct 18, 2021
80e9f35
docs:bio: add manhattanplot documentation
smallstepman Oct 18, 2021
5ed742d
docs:bio: renamed file with alignmentchat docs
smallstepman Oct 18, 2021
44b3c5f
docs:bio: add `no_display=true` to circos iframe example
smallstepman Oct 18, 2021
41cb53c
docs:bio: bar chart for conversion viz + alignment chart iframe url
smallstepman Oct 19, 2021
cdbeb71
Update requirements.txt
smallstepman Oct 19, 2021
df87ed9
Update bio-alignment-chart.md
smallstepman Oct 19, 2021
343b6f9
try to pin down doc deps
nicolaskruchten Oct 20, 2021
b9ab9da
Merge pull request #3429 from plotly/docfix23
nicolaskruchten Oct 20, 2021
e91ba8a
Merge branch 'master' into bio-docs
emmeb Oct 20, 2021
f05a436
Apply suggestions from code review
smallstepman Oct 21, 2021
3269052
fix:change page name: Volcano plot -> Manhattan Plot
smallstepman Oct 21, 2021
1335742
Volcano Plot page name title-cased
smallstepman Oct 21, 2021
05de373
add intro paragraph to Volcano Plot page
smallstepman Oct 21, 2021
39cb3c2
add intro paragraph to Manhattan Plot page
smallstepman Oct 21, 2021
3dbcbae
add intro paragraph to bio-circos.md
smallstepman Oct 21, 2021
a54afe4
add intro paragraph to bio-aligment-chart.md
smallstepman Oct 21, 2021
b039ebd
Update bio-manhattanplot.md
smallstepman Oct 21, 2021
bab1653
rename circos.md to clustergram.md, drop all cicros examples
smallstepman Oct 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file.
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)

### Updated
- The JSON serialization engines no longer sort their keys [#3380](https://github.com/plotly/plotly.py/issues/3380)

## [5.3.1] - 2021-08-31

### Updated
Expand Down
55 changes: 55 additions & 0 deletions doc/python/bio-alignment-chart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
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
---

## Bar Chart for conservation visualization

```python
import plotly.express as px

df = (pd.read_csv('https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/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)
```
115 changes: 115 additions & 0 deletions doc/python/bio-circos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
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
An example of a default Clustergram component without any extra properties.


```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]
)
```

## Circos 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-circos', width='100%', height=630)
```
76 changes: 76 additions & 0 deletions doc/python/bio-manhattanplot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permalink: python/manhattan-plot/
thumbnail: thumbnail/manhttan-plot.png

Copy link
Collaborator

@HammadTheOne HammadTheOne Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note - I can add the thumbnails, which are sourced from our S3 bucket, as long as they have the correct path.

Once we know which ones we want to add to begin with, feel free to send me the thumbnails and I can upload them so that they're displayed on the docs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HammadTheOne we've dumped all image files here

all_static/images/alignment_chart.png 
all_static/images/circos.png 
all_static/images/clustergram.png 
all_static/images/molecule_3d_viewer.png 
all_static/images/volcano_plot.png 

---

## Manhattan Plot

An example of a default ManhattanPlot component without any extra properties.

```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)
```
79 changes: 79 additions & 0 deletions doc/python/bio-volcano-plot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
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
An example of a default VolcanoPlot component without any extra properties.


```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)
```
2 changes: 2 additions & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plotly==5.3.1
jupytext==1.1.1
jupyter-client<7
jupyter
notebook
pandas==1.0.3
Expand Down Expand Up @@ -32,3 +33,4 @@ pooch
wget
nbconvert==5.6.1
orjson
dash-bio
6 changes: 3 additions & 3 deletions packages/python/plotly/plotly/io/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def to_json_plotly(plotly_object, pretty=False, engine=None):
# Dump to a JSON string and return
# --------------------------------
if engine == "json":
opts = {"sort_keys": True}
opts = {}
if pretty:
opts["indent"] = 2
else:
Expand All @@ -124,7 +124,7 @@ def to_json_plotly(plotly_object, pretty=False, engine=None):
return json.dumps(plotly_object, cls=PlotlyJSONEncoder, **opts)
elif engine == "orjson":
JsonConfig.validate_orjson()
opts = orjson.OPT_SORT_KEYS | orjson.OPT_SERIALIZE_NUMPY
opts = orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY

if pretty:
opts |= orjson.OPT_INDENT_2
Expand Down Expand Up @@ -462,7 +462,7 @@ def clean_to_json_compatible(obj, **kwargs):
return obj

if isinstance(obj, dict):
return {str(k): clean_to_json_compatible(v, **kwargs) for k, v in obj.items()}
return {k: clean_to_json_compatible(v, **kwargs) for k, v in obj.items()}
elif isinstance(obj, (list, tuple)):
if obj:
# Must process list recursively even though it may be slow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def test_move_nested_trace_properties(self):
},
)

self.assertEqual(pio.to_json(templated_fig), pio.to_json(expected_fig))
self.assertEqual(templated_fig.to_dict(), expected_fig.to_dict())

def test_move_nested_trace_properties_existing_traces(self):
fig = go.Figure(
Expand Down
Loading