Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,13 @@ ui.page_opts(fillable=True)
|
|
8 |
ui.panel_title("Kmer Analysis")
|
9 |
with ui.layout_columns():
|
10 |
with ui.card():
|
11 |
-
ui.input_slider("slider", "
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
@render.plot
|
@@ -16,12 +22,22 @@ def plot():
|
|
16 |
df = pd.read_csv('kmers.csv')
|
17 |
k = input.slider()
|
18 |
fig = None
|
19 |
-
if
|
20 |
df = df[df['k'] == k]
|
|
|
21 |
fig, ax = plt.subplots()
|
22 |
ax.bar(df['kmer'], df['count'])
|
23 |
ax.set_title(f"Most common {k}-mers")
|
24 |
ax.set_xlabel("K-mer")
|
25 |
ax.set_ylabel("Count")
|
26 |
ax.set_xticklabels(df['kmer'], rotation=90)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
return fig
|
|
|
8 |
ui.panel_title("Kmer Analysis")
|
9 |
with ui.layout_columns():
|
10 |
with ui.card():
|
11 |
+
ui.input_slider("slider", "kmer", 0, 10, 5)
|
12 |
+
ui.input_selectize(
|
13 |
+
"plot_type",
|
14 |
+
"Select Metric:",
|
15 |
+
["percentage", "count"],
|
16 |
+
multiple=False,
|
17 |
+
)
|
18 |
|
19 |
|
20 |
@render.plot
|
|
|
22 |
df = pd.read_csv('kmers.csv')
|
23 |
k = input.slider()
|
24 |
fig = None
|
25 |
+
if input.plot_type() == "count":
|
26 |
df = df[df['k'] == k]
|
27 |
+
df = df.head(20)
|
28 |
fig, ax = plt.subplots()
|
29 |
ax.bar(df['kmer'], df['count'])
|
30 |
ax.set_title(f"Most common {k}-mers")
|
31 |
ax.set_xlabel("K-mer")
|
32 |
ax.set_ylabel("Count")
|
33 |
ax.set_xticklabels(df['kmer'], rotation=90)
|
34 |
+
if input.plot_type() == "percentage":
|
35 |
+
df = df[df['k'] == k]
|
36 |
+
df = df.head(20)
|
37 |
+
fig, ax = plt.subplots()
|
38 |
+
ax.bar(df['kmer'], df['percentage']*100)
|
39 |
+
ax.set_title(f"Most common {k}-mers")
|
40 |
+
ax.set_xlabel("K-mer")
|
41 |
+
ax.set_ylabel("Percentage")
|
42 |
+
ax.set_xticklabels(df['kmer'], rotation=90)
|
43 |
return fig
|