An example of a default Clustergram component without any extra properties.
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
import pandas as pd
from dash import Dash, html, dcc, Input, Output, callback
import dash_bio as dashbio
app = Dash()
df = pd.read_csv('https://git.io/clustergram_brain_cancer.csv').set_index('ID_REF')
columns = list(df.columns.values)
rows = list(df.index)
app.layout = html.Div([
"Rows to display",
dcc.Dropdown(
id='my-default-clustergram-input',
options=[
{'label': row, 'value': row} for row in list(df.index)
],
value=rows[:10],
multi=True
),
html.Div(id='my-default-clustergram')
])
@callback(
Output('my-default-clustergram', 'children'),
Input('my-default-clustergram-input', 'value')
)
def update_clustergram(rows):
if len(rows) < 2:
return "Please select at least two rows to display."
return dcc.Graph(figure=dashbio.Clustergram(
data=df.loc[rows].values,
column_labels=columns,
row_labels=rows,
color_threshold={
'row': 250,
'col': 700
},
hidden_labels='row',
height=800,
width=700
))
if __name__ == '__main__':
app.run(debug=True)
Change the color scale by specifying values and colors.
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
import pandas as pd
from dash import dcc
import dash_bio as dashbio
df = pd.read_csv('https://git.io/clustergram_brain_cancer.csv').set_index('ID_REF')
columns = list(df.columns.values)
rows = list(df.index)
clustergram = dashbio.Clustergram(
data=df.loc[rows].values,
row_labels=rows,
column_labels=columns,
color_threshold={
'row': 250,
'col': 700
},
height=800,
width=700,
color_map= [
[0.0, '#636EFA'],
[0.25, '#AB63FA'],
[0.5, '#FFFFFF'],
[0.75, '#E763FA'],
[1.0, '#EF553B']
]
)
dcc.Graph(figure=clustergram)
Change the colors of the dendrogram traces that are used to represent clusters, and configure their line widths.
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
import pandas as pd
from dash import dcc
import dash_bio as dashbio
df = pd.read_csv('https://git.io/clustergram_brain_cancer.csv').set_index('ID_REF')
columns = list(df.columns.values)
rows = list(df.index)
clustergram = dashbio.Clustergram(
data=df.loc[rows].values,
row_labels=rows,
column_labels=columns,
color_threshold={
'row': 250,
'col': 700
},
height=800,
width=700,
color_list={
'row': ['#636EFA', '#00CC96', '#19D3F3'],
'col': ['#AB63FA', '#EF553B'],
'bg': '#506784'
},
line_width=2
)
dcc.Graph(figure=clustergram)
Change the relative width and height of, respectively, the row and column dendrograms compared to the width and height of the heatmap.
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
import pandas as pd
from dash import dcc
import dash_bio as dashbio
df = pd.read_csv('https://git.io/clustergram_brain_cancer.csv').set_index('ID_REF')
columns = list(df.columns.values)
rows = list(df.index)
clustergram = dashbio.Clustergram(
data=df.loc[rows].values,
row_labels=rows,
column_labels=columns,
color_threshold={
'row': 250,
'col': 700
},
height=800,
width=700,
display_ratio=[0.1, 0.7]
)
dcc.Graph(figure=clustergram)
Hide the labels along one or both dimensions.
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
import pandas as pd
from dash import dcc
import dash_bio as dashbio
df = pd.read_csv('https://git.io/clustergram_brain_cancer.csv').set_index('ID_REF')
columns = list(df.columns.values)
rows = list(df.index)
clustergram = dashbio.Clustergram(
data=df.loc[rows].values,
row_labels=rows,
column_labels=columns,
color_threshold={
'row': 250,
'col': 700
},
height=800,
width=700,
hidden_labels='row'
)
dcc.Graph(figure=clustergram)
Annotate the clustergram by highlighting specific clusters.
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
import pandas as pd
from dash import dcc
import dash_bio as dashbio
df = pd.read_csv('https://git.io/clustergram_brain_cancer.csv').set_index('ID_REF')
columns = list(df.columns.values)
rows = list(df.index)
clustergram = dashbio.Clustergram(
data=df.loc[rows].values,
row_labels=rows,
column_labels=columns,
color_threshold={
'row': 250,
'col': 700
},
height=800,
width=700,
hidden_labels='row',
col_group_marker=[
{'group': 1, 'annotation': 'largest column cluster', 'color': '#EF553B'}
],
row_group_marker=[
{'group': 2, 'annotation': 'cluster 2', 'color': '#AB63FA'},
{'group': 1, 'annotation': '', 'color': '#19D3F3'}
]
)
dcc.Graph(figure=clustergram)
dash_bio.Clustergram
is a Python-based component,
and may not be available in other languages.