def create_second_upload(match_title):
    if match_title == 'uploaded':
        return html.Div([
            html.
            H5('The match has already been uploaded. Please select another match.',
               style={'textAlign': 'center'})
        ])
    return html.Div([
        html.H5('Next, please upload the position data for the game',
                style={'textAlign': 'center'}),
        html.H6(match_title.replace(":", " - "), style={'textAlign':
                                                        'center'}),
        dash_resumable_upload.Upload(
            id='upload_position',
            maxFiles=1,
            maxFileSize=1024 * 1024 * 1000,  # 1000 MB
            service="/upload_resumable",
            textLabel="Drag and Drop here to upload!",
            startButton=False,
            pauseButton=False,
            cancelButton=False,
            defaultStyle={
                'lineHeight': '60px',
                'borderWidth': '1px',
                'borderStyle': 'dashed',
                'borderRadius': '5px'
            },
            activeStyle={
                'lineHeight': '60px',
                'borderWidth': '1px',
                'borderStyle': 'solid',
                'borderRadius': '5px'
            },
            # Allow multiple files to be uploaded
            #multiple=True
        ),
    ])
def test1(server):
    app = dash.Dash(server=server,
                         routes_pathname_prefix='/dashapp/',
                         external_stylesheets=[
                             'https://codepen.io/dapraxis/pen/gOPGzPj.css',
                             '/static/dist/css/styles.css',
                             'https://fonts.googleapis.com/css?family=Lato'
                             ])

    dash_resumable_upload.decorate_server(app.server, "uploads")
    
    app.index_string = html_layout

    app.scripts.config.serve_locally = True  # Uploaded to npm, this can work online now too.

    app.layout = html.Div([
        dash_resumable_upload.Upload(
            id='upload-data',
            maxFiles=1,
            maxFileSize=1024*1024*1000,  # 100 MB
            service="/upload_resumable",
            textLabel="Drag and Drop to upload",
            # startButton=True
        ),
        html.Div(id='output')
        ],style={
            'width': '70%',
            'margin': '5% 15%',
            'text-align': 'center',
        })


    @app.callback(Output('output', 'children'),
                [Input('upload-data', 'fileNames')])
    def update_output(list_of_names):
        if list_of_names is not None:
            children = [parse_contents(filename) for filename in list_of_names]
            return children
        
    def parse_contents(filename):
        try:
            if 'csv' in filename:
                # Assume that the user uploaded a CSV file
                df = pd.read_csv("uploads/%s" % (filename))
            elif 'xls' in filename:
                # Assume that the user uploaded an excel file
                df = pd.read_excel(io.BytesIO(decoded))
        except Exception as e:
            print(e)
            return html.Div([
                'There was an error processing this file.'
            ])
        
        size = convert_unit(os.stat(str(os.getcwd())+'/uploads/'+str(filename)).st_size, SIZE_UNIT.MB)

        return html.Div([
            html.H5("Upload File: {}".format(filename)),
            html.H5("File size: {:.3f}MB".format(size)),
            dash_table.DataTable(
                id='database-table',
                columns=[{'name': i, 'id': i} for i in df.columns],
                data=df[:1000].to_dict('records'),
                sort_action="native",
                sort_mode='native',
                page_size=300,
                fixed_rows = 100,
                style_table={
                    'maxHeight': '80ex',
                    'overflowY': 'scroll',
                    'overflowX': 'scroll',
                    'width': '100%',
                    # 'minWidth': '100%',
                    # 'margin': '5% 15%'
                },
            ),

            html.Hr(),  # horizontal line
            html.A(html.Button('Next', id='btn'), href='/EDA')
        ])
Пример #3
0
          style={'textAlign': 'center'}),
 html.H2(
     children=
     'A Tool for Accelerating the Analysis of Cyclic Voltammetry Data',
     style={
         'textAlign': 'center',
         'color': colors['text']
     }),
 html.Br(),
 html.Div([
     html.Link(rel='stylesheet',
               href='https://codepen.io/rmarren1/pen/eMQKBW.css'),
     dash_resumable_upload.Upload(
         id='upload',
         maxFiles=1,
         maxFileSize=1024 * 1024 * 1000,  # 100 MB
         service="/upload_resumable",
         textLabel="Upload Files",
         startButton=False)
 ]),
 html.Div(id='output_uploaded_file'),
 html.Br(),
 html.H2(children='Select File to Analyze',
         style={
             'textAlign': 'center',
             'color': colors['text']
         }),
 html.Div(
     [dcc.Dropdown(id='files_dropdown')],
     style={
         'width': '70%',
Пример #4
0
#ax.grid()

#plotly_fig = mpl_to_plotly(fig)

app.layout = html.Div([
    dash_resumable_upload.Upload(
        id='upload',
        maxFiles=1,
        maxFileSize=1024*1024*1000,  # 100 MB
        service="/upload_resumable",
        #textLabel="Drag and Drop Here to upload!",
        startButton=False,
        pauseButton=False,
        cancelButton=False,
        defaultStyle={
            'width': '100%',
            'height': '60px',
            'lineHeight': '60px',
            'borderWidth': '1px',
            'borderStyle': 'dashed',
            'borderRadius': '5px',
            'textAlign': 'center',
            'margin': '10px'
        }
        # Allow multiple files to be uploaded
        #multiple=True
    ),

    #dcc.Graph(id='myGraph', figure=plotly_fig),

    html.Div(id='output'),
Пример #5
0
    def main_layout(self, tab_plots=[], tab_tables=[]):
        '''Serve the main Dash layout '''

        # ------------ Left panel features ------------
        # File upload with organism selection
        __upload_feature = self.__panel_feature(
            element_id='upload-feature',
            details_summary='File Upload',
            open_details=True,
            html_element_list = \
                [
                    dash_resumable_upload.Upload(
                        id='upload-data',
                        maxFiles=1,
                        maxFileSize=1024*1024*1000,  # 100 MB
                        service='/upload_resumable',
                        textLabel='Drag and Drop or Click Here to Upload',
                        startButton=False,
                        cancelButton=False,
                        pauseButton=False,
                        chunkSize=500_000,
                        defaultStyle={'color':'black', 'font-size':'1em', 'display':'inline-block'},
                        activeStyle={'color':'black', 'font-size':'1em', 'display':'inline-block'},
                        completeStyle={'color':'black', 'font-size':'1em', 'display':'inline-block', 'overflow-wrap':'break-word'}),

                    # Allow selection of organism for populating gene information
                    html.Summary('Select Organism', style={'margin-top':'5px'}),
                    dcc.Dropdown(
                        id='organism-select',
                        multi=False,
                        options=[
                            {'label':'Mouse', 'value':'mouse'},
                            {'label':'Human','value':'human'},
                        ],
                        value='mouse'
                    )
                ])

        # SC cluster selection dropdown menu
        __cluster_feature = self.__panel_feature(
            element_id='cluster-dropdown-div',
            details_summary='Cluster',
            open_details=True,
            html_element_list = \
                [
                    # html.Summary('Cluster'),
                    html.Div([
                        dcc.Dropdown(
                        id='cluster-dropdown',
                        multi=False)])])

        # Gene highlighter dropdown menu
        __gene_dropdown_feature = self.__panel_feature(
            element_id='gene-dropdown-div',
            details_summary='Highlight Genes',
            open_details=True,
            html_element_list=\
                [
                    html.Div([
                    dcc.Dropdown(
                    id='gene-dropdown',
                    multi=True)])])

        # Temporary GO filter menu.
        __go_dropdown_feature = self.__panel_feature(
            element_id='go-dropdown-div',
            details_summary='Filter on Gene Ontology (GO)',
            open_details=False,
            html_element_list=\
                [
                    html.Div([
                    dcc.Dropdown(
                    id='go-dropdown',
                    multi=True)])])

        # log₁₀(adjusted p-value) filter sliders and buttons
        __pvalue_slider_feature = self.__panel_feature(
            element_id='pvalue-slider-div',
            details_summary='Filter on Transformed p-value',
            html_element_list=\
                [
                    self.slider_layout(
                        slider_id='pvalue-slider',
                        input_min_id='pvalue-textbox-min',
                        input_max_id='pvalue-textbox-max',
                        submit_button_id='pvalue-submit-button',
                        reset_button_id='pvalue-reset-button'),
                ])

        # Log2(foldchange) filter sliders and buttons
        __foldchange_slider_feature = self.__panel_feature(
            element_id='foldchange-slider-div',
            details_summary='Filter on log₂(FoldChange)',
            html_element_list=\
                [
                    self.slider_layout(
                        slider_id='foldchange-slider',
                        input_min_id='foldchange-textbox-min',
                        input_max_id='foldchange-textbox-max',
                        submit_button_id='foldchange-submit-button',
                        reset_button_id='foldchange-reset-button'),
                ],)

        # Base mean filter sliders and buttons
        __basemean_slider_feature = self.__panel_feature(
            element_id='basemean-slider-div',
            details_summary='Filter on log₁₀(BaseMean)',
            html_element_list=\
                [
                    self.slider_layout(
                        slider_id='basemean-slider',
                        input_min_id='basemean-textbox-min',
                        input_max_id='basemean-textbox-max',
                        submit_button_id = 'basemean-submit-button',
                        reset_button_id='basemean-reset-button'),
                ])

        def collapsible_tree(tree_data=None, id='dash-collapsible-tree'):
            test_tree_data = {
                'label':
                'search me',
                'value':
                'searchme',
                'children': [
                    {
                        'label':
                        'search me too',
                        'value':
                        'searchmetoo',
                        'children': [
                            {
                                'label': 'No one can get me',
                                'value': 'anonymous',
                            },
                        ],
                    },
                ],
            }

            if tree_data == None:
                tree_data = test_tree_data

            return html.Div([
                dash_collapsible_tree.DashCollapsibleTree(id=id,
                                                          data=tree_data)
            ])
        __collapsible_tree_feature = self.__panel_feature(
            element_id='go-dropdown-div',
            details_summary='Filter on GO Terms',
            # !! Keep invisible for now
            visibility=False,
            html_element_list=\
                [
                    collapsible_tree()
                ])
        # ------------ /Left panel features ------------

        tabs_styles = {
            'height': '38px',
            'display': 'inline-block',
            'white-space': 'nowrap',
        }

        return html.Div(children=[
            # Hidden Div to store session
            html.Div(id='session-id', style={'display': 'none'}),
            # Hidden Div to store file type
            html.Div(id='file-type', style={'display': 'none'}),
            # Hidden Div as store for organism type
            html.Div(id='organism-div', style={'display': 'none'}),
            # Store timestamps of plot clicks help determine last plot clicked
            html.Div(id='volcano-plot-timediv', style={'display': 'none'}),
            html.Div(id='ma-plot-timediv', style={'display': 'none'}),
            html.Div(id='maxvolc-plot-timediv', style={'display': 'none'}),
            # Hidden div for subset_data callback
            html.Div(id='data-subset-sink', style={'display': 'none'}),
            # Keep track of the last clicked gene for highlighting and metadata retrieval/display
            html.Div(id='last-selected-gene', style={'display': 'none'}),
            # App title header
            html.A(
                children=[
                    html.Img(
                        src='assets/lavaruins_logo.png',
                        style={
                            'width': '60px',
                            'display': 'inline',
                            'vertical-align': 'middle'
                        },
                    ),
                ],
                href=
                'https://github.com/tubuliferous/lavaruins',  # Link to GitHub page
                target='_blank',
            ),
            # style={'text-decoration':'none', 'color':'black'},),
            html.H3('LavaRuins Differential Gene Expression Explorer',
                    style={
                        'display': 'inline',
                    }),

            # Plots and side bars (top part of interface)
            html.Div(
                children=[
                    html.Div(
                        children=[
                            # File upload with organism selection
                            __upload_feature,

                            # SC cluster selection dropdown menu
                            __cluster_feature,

                            # Gene highlighter dropdown menu
                            __gene_dropdown_feature,

                            # GO filter dropdown menu
                            __go_dropdown_feature,

                            # log₁₀(adjusted p-value) filter sliders and buttons
                            __pvalue_slider_feature,

                            # Log2(foldchange) filter sliders and buttons
                            __foldchange_slider_feature,

                            # Log₁₀(basemean) filter sliders and buttons
                            __basemean_slider_feature,

                            # GO Tree filter menu
                            # __collapsible_tree_feature,
                        ],
                        style={
                            'width': '20%',
                            'display': 'inline-block',
                            'vertical-align': 'top',
                            'padding-top': '0px'
                        },
                    ),

                    # Tab-accessed plots in the center of the layout
                    html.Div(
                        children=[
                            dcc.Tabs(
                                id='plot-tabs',
                                children=tab_plots,
                                style=tabs_styles,
                            ),
                        ],
                        style={
                            'width': '60%',
                            'display': 'inline-block',
                            'vertical-align': 'top',
                            'padding-top': '0px'
                        },
                    ),
                    html.Div(id='gene-info-markdown',
                             style={
                                 'width': '20%',
                                 'display': 'inline-block',
                                 'vertical-align': 'top',
                                 'padding-top': '35px'
                             })
                ],
                style={'margin-bottom': '20px'}),
            # DataTables (bottom part of interface)
            dcc.Tabs(id='table-tabs', children=tab_tables, style=tabs_styles),
        ])
Пример #6
0
import base64

app = dash.Dash('')

dash_resumable_upload.decorate_server(app.server, "uploads")

app.scripts.config.serve_locally = True  # Uploaded to npm, this can work online now too.

app.css.append_css(
    {"external_url": "https://codepen.io/rmarren1/pen/eMQKBW.css"})

app.layout = html.Div([
    dash_resumable_upload.Upload(
        id='upload',
        maxFiles=1,
        maxFileSize=1024 * 1024 * 1000,  # 100 MB
        service="/upload_resumable",
        textLabel="Drag and Drop Here to upload!",
        startButton=False),
    html.Div(id='output')
])


def get_img(x):
    return x
    #encode = base64.b64encode(
    #    open("uploads/%s" % (x), 'rb').read()).decode('ascii')
    #return "data:image/jpg;base64,{}".format(encode)


@app.callback(Output('output', 'children'), [Input('upload', 'fileNames')])