Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -831,49 +831,54 @@ def compare_persistence_homology(dna_sequence1, dna_sequence2):
|
|
| 831 |
return distance
|
| 832 |
|
| 833 |
############################################################# UI #################################################################
|
|
|
|
| 834 |
ui.page_opts(fillable=True)
|
| 835 |
-
|
| 836 |
-
with ui.
|
| 837 |
-
with ui.
|
| 838 |
-
ui.
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 877 |
|
| 878 |
# @render.image
|
| 879 |
# def image():
|
|
|
|
| 831 |
return distance
|
| 832 |
|
| 833 |
############################################################# UI #################################################################
|
| 834 |
+
|
| 835 |
ui.page_opts(fillable=True)
|
| 836 |
+
|
| 837 |
+
with ui.navset_card_tab(id="tab"):
|
| 838 |
+
with ui.nav_panel("Viral Macrostructure"):
|
| 839 |
+
ui.page_opts(fillable=True)
|
| 840 |
+
ui.panel_title("Do viruses have underlying structure?")
|
| 841 |
+
with ui.layout_columns():
|
| 842 |
+
with ui.card():
|
| 843 |
+
ui.input_selectize(
|
| 844 |
+
"virus_selector",
|
| 845 |
+
"Select your viruses:",
|
| 846 |
+
virus,
|
| 847 |
+
multiple=True,
|
| 848 |
+
)
|
| 849 |
+
with ui.card():
|
| 850 |
+
ui.input_selectize(
|
| 851 |
+
"plot_type",
|
| 852 |
+
"Select your method:",
|
| 853 |
+
["Chaos Game Representation", "2D Line", "ColorSquare", "Persistant Homology", "Wens Method"],
|
| 854 |
+
multiple=False,
|
| 855 |
+
)
|
| 856 |
+
|
| 857 |
+
############################################################# Plotting ########################################################
|
| 858 |
+
here = Path(__file__).parent
|
| 859 |
+
@render.plot
|
| 860 |
+
def plot():
|
| 861 |
+
#ds = load_dataset('Hack90/virus_tiny')
|
| 862 |
+
df = pd.read_parquet('virus_ds.parquet')
|
| 863 |
+
df = df[df['Organism_Name'].isin(input.virus_selector())]
|
| 864 |
+
# group by virus
|
| 865 |
+
grouped = df.groupby('Organism_Name')['Sequence'].apply(list)
|
| 866 |
+
# plot the comparison
|
| 867 |
+
fig = None
|
| 868 |
+
if input.plot_type() == "2D Line":
|
| 869 |
+
fig = plot_2d_comparison(grouped, grouped.index)
|
| 870 |
+
if input.plot_type() == "ColorSquare":
|
| 871 |
+
filtered_df = df.groupby('Organism_Name').apply(filter_and_select).reset_index(drop=True)
|
| 872 |
+
fig = plot_color_square(filtered_df['Sequence'], filtered_df['Organism_Name'].unique())
|
| 873 |
+
if input.plot_type() == "Wens Method":
|
| 874 |
+
fig = wens_method_heatmap(df, df['Organism_Name'].unique())
|
| 875 |
+
if input.plot_type() == "Chaos Game Representation":
|
| 876 |
+
filtered_df = df.groupby('Organism_Name').apply(filter_and_select).reset_index(drop=True)
|
| 877 |
+
fig = plot_fcgr(filtered_df['Sequence'], df['Organism_Name'].unique())
|
| 878 |
+
if input.plot_type() == "Persistant Homology":
|
| 879 |
+
filtered_df = df.groupby('Organism_Name').apply(filter_and_select).reset_index(drop=True)
|
| 880 |
+
fig = plot_persistence_homology(filtered_df['Sequence'], filtered_df['Organism_Name'])
|
| 881 |
+
return fig
|
| 882 |
|
| 883 |
# @render.image
|
| 884 |
# def image():
|