File size: 1,297 Bytes
714dbd4
 
 
c8249a0
31b45d6
714dbd4
 
 
 
 
53de236
8aba07b
53de236
acc5451
 
 
 
 
 
714dbd4
6f52a43
714dbd4
 
 
53de236
 
714dbd4
acc5451
714dbd4
53de236
6f52a43
 
 
 
 
 
acc5451
 
53de236
acc5451
49e0a3d
acc5451
 
 
 
6f52a43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from shiny import render
from shiny.express import input, ui
import plotly.express as px
import pandas as pd
import matplotlib.pyplot as plt

ui.page_opts(fillable=True)
ui.panel_title("Kmer Analysis")
with ui.layout_columns():
    with ui.card():
        ui.input_slider("kmer", "kmer", 0, 10, 5)
        ui.input_slider("top_k", "top:", 0, 1000, 15)
        
        ui.input_selectize(  
    "plot_type",  
    "Select Metric:",
    ["percentage", "count"],
    multiple=False,  
)


@render.plot
def plot():  
    df = pd.read_csv('kmers.csv')
    k = input.kmer()
    top_k = input.top_k()
    fig = None
    if input.plot_type() == "count":
        df = df[df['k'] == k]
        df = df.head(top_k)
        fig, ax = plt.subplots()
        ax.bar(df['kmer'], df['count'])
        ax.set_title(f"Most common {k}-mers")
        ax.set_xlabel("K-mer")
        ax.set_ylabel("Count")
        ax.set_xticklabels(df['kmer'], rotation=90)
    if input.plot_type() == "percentage":
        df = df[df['k'] == k]
        df = df.head(top_k)
        fig, ax = plt.subplots()
        ax.bar(df['kmer'], df['percent']*100)
        ax.set_title(f"Most common {k}-mers")
        ax.set_xlabel("K-mer")
        ax.set_ylabel("Percentage")
        ax.set_xticklabels(df['kmer'], rotation=90)
    return fig