Hack90 commited on
Commit
a3ca460
·
verified ·
1 Parent(s): ca74bfe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -68
app.py CHANGED
@@ -894,79 +894,79 @@ with ui.navset_card_tab(id="tab"):
894
  # with ui.nav_panel("Viral Model"):
895
  # gr.load("models/Hack90/virus_pythia_31_1024").launch()
896
 
897
- with ui.nav_panel("Viral Microstructure"):
898
- ui.page_opts(fillable=True)
899
- ui.panel_title("Kmer Distribution")
900
- with ui.layout_columns():
901
- with ui.card():
902
- ui.input_slider("kmer", "kmer", 0, 10, 5)
903
- ui.input_slider("top_k", "top:", 0, 1000, 15)
904
 
905
- ui.input_selectize(
906
- "plot_type",
907
- "Select metric:",
908
- ["percentage", "count"],
909
- multiple=False,
910
- )
911
 
912
 
913
- @render.plot
914
- def plot():
915
- df = pd.read_csv('kmers.csv')
916
- k = input.kmer()
917
- top_k = input.top_k()
918
- fig = None
919
- if input.plot_type() == "count":
920
- df = df[df['k'] == k]
921
- df = df.head(top_k)
922
- fig, ax = plt.subplots()
923
- ax.bar(df['kmer'], df['count'])
924
- ax.set_title(f"Most common {k}-mers")
925
- ax.set_xlabel("K-mer")
926
- ax.set_ylabel("Count")
927
- ax.set_xticklabels(df['kmer'], rotation=90)
928
- if input.plot_type() == "percentage":
929
- df = df[df['k'] == k]
930
- df = df.head(top_k)
931
- fig, ax = plt.subplots()
932
- ax.bar(df['kmer'], df['percent']*100)
933
- ax.set_title(f"Most common {k}-mers")
934
- ax.set_xlabel("K-mer")
935
- ax.set_ylabel("Percentage")
936
- ax.set_xticklabels(df['kmer'], rotation=90)
937
- return fig
938
-
939
- with ui.nav_panel("Viral Model Training"):
940
- ui.page_opts(fillable=True)
941
- ui.panel_title("Does context size matter for a nucleotide model?")
942
 
943
- def plot_loss_rates(df, type):
944
- # interplot each column to be same number of points
945
- x = np.linspace(0, 1, 1000)
946
- loss_rates = []
947
- labels = ['32', '64', '128', '256', '512', '1024']
948
- #drop the column step
949
- df = df.drop(columns=['Step'])
950
- for col in df.columns:
951
- y = df[col].dropna().astype('float', errors = 'ignore').dropna().values
952
- f = interp1d(np.linspace(0, 1, len(y)), y)
953
- loss_rates.append(f(x))
954
- fig, ax = plt.subplots()
955
- for i, loss_rate in enumerate(loss_rates):
956
- ax.plot(x, loss_rate, label=labels[i])
957
- ax.legend()
958
- ax.set_title(f'Loss rates for a {type} parameter model')
959
- ax.set_xlabel('Training steps')
960
- ax.set_ylabel('Loss rate')
961
- return fig
962
 
963
- @render.plot
964
- def plot():
965
- fig = None
966
- df = pd.read_csv('14m.csv')
967
- mpl.rcParams.update(mpl.rcParamsDefault)
968
- fig = plot_loss_rates(df, '14M')
969
- return fig
970
 
971
 
972
  # @render.image
 
894
  # with ui.nav_panel("Viral Model"):
895
  # gr.load("models/Hack90/virus_pythia_31_1024").launch()
896
 
897
+ # with ui.nav_panel("Viral Microstructure"):
898
+ # ui.page_opts(fillable=True)
899
+ # ui.panel_title("Kmer Distribution")
900
+ # with ui.layout_columns():
901
+ # with ui.card():
902
+ # ui.input_slider("kmer", "kmer", 0, 10, 5)
903
+ # ui.input_slider("top_k", "top:", 0, 1000, 15)
904
 
905
+ # ui.input_selectize(
906
+ # "plot_type",
907
+ # "Select metric:",
908
+ # ["percentage", "count"],
909
+ # multiple=False,
910
+ # )
911
 
912
 
913
+ # @render.plot
914
+ # def plot():
915
+ # df = pd.read_csv('kmers.csv')
916
+ # k = input.kmer()
917
+ # top_k = input.top_k()
918
+ # fig = None
919
+ # if input.plot_type() == "count":
920
+ # df = df[df['k'] == k]
921
+ # df = df.head(top_k)
922
+ # fig, ax = plt.subplots()
923
+ # ax.bar(df['kmer'], df['count'])
924
+ # ax.set_title(f"Most common {k}-mers")
925
+ # ax.set_xlabel("K-mer")
926
+ # ax.set_ylabel("Count")
927
+ # ax.set_xticklabels(df['kmer'], rotation=90)
928
+ # if input.plot_type() == "percentage":
929
+ # df = df[df['k'] == k]
930
+ # df = df.head(top_k)
931
+ # fig, ax = plt.subplots()
932
+ # ax.bar(df['kmer'], df['percent']*100)
933
+ # ax.set_title(f"Most common {k}-mers")
934
+ # ax.set_xlabel("K-mer")
935
+ # ax.set_ylabel("Percentage")
936
+ # ax.set_xticklabels(df['kmer'], rotation=90)
937
+ # return fig
938
+
939
+ # with ui.nav_panel("Viral Model Training"):
940
+ # ui.page_opts(fillable=True)
941
+ # ui.panel_title("Does context size matter for a nucleotide model?")
942
 
943
+ # def plot_loss_rates(df, type):
944
+ # # interplot each column to be same number of points
945
+ # x = np.linspace(0, 1, 1000)
946
+ # loss_rates = []
947
+ # labels = ['32', '64', '128', '256', '512', '1024']
948
+ # #drop the column step
949
+ # df = df.drop(columns=['Step'])
950
+ # for col in df.columns:
951
+ # y = df[col].dropna().astype('float', errors = 'ignore').dropna().values
952
+ # f = interp1d(np.linspace(0, 1, len(y)), y)
953
+ # loss_rates.append(f(x))
954
+ # fig, ax = plt.subplots()
955
+ # for i, loss_rate in enumerate(loss_rates):
956
+ # ax.plot(x, loss_rate, label=labels[i])
957
+ # ax.legend()
958
+ # ax.set_title(f'Loss rates for a {type} parameter model')
959
+ # ax.set_xlabel('Training steps')
960
+ # ax.set_ylabel('Loss rate')
961
+ # return fig
962
 
963
+ # @render.plot
964
+ # def plot():
965
+ # fig = None
966
+ # df = pd.read_csv('14m.csv')
967
+ # mpl.rcParams.update(mpl.rcParamsDefault)
968
+ # fig = plot_loss_rates(df, '14M')
969
+ # return fig
970
 
971
 
972
  # @render.image