Пример #1
0
import pandas as pd
import metabolyze as met
import numpy as np
#skeleton_name = [x for x in os.listdir('inputs') if x.endswith('output.tsv')][0]
# 	result = Analysis(data=skeleton_name,samplesheet='Groups.csv',blank_threshold_value=10000)
# 	result.t_test()
#normalized_df=(df-df.mean())/df.std()
#result = Analysis(data='skeleton_output.tsv',samplesheet='Groups.csv',blank_threshold_value=10000)
#matrix = result.get_matrix(result.get_ids('All'))
x = met.Analysis(data='skeleton_output.tsv',
                 samplesheet='Groups.csv',
                 blank_threshold_value=10000,
                 method='default')
corrected_matrix = (x.get_imputed_full_matrix(
    x.get_matrix(ids=x.get_ids('True')), param='corrected'))  ##
blank_matrix = x.get_matrix(ids=x.get_ids('Blank'))
blank_matrix[blank_matrix > 1] = 0
mergedDf = corrected_matrix.merge(blank_matrix,
                                  left_index=True,
                                  right_index=True)
matrix_sum_normalized = mergedDf.div(mergedDf.sum(axis=0), axis=1)
matrix_sum_normalized = matrix_sum_normalized.fillna(0)
#matrix_median_normalized = mergedDf.div(mergedDf.replace(0, np.nan).median(axis=0), axis=1)
# matrix_median_normalized['Metabolite'] = matrix_median_normalized.index
# matrix_median_normalized = matrix_median_normalized.reset_index(drop=True)
original = pd.read_csv('inputs/skeleton_output.tsv', sep='\t')
original.update(matrix_sum_normalized)
original.to_csv('inputs/skeleton_sum_normalized.tsv', sep='\t')

normalize_result = met.Analysis(data='skeleton_sum_normalized.tsv',
                                samplesheet='Groups.csv',
Пример #2
0
from scipy import stats
from sklearn.decomposition import PCA
import chart_studio.plotly as py
#%matplotlib inline
import plotly
#plotly.offline.init_notebook_mode() # To embed plots in the output cell of the notebook
import plotly.graph_objs as go
import os
import operator
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from math import sqrt
from itertools import combinations
from matplotlib import rcParams

result = met.Analysis('skeleton_output.tsv', 'Groups.csv')


def register_callbacks(dashapp):

    COLORS20 = [
        '#1f77b4',
        '#aec7e8',
        '#ff7f0e',
        '#ffbb78',
        '#2ca02c',
        '#98df8a',
        '#d62728',
        '#ff9896',
        '#9467bd',
        '#c5b0d5',
Пример #3
0
import os
import pandas as pd
import metabolyze as met
import numpy as np
skeleton_name = [x for x in os.listdir('inputs') if x.endswith('output.tsv')][0]
# 	result = Analysis(data=skeleton_name,samplesheet='Groups.csv',blank_threshold_value=10000)
# 	result.t_test()
#normalized_df=(df-df.mean())/df.std()
#result = Analysis(data='skeleton_output.tsv',samplesheet='Groups.csv',blank_threshold_value=10000)
#matrix = result.get_matrix(result.get_ids('All'))
x = met.Analysis(data=skeleton_name,samplesheet='Groups.csv',blank_threshold_value=10000,method='default')
corrected_matrix = (x.get_imputed_full_matrix(x.get_matrix(ids=x.get_ids('True')),param='corrected'))##
blank_matrix = x.get_matrix(ids=x.get_ids('Blank'))
blank_matrix[blank_matrix>1] = 0


mergedDf = corrected_matrix.merge(blank_matrix, left_index=True, right_index=True)
matrix_sum_normalized = mergedDf.div(mergedDf.sum(axis=0), axis=1)
matrix_sum_normalized = matrix_sum_normalized.fillna(0)

matrix_median_normalized = mergedDf.div(mergedDf.replace(0, np.nan).median(axis=0), axis=1)
matrix_median_normalized = matrix_median_normalized.fillna(0)
#matrix_median_normalized = matrix_median_normalized.reset_index(drop=True)


#sum

original = pd.read_csv('inputs/'+skeleton_name,sep='\t',index_col=0)
matrix_sum_normalized.index.names = ['Metabolite']
detect_column = original.columns.get_loc("detections")
meta_data_df = original[original.columns[0:detect_column+1]]
Пример #4
0
grouped_samples = {}

for condition in (project.id.unique()):
    test = [
        x.split('.')[0]
        for x in project.loc[project['id'] == condition, 'File'].tolist()
    ]
    test = ''.join(test)
    grouped_samples[test] = condition

detection_column_index = standard.columns.get_loc("detections")
standard = pd.read_table('inputs/skeleton_output.tsv')
standard = standard.iloc[:, 0:detection_column_index + 1]

merged = pd.merge(standard, flux_output, on='Metabolite')

merged_2 = pd.merge(merged, blanks, on='Metabolite')

for x, y in grouped_samples.items():
    merged_2.rename(columns={y: x}, inplace=True)

merged_2['Metabolite'] = merged_2['Metabolite'].str.replace('-13C-0', '')

merged_2.to_csv('inputs/flux_skeleton_output.tsv', sep='\t')

flux_result = met.Analysis(data='flux_skeleton_output.tsv',
                           samplesheet='Groups.csv',
                           blank_threshold_value=0,
                           method='flux')
flux_result.t_test()
Пример #5
0
def get_layout():

    result = met.Analysis('skeleton_output.tsv', 'Groups.csv')
    dropdown_comparison = [
        ' vs. '.join(list(x)) for x in result.dme_comparisons()
    ]
    #print("met_comparison",result.dme_comparisons())
    dropdown_list = []
    for dropdown, met_comparison in zip(dropdown_comparison,
                                        result.dme_comparisons()):
        drop_dict = {}
        drop_dict['label'] = dropdown
        met_list = list(met_comparison)
        met_list = ','.join("'{0}'".format(comparison)
                            for comparison in met_list)
        drop_dict['value'] = met_list
        dropdown_list.append(drop_dict)

    logo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATYAAACiCAMAAAD84hF6AAAAnFBMVEX///9XD4xQAIhTAIpKAIVNAIdVCItKAIb18vhIAITTyN5FAIKbf7dQAIeafLby7vWCW6isl8PKvNi9q8/q4+5gI5Hj2+tvRJr7+vx+U6O1o8nWzeDCs9OeiLmOba7f1OeWdbN3S5+okL85AHuRcLCJZarm4OxuPJqFYqnSxd5iKJJeG4/HuNVrMpiihruxm8VtN5lzQZ6MY6+ff7wJGcKbAAARQElEQVR4nO2dC1fqvBKG29wgxFKFguWiQBUEUdDv/P//dtrMpE1pK6Cg6O679lpbeknTh1wmk0lwnFq1atWqVatWrVq1atWqVatWrVq1atWqVatWrbMpWHWHm8f58no5f9wMx6PgpzN08ep3H3uswTjxCE1ECOdMsrf2uGZXIX88F8ojwi2KEi7X007401m8OIXdgeS0DJmRIJzMVz+dz4tSf6o4/QCZEWl4kf/Tmb0UrW4lOYAZlDnOHutmLlbrXRUKmki6Ay9W/F+h4hJ5/8+D68+kDS1u+5lU9Hkwv5+22+3p4/z6lSrJuGfjI2rzT/cOYTsraYJySW/bw9aigCQYdTczoXjWy3Jv/BP5vQytqGdKmSfdebf/YR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OrnrvJGmt9x0PS3wzx7/TCl6ckK8mur8mUwVTBacCm9Bl1CT/G2wySEOPJYhEcMlItWwZYcmgx3m7uhjvWdLDqtILdO0pW5TUXq05n1Q/s51U+qVatWrVq1apVq1atWrVq1apVq1atWrVq1apV6yz6P3qkMU2J+agDAAAAAElFTkSuQmCC'

    search_bar = dbc.Row(
        [
            dbc.Col(dbc.Input(type="search", placeholder="Search")),
            dbc.Col(
                dbc.Button("Search", color="primary", className="ml-2"),
                width="auto",
            ),
        ],
        no_gutters=True,
        className="ml-auto flex-nowrap mt-3 mt-md-0",
        align="center",
    )

    navbar = dbc.Navbar(
        [
            html.A(
                # Use row and col to control vertical alignment of logo / brand
                dbc.Row(
                    [
                        dbc.Col(html.Img(src=logo, height="80")),
                        dbc.Col(dbc.NavbarBrand("Metabolive",
                                                className="ml-2")),
                    ],
                    align="center",
                    no_gutters=True,
                ),
                href="/login",
            ),
            dbc.NavItem(
                dbc.NavLink("Home", active=True, href="/",
                            external_link=True)),
            dbc.NavItem(
                dbc.NavLink(
                    "Logout", active=True, href="/logout",
                    external_link=True)),
            dbc.NavItem(
                dbc.NavLink(
                    "Contact Us", active=True, href="", external_link=True)),
            dbc.NavbarToggler(id="navbar-toggler"),
            dbc.Collapse(search_bar, id="navbar-collapse", navbar=True),
        ],
        color="dark",
        dark=True,
    )

    jumbotron = dbc.Jumbotron([
        html.H1("Metabolive Beta", className="display-3"),
        html.
        P("Beta testing for the interactive analysis of Metabolyze results."),
    ])

    tab1_content = dbc.Card(
        dbc.CardBody([
            dbc.Button("Hybrid", size="lg", outline=True, color="primary"),
            dbc.Button("Untargeted", size="lg", outline=True, color="primary"),
            dbc.Button("Global", size="lg", outline=True, color="primary")
        ]),
        className="mt-3",
    )

    tab2_content = dbc.Card(
        dbc.CardBody([
            dbc.Button("Run", outline=True, color="primary"),
        ]),
        className="mt-3",
    )

    tabs = dbc.Tabs([
        dbc.Tab(tab1_content, label="Metabolyze"),
        dbc.Tab(tab2_content, label="XIC Analysis")
    ])
    #"'1e6 per mL','RPMI_PBS'"
    #[{'label': 'OLFR2 vs. GPI1', 'value': ['OLFR2', 'GPI1']}]

    button = html.Div([
        dbc.Button("Submit", id="button"),
        html.Span(id="example-output"),
    ])

    dropdown_processing = dcc.Dropdown(
        id='pipeline-dropdown',
        #options=[{'label':'OLFR2 vs. GPI1', 'value': "'OLFR2','GPI1'"}, {'label': 'GPI1 vs. OLFR2', 'value': "'GPI1','OLFR2'"}],
        options=[{
            'label': 'Ungrid',
            'value': 'Ungrid'
        }],
        value="Ungrid"
        #value=["test"]
    )

    dropdown_analysis = dcc.Dropdown(
        id='my-dropdown',
        #options=[{'label':'OLFR2 vs. GPI1', 'value': "'OLFR2','GPI1'"}, {'label': 'GPI1 vs. OLFR2', 'value': "'GPI1','OLFR2'"}],
        options=dropdown_list,
        #value=["test"]
    )
    table = html.Div(id='output-data-upload')

    hidden_div = html.Div(id='intermediate-value', style={'display': 'none'})
    volcano_graph = html.Div(id='volcano_graph')
    heatmap_graph = html.Div(id='heatmap_graph')
    pca_graph = html.Div(id='pca_graph')
    #graph = html.Div(id='graph')
    # def layout():
    layout = html.Div([
        navbar, jumbotron, tabs, dropdown_processing, dropdown_analysis,
        button, hidden_div, volcano_graph, heatmap_graph, pca_graph, table
    ])
    return (layout)