Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -81,17 +81,73 @@ with ui.navset_card_tab(id="tab"):
|
|
81 |
with ui.layout_columns():
|
82 |
with ui.card():
|
83 |
ui.input_selectize("virus_selector_1", "Select your viruses:", virus_new, multiple=True, selected=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
@render.plot()
|
86 |
def plot_distro_new():
|
87 |
import seaborn as sns
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
with ui.nav_panel("Viral Microstructure"):
|
97 |
ui.panel_title("Kmer Distribution")
|
|
|
81 |
with ui.layout_columns():
|
82 |
with ui.card():
|
83 |
ui.input_selectize("virus_selector_1", "Select your viruses:", virus_new, multiple=True, selected=None)
|
84 |
+
# with ui.card():
|
85 |
+
ui.input_selectize(
|
86 |
+
"plot_type_distro",
|
87 |
+
"Select your distrobution variance view:",
|
88 |
+
["Variance across bp", "Standard deviation across bp", "Full Genome Distrobution"],
|
89 |
+
multiple=False,
|
90 |
+
selected="Full Genome Distrobution",
|
91 |
+
)
|
92 |
+
|
93 |
|
94 |
@render.plot()
|
95 |
def plot_distro_new():
|
96 |
import seaborn as sns
|
97 |
+
plot_type = input.plot_type_distro()
|
98 |
+
if plot_type == "Full Genome Distrobution":
|
99 |
+
df = MASTER_DF[MASTER_DF["organism_name"].isin(input.virus_selector_1())].copy()
|
100 |
+
df = df.explode('charts').copy()
|
101 |
+
ax = sns.histplot(data=df, x='charts', hue='organism_name', stat='density')
|
102 |
+
ax.set_title("Distribution")
|
103 |
+
ax.set_xlabel("Distance from mean")
|
104 |
+
ax.set_ylabel("Density")
|
105 |
+
return ax
|
106 |
+
elif plot_type == "Standard deviation across bp":
|
107 |
+
df = MASTER_DF[MASTER_DF["organism_name"].isin(input.virus_selector_1())].copy()
|
108 |
+
dfs = []
|
109 |
+
for organism in input.virus_selector_1():
|
110 |
+
df_tiny = df[df['organism_name'] == organism].copy()
|
111 |
+
y = df_tiny['std'].values[0].tolist()
|
112 |
+
x = [x for x in range(len(y))]
|
113 |
+
df_tiny = pd.DataFrame()
|
114 |
+
|
115 |
+
df_tiny['y'] = y
|
116 |
+
df_tiny['x'] = x
|
117 |
+
df_tiny['organism'] = organism
|
118 |
+
dfs.append(df_tiny)
|
119 |
+
|
120 |
+
df_k = pd.DataFrame()
|
121 |
+
df_k = pd.concat(dfs)
|
122 |
+
df_k = df_k.explode(column =['x', 'y']).copy()
|
123 |
+
ax = sns.lineplot(data=df_k, x='x',y = 'y', hue='organism')
|
124 |
+
ax.set_title("Standard Deviation across basepairs")
|
125 |
+
ax.set_xlabel("Basepair")
|
126 |
+
ax.set_ylabel("Std")
|
127 |
+
|
128 |
+
return ax
|
129 |
+
elif plot_type == "Variance across bp":
|
130 |
+
df = MASTER_DF[MASTER_DF["organism_name"].isin(input.virus_selector_1())].copy()
|
131 |
+
dfs = []
|
132 |
+
for organism in input.virus_selector_1():
|
133 |
+
df_tiny = df[df['organism_name'] == organism].copy()
|
134 |
+
y = df_tiny['var'].values[0].tolist()
|
135 |
+
x = [x for x in range(len(y))]
|
136 |
+
df_tiny = pd.DataFrame()
|
137 |
+
|
138 |
+
df_tiny['y'] = y
|
139 |
+
df_tiny['x'] = x
|
140 |
+
df_tiny['organism'] = organism
|
141 |
+
dfs.append(df_tiny)
|
142 |
+
|
143 |
+
df_k = pd.DataFrame()
|
144 |
+
df_k = pd.concat(dfs)
|
145 |
+
df_k = df_k.explode(column =['x', 'y']).copy()
|
146 |
+
ax = sns.lineplot(data=df_k, x='x',y = 'y', hue='organism')
|
147 |
+
ax.set_title("Variance across basepairs")
|
148 |
+
ax.set_xlabel("Basepair")
|
149 |
+
ax.set_ylabel("Variance")
|
150 |
+
return ax
|
151 |
|
152 |
with ui.nav_panel("Viral Microstructure"):
|
153 |
ui.panel_title("Kmer Distribution")
|