Exemple #1
0

    html.Div("Throw on error:"),
    dcc.RadioItems(
        id='radio-item-throw-on-error',
        options=[
            {'label': "Throw Errors", 'value': "Throw"},
            {'label': "Pass Error", 'value': "Pass"}
        ],
        value = "Pass",
    ),

    html.Div('Here is some latex:'),
    dash_katex.DashKatex(
        id='katex',
        expression="",
        displayMode = True,
        throwOnError = False,
    )
])


@app.callback(Output('katex', 'expression'),
              [Input('input-latex-expression', 'value')])
def updateExpression(value):
    return str(value)


@app.callback(Output('katex', 'displayMode'),
              [Input('radio-item-display-mode', 'value')])
def updateDisplayMode(value):
    return value == "Display"
Exemple #2
0
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_katex

import numpy as np
import plotly.express as px
from scipy import stats

from app import app

layout = html.Div([
    dash_katex.DashKatex(expression=r'''
            f_X(x) = \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)}
            x^{a - 1}(1 - x)^{b - 1}
        ''',
                         displayMode=True),
    dcc.Graph(id='beta_graph'),
    dash_katex.DashKatex(expression=r'a'),
    dcc.Slider(id='beta_a',
               min=0.01,
               max=5,
               marks={x: str(x)
                      for x in range(6)},
               step=0.01,
               value=2,
               tooltip={'placement': 'top'}),
    dash_katex.DashKatex(expression=r'b'),
    dcc.Slider(id='beta_b',
               min=0.01,
               max=5,
Exemple #3
0
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import dash_katex

import numpy as np
import plotly.express as px
from scipy import stats
import math

from app import app

layout = html.Div([
    dash_katex.DashKatex(expression=r'''
            f_X(x) = \frac{\lambda^x e^{-\lambda}}{x!}
        ''',
                         displayMode=True),
    dcc.Graph(id='poisson_graph'),
    dash_katex.DashKatex(expression=r'\lambda'),
    dcc.Slider(id='poisson_rate',
               value=1,
               min=0.01,
               max=10,
               marks={i: str(i)
                      for i in range(11)},
               step=0.01,
               tooltip={'placement': 'top'})
])


@app.callback(Output('poisson_graph', 'figure'), [
Exemple #4
0
         render_latex(expression=r"Dh"),
         dbc.Input(id="Dh-value", type="number", value=1/2)
     ]
 ),
 dbc.FormGroup(
     [
         render_latex(expression=r"\Delta t"),
         dbc.Input(id="Dt-value", type="number", value=0.01),
     ]
 ),
 dbc.FormGroup(
     [
         dbc.Label("Wave-Function Configuration"),
         dash_katex.DashKatex(expression="",
             displayMode=True,
             throwOnError=False,
             id="wf-config-vars"
         ),
         dbc.Input(id="wf-config-vars-value", type="text"),
     ]
 ),
 dbc.FormGroup(
     [
         dbc.Label("Potential Configuration"),
         dash_katex.DashKatex(expression="",
             displayMode=True,
             throwOnError=False,
             id="pot-config-vars"
         ),
         dbc.Input(id="pot-config-vars-value", type="text"),
     ]
Exemple #5
0
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_katex

import plotly.express as px
from scipy import stats

from app import app

layout = html.Div([
    dash_katex.DashKatex(expression=r'''
            f_X(x) = \begin{cases}
            1 - p, \quad &x = 0, \\
            p, \quad &x = 1
            \end{cases}
        ''',
                         displayMode=True),
    dcc.Graph(id='bernoulli_graph'),
    dash_katex.DashKatex(expression=r'p'),
    dcc.Slider(id='bernoulli_p',
               value=0.5,
               min=0,
               max=1,
               marks={p: f'{p:.1f}'
                      for p in [i * 0.1 for i in range(1, 11)]},
               step=0.01,
               tooltip={'placement': 'top'})
])

Exemple #6
0
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_katex

import numpy as np
import plotly.express as px
from scipy import stats

from app import app

layout = html.Div([
    dash_katex.DashKatex(
        expression=r'f_X(x) = \lambda e^{-\lambda x}',
        displayMode=True
    ),
    dcc.Graph(id='exponential_graph'),
    dash_katex.DashKatex(expression=r'\lambda'),
    dcc.Slider(
        id='exponential_rate',
        value=1,
        min=0.01,
        max=10,
        marks={i: str(i) for i in range(11)},
        step=0.01,
        tooltip={'placement': 'top'}
    )
])


@app.callback(
Exemple #7
0
def update_figure_polar(value, value_main_tab, value_analysis, gene_name):
    if gene_name is None:
        raise Exception()
    else:
        if value_main_tab == 'main-tab-2' and value_analysis == 'temporal':
            array_gene_time = np.concatenate(
                (gene_data[gene_name]['rep1'], gene_data[gene_name]['rep2'],
                 gene_data[gene_name]['rep3'][:, [0, 2]]),
                axis=1)

            l_time_reg = []
            for x in range(8):
                l_time_reg.append(
                    LinearRegression.make_time_regression(
                        array_gene_time[x, :], simple=False, predict=True))
            l_time_reg_simple = []
            for x in range(8):
                l_time_reg_simple.append(
                    LinearRegression.make_time_regression(
                        array_gene_time[x, :], simple=True, predict=False))

            #correct value
            value = int(value) - 1

            B, SE, adj_r2, aic, bic, pv, X_pred, Y_pred = l_time_reg[value]
            [mu_1, a_1, b_1] = B.flatten()
            [std_mu_1, std_a_1, std_b_1] = np.diagonal(SE)
            bic_1 = bic
            aic_1 = aic
            r2_1 = adj_r2

            B_simple, SE_simple, adj_r2_simple, aic_simple, bic_simple, pv_simple = l_time_reg_simple[
                value]
            [mu_2] = B_simple.flatten()
            [std_mu_2] = np.diagonal(SE_simple)
            bic_2 = bic_simple
            aic_2 = aic_simple
            r2_2 = adj_r2_simple

            table_model_1 = html.Table([
                html.Tr([
                    Styled_th('Parameter'),
                    Styled_th('Mean'),
                    Styled_th('SE')
                ],
                        style={'background-color': colorscale[5]}),
                html.Tr([
                    Styled_th(dash_katex.DashKatex(expression='\mu'),
                              {'background-color': colorscale[5]}),
                    Styled_th('{:.2e}'.format(mu_1)),
                    Styled_th('{:.2e}'.format(std_mu_1))
                ]),
                html.Tr([
                    Styled_th(dash_katex.DashKatex(expression='a'),
                              {'background-color': colorscale[5]}),
                    Styled_th('{:.2e}'.format(a_1)),
                    Styled_th('{:.2e}'.format(std_a_1))
                ]),
                html.Tr([
                    Styled_th(dash_katex.DashKatex(expression='b'),
                              {'background-color': colorscale[5]}),
                    Styled_th('{:.2e}'.format(b_1)),
                    Styled_th('{:.2e}'.format(std_b_1))
                ])
            ])

            table_model_2 = html.Table([
                html.Tr([
                    Styled_th('Parameter'),
                    Styled_th('Mean'),
                    Styled_th('SE')
                ],
                        style={'background-color': colorscale[5]}),
                html.Tr([
                    Styled_th(dash_katex.DashKatex(expression='\mu'),
                              {'background-color': colorscale[5]}),
                    Styled_th('{:.2e}'.format(mu_2)),
                    Styled_th('{:.2e}'.format(std_mu_2))
                ])
            ])
            table_comparison = html.Table([
                html.Tr([
                    Styled_th('Model'),
                    Styled_th('BIC'),
                    Styled_th('AIC'),
                    Styled_th(
                        dash_katex.DashKatex(expression='\\text{Adj. } R^2'))
                ],
                        style={'background-color': colorscale[5]}),
                html.Tr([
                    Styled_th('Intercept-only',
                              {'background-color': colorscale[5]}),
                    Styled_th('{:.2e}'.format(bic_2)),
                    Styled_th('{:.2e}'.format(aic_2)),
                    Styled_th('{:.2e}'.format(r2_2))
                ]),
                html.Tr([
                    Styled_th('Oscillatory',
                              {'background-color': colorscale[5]}),
                    Styled_th('{:.2e}'.format(bic_1)),
                    Styled_th('{:.2e}'.format(aic_1)),
                    Styled_th('{:.2e}'.format(r2_1))
                ])
            ])

            time_domain = np.concatenate(
                (np.linspace(0, 24, 4, endpoint=False),
                 np.linspace(0, 24, 4, endpoint=False),
                 np.linspace(0, 24, 2, endpoint=False)))
            x = int(value)
            B, SE, adj_r2, aic, bic, pv, X_pred, Y_pred = l_time_reg[x]
            figure = Figures.compute_figure_time_tab_3(
                time_domain, array_gene_time[x, :], X_pred,
                Y_pred)  #, yaxis_type, yaxis_scale)

            return [
                html.Div(children=[
                    html.Div(children=[
                        html.H6('Intercept-only model',
                                style={'textAlign': 'center'}), table_model_2
                    ]),
                    html.Div(children=[
                        html.H6('Oscillatory model',
                                style={'textAlign': 'center'}), table_model_1
                    ]),
                    html.Div(children=[
                        html.H6('Models comparison',
                                style={'textAlign':
                                       'center'}), table_comparison,
                        html.
                        P('P-value associated with the oscillatory model (ANOVA): '
                          + str(pv))
                    ],
                             style={
                                 'display': 'flex',
                                 'flex-direction': 'column'
                             }),
                ],
                         style={
                             'display': 'flex',
                             'flex-direction': 'row',
                             'justify-content': 'space-around',
                             'flex-wrap': 'wrap',
                             'flex-align': 'baseline'
                         }),
                dcc.Graph(id='graph-stat-time',
                          figure=figure,
                          config={
                              'displayModeBar': False,
                              'modeBarButtonsToRemove': [],
                              'displaylogo': False
                          },
                          style={'width': '60vw'})
            ]
        else:
            raise PreventUpdate
Exemple #8
0
def update_figure_fits(value_main_tab, value_analysis,
                       gene_name):  #, yaxis_type, yaxis_scale, value_tab ):
    if gene_name is None:
        raise Exception()
    else:
        if value_main_tab == 'main-tab-2' and value_analysis == 'spatiotemporal':
            array_gene_time = np.concatenate(
                (gene_data[gene_name]['rep1'], gene_data[gene_name]['rep2'],
                 gene_data[gene_name]['rep3'][:, [0, 2]]),
                axis=1)
            fig_3D = Figures.compute_figure_3D_tab_3(
                dic_reg[gene_name],
                array_gene_time)  #, yaxis_type, yaxis_scale)

            selected = dic_reg[gene_name][0]
            pv = dic_reg[gene_name][6]
            set_selected = set(selected)
            if len(selected) == 1:
                str_param = dash_katex.DashKatex(
                    expression='\\text{ } \mu_0\\text{. }')
                str_param2 = 'This corresponds to the flat model.'
            else:
                str_param = dash_katex.DashKatex(
                    expression='\\text{ }' + return_str_list_param(selected) +
                    '\\text{. }')

                if set_selected == set(
                    ['mu0', 'a0', 'b0']) or set_selected == set(
                        ['mu0', 'a0']) or set_selected == set(['mu0', 'b0']):
                    str_param2 = "This corresponds to the rhythmic model."

                elif 'a0' not in selected and 'a1' not in selected and 'a2' not in selected and 'b0' not in selected and 'b1' not in selected and 'b2' not in selected:
                    if 'mu1' in selected or 'mu2' in selected:
                        str_param2 = "This corresponds to the zonated model."
                else:
                    str_param2 = "This corresponds to the rhythmic-zonated model."

            l_time_reg = []
            for x in range(8):
                l_time_reg.append(
                    LinearRegression.make_time_regression(
                        array_gene_time[x, :], simple=False, predict=True))

            fig_polar = Figures.compute_figure_polar_fit_tab_3(
                dic_reg[gene_name], l_time_reg)
            if fig_polar != None:
                return [
                    html.Div(children=[
                        html.P("Retained parameters: "), str_param,
                        html.P(str_param2)
                    ],
                             style={
                                 'display': 'flex',
                                 'justify-content': 'center'
                             }),
                    html.Div(
                        children=[
                            dcc.Graph(id='graph-polar-fit',
                                      figure=fig_polar,
                                      config={
                                          'displayModeBar': False,
                                          'modeBarButtonsToRemove': [],
                                          'displaylogo': False
                                      },
                                      style={'width': '25vw'}),
                            dcc.Graph(id='graph-fit-3D',
                                      figure=fig_3D,
                                      config={
                                          'modeBarButtonsToRemove': [
                                              'sendDataToCloud',
                                              'resetCameraLastSave3d',
                                              'hoverClosest3d', 'zoom3d',
                                              'toImage'
                                          ],
                                          'displaylogo':
                                          False
                                      },
                                      style={
                                          'border-width': '1px',
                                          'border-style': 'solid',
                                          'border-color': '#e8e8e8',
                                          'width': '45vw'
                                      })
                        ],
                        style={
                            'display': 'flex',
                            'flex-direction': 'row',
                            'justify-content': 'space-between',
                            'height': '500px'
                        },
                    ),
                ]
            else:
                return [
                    html.Div(children=[
                        html.P("Retained parameters: "), str_param,
                        html.P(str_param2)
                    ],
                             style={
                                 'display': 'flex',
                                 'justify-content': 'center'
                             }),
                    html.Div(children=[
                        dcc.Graph(id='graph-fit-3D',
                                  figure=fig_3D,
                                  config={
                                      'modeBarButtonsToRemove': [
                                          'sendDataToCloud',
                                          'resetCameraLastSave3d',
                                          'hoverClosest3d', 'zoom3d', 'toImage'
                                      ],
                                      'displaylogo':
                                      False
                                  },
                                  style={
                                      'border-width': '1px',
                                      'border-style': 'solid',
                                      'border-color': '#e8e8e8',
                                      'width': '60vw'
                                  })
                    ],
                             style={
                                 'display': 'flex',
                                 'flex-direction': 'row',
                                 'justify-content': 'space-around'
                             }),
                ]
        else:
            raise PreventUpdate
Exemple #9
0
def update_figure_fits(value, value_main_tab, value_analysis,
                       gene_name):  #yaxis_type, yaxis_scale, value_tab ):
    if gene_name is None:
        raise Exception()
    else:
        if value_main_tab == 'main-tab-2' and value_analysis == 'spatial':
            #correct value
            value = int(value) - 1
            t = int(value)

            array_gene_space = np.concatenate(
                (gene_data[gene_name]['rep1'], gene_data[gene_name]['rep2'],
                 gene_data[gene_name]['rep3']),
                axis=0)

            if t == 0 or t == 2:
                selected, B, SE, adj_r2, aic, bic, pv, X_pred, Y_pred = LinearRegression.make_space_regression(
                    array_gene_space[:, t], predict=True)
            else:
                selected, B, SE, adj_r2, aic, bic, pv, X_pred, Y_pred = LinearRegression.make_space_regression(
                    array_gene_space[:16, t], predict=True)

            if len(selected) == 1:
                str_param = dash_katex.DashKatex(id='katex_a0',
                                                 expression=' \mu_0')
            else:
                str_param = dash_katex.DashKatex(
                    id='katex_other_parameters',
                    expression=return_str_list_param(selected))

            space_domain = np.concatenate(
                (np.linspace(0, 8, 8, endpoint=False),
                 np.linspace(0, 8, 8, endpoint=False),
                 np.linspace(0, 8, 8, endpoint=False)))

            if t == 0 or t == 2:
                figure = Figures.compute_figure_space_tab_3(
                    space_domain, array_gene_space[:, t], X_pred,
                    Y_pred)  #, yaxis_type, yaxis_scale)
            else:
                figure = Figures.compute_figure_space_tab_3(
                    space_domain[:16], array_gene_space[:16, t], X_pred,
                    Y_pred)  #, yaxis_type, yaxis_scale)

            return [
                html.Div(children=[
                    html.P('Retained parameters: '),
                    html.Div(style={'width': '5px'}), str_param
                ],
                         style={
                             'display': 'flex',
                             'justify-content': 'center'
                         }),
                dcc.Graph(id='graph-stat-space',
                          figure=figure,
                          config={
                              'displayModeBar': False,
                              'modeBarButtonsToRemove': [],
                              'displaylogo': False
                          },
                          style={'width': '60vw'})
            ]
        else:
            raise PreventUpdate
Exemple #10
0
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_katex

import numpy as np
import plotly.express as px
from scipy import stats

from app import app

layout = html.Div([
    dash_katex.DashKatex(
        expression=r'f_X(x) = {n \choose x} p^x (1 - p)^{n - x}',
        displayMode=True
    ),
    dcc.Graph(id='binomial_graph'),
    dash_katex.DashKatex(expression=r'n'),
    dcc.Slider(
        id='binomial_n',
        value=10,
        min=0,
        max=50,
        marks={i: str(i) for i in range(51) if i % 10 == 0},
        tooltip={'placement': 'top'}
    ),
    dash_katex.DashKatex(expression=r'p'),
    dcc.Slider(
        id='binomial_p',
        value=0.5,
        min=0,
Exemple #11
0
     html.Div([
         daq.Gauge(
             id='pgpress-status1',
             min=0, max=20,
             units="Torr",
             showCurrentValue=True,
             color={
                 "gradient": True,
                 "ranges": {
                     "green": [0, 7],
                     "yellow": [7, 14],
                     "red": [14, 20]
                 }
             },
         ),
         dash_katex.DashKatex(expression='\\textrm{x } 10^{-4}') # scale
     ])
 ]),
 html.Div(className='indicator-box'+class_theme['dark'], id='thePressure-container', children=[
     html.H4('Blue Vac Ion'), # pressure gauge for blue vac ion
     html.Div([
         daq.Gauge(
             id='thePressure-status1',
             min=0, max=100,
             units="Torr",
             showCurrentValue=True,
             color={
                 "gradient": True,
                 "ranges": {
                     "green": [0, 30],
                     "yellow": [30, 70],
Exemple #12
0
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_katex

import numpy as np
import plotly.express as px
from scipy import stats

from app import app

layout = html.Div([
    dash_katex.DashKatex(expression=r'''
            f_X(x) = \frac{1}{\sqrt{2\pi\sigma^2}}
            \exp\left(-\frac{(x - \mu)^2}{2\sigma^2}\right)
        ''',
                         displayMode=True),
    dcc.Graph(id='normal_graph'),
    dash_katex.DashKatex(expression=r'\mu'),
    dcc.Slider(id='normal_mean',
               value=0,
               min=-5,
               max=5,
               marks={x: str(x)
                      for x in range(-5, 6)},
               step=0.01,
               tooltip={'placement': 'top'}),
    dash_katex.DashKatex(expression=r'\sigma^2'),
    dcc.Slider(id='normal_variance',
               value=1,
               min=0.01,
Exemple #13
0
                       'value': True
                   }, {
                       'label': "False (Inline Mode)",
                       'value': False
                   }]),
    html.Div("Throw on error:"),
    dcc.RadioItems(id='radio-item-throw-on-error',
                   options=[{
                       'label': 'True',
                       'value': True
                   }, {
                       'label': "False",
                       'value': False
                   }]),
    html.Div('Here is some latex:'),
    dash_katex.DashKatex(id='katex', expression="")
])


@app.callback(Output('katex', 'expression'),
              [Input('input-latex-expression', 'value')])
def updateExpression(value):
    return value


@app.callback(Output('katex', 'displayMode'),
              [Input('radio-item-display-mode', 'value')])
def updateDisplayMode(value):
    return value