|
| 1 | +import pandas as pd |
| 2 | +import streamlit as st |
| 3 | +df_index = 1 |
| 4 | +from vuegen import table_utils |
| 5 | +from st_aggrid import AgGrid, GridOptionsBuilder |
| 6 | + |
| 7 | +st.markdown('''<h3 style='text-align: center; color: #023558;'>All Formats</h3>''', unsafe_allow_html=True) |
| 8 | +st.markdown('''<h4 style='text-align: center; color: #2b8cbe;'>Phyla Correlation Network Csv</h4>''', unsafe_allow_html=True) |
| 9 | +df = pd.read_csv('docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/1_phyla_correlation_network_csv.csv') |
| 10 | + |
| 11 | + |
| 12 | +# Displays a DataFrame using AgGrid with configurable options. |
| 13 | +grid_builder = GridOptionsBuilder.from_dataframe(df) |
| 14 | +grid_builder.configure_default_column(editable=True, groupable=True, filter=True) |
| 15 | +grid_builder.configure_side_bar(filters_panel=True, columns_panel=True) |
| 16 | +grid_builder.configure_selection(selection_mode="multiple") |
| 17 | +grid_builder.configure_pagination(enabled=True, paginationAutoPageSize=False, paginationPageSize=20) |
| 18 | +grid_options = grid_builder.build() |
| 19 | + |
| 20 | +AgGrid(df, gridOptions=grid_options, enable_enterprise_modules=True) |
| 21 | + |
| 22 | +# Button to download the df |
| 23 | +df_csv = df.to_csv(sep=',', header=True, index=False).encode('utf-8') |
| 24 | +st.download_button( |
| 25 | + label="Download dataframe as CSV", |
| 26 | + data=df_csv, |
| 27 | + file_name=f"dataframe_{df_index}.csv", |
| 28 | + mime='text/csv', |
| 29 | + key=f"download_button_{df_index}") |
| 30 | +df_index += 1 |
| 31 | +st.markdown('''<h4 style='text-align: center; color: #2b8cbe;'>Abundance Table Example Xls</h4>''', unsafe_allow_html=True) |
| 32 | +selected_sheet = 0 |
| 33 | +sheet_names = table_utils.get_sheet_names("/Users/heweb/Documents/repos/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/2_abundance_table_example_xls.xls") |
| 34 | +selected_sheet = st.selectbox("Select a sheet to display", options=sheet_names) |
| 35 | + |
| 36 | +df = pd.read_excel('/Users/heweb/Documents/repos/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/2_abundance_table_example_xls.xls', sheet_name=selected_sheet) |
| 37 | + |
| 38 | + |
| 39 | +# Displays a DataFrame using AgGrid with configurable options. |
| 40 | +grid_builder = GridOptionsBuilder.from_dataframe(df) |
| 41 | +grid_builder.configure_default_column(editable=True, groupable=True, filter=True) |
| 42 | +grid_builder.configure_side_bar(filters_panel=True, columns_panel=True) |
| 43 | +grid_builder.configure_selection(selection_mode="multiple") |
| 44 | +grid_builder.configure_pagination(enabled=True, paginationAutoPageSize=False, paginationPageSize=20) |
| 45 | +grid_options = grid_builder.build() |
| 46 | + |
| 47 | +AgGrid(df, gridOptions=grid_options, enable_enterprise_modules=True) |
| 48 | + |
| 49 | +# Button to download the df |
| 50 | +df_csv = df.to_csv(sep=',', header=True, index=False).encode('utf-8') |
| 51 | +st.download_button( |
| 52 | + label="Download dataframe as CSV", |
| 53 | + data=df_csv, |
| 54 | + file_name=f"dataframe_{df_index}.csv", |
| 55 | + mime='text/csv', |
| 56 | + key=f"download_button_{df_index}") |
| 57 | +df_index += 1 |
| 58 | +st.markdown('''<h4 style='text-align: center; color: #2b8cbe;'>Sample Info Example Txt</h4>''', unsafe_allow_html=True) |
| 59 | +df = pd.read_table('docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/3_sample_info_example_txt.txt') |
| 60 | + |
| 61 | + |
| 62 | +# Displays a DataFrame using AgGrid with configurable options. |
| 63 | +grid_builder = GridOptionsBuilder.from_dataframe(df) |
| 64 | +grid_builder.configure_default_column(editable=True, groupable=True, filter=True) |
| 65 | +grid_builder.configure_side_bar(filters_panel=True, columns_panel=True) |
| 66 | +grid_builder.configure_selection(selection_mode="multiple") |
| 67 | +grid_builder.configure_pagination(enabled=True, paginationAutoPageSize=False, paginationPageSize=20) |
| 68 | +grid_options = grid_builder.build() |
| 69 | + |
| 70 | +AgGrid(df, gridOptions=grid_options, enable_enterprise_modules=True) |
| 71 | + |
| 72 | +# Button to download the df |
| 73 | +df_csv = df.to_csv(sep=',', header=True, index=False).encode('utf-8') |
| 74 | +st.download_button( |
| 75 | + label="Download dataframe as CSV", |
| 76 | + data=df_csv, |
| 77 | + file_name=f"dataframe_{df_index}.csv", |
| 78 | + mime='text/csv', |
| 79 | + key=f"download_button_{df_index}") |
| 80 | +df_index += 1 |
| 81 | +st.markdown('''<h4 style='text-align: center; color: #2b8cbe;'>Sample Info Example Parquet</h4>''', unsafe_allow_html=True) |
| 82 | +df = pd.read_parquet('docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/4_sample_info_example_parquet.parquet') |
| 83 | + |
| 84 | + |
| 85 | +# Displays a DataFrame using AgGrid with configurable options. |
| 86 | +grid_builder = GridOptionsBuilder.from_dataframe(df) |
| 87 | +grid_builder.configure_default_column(editable=True, groupable=True, filter=True) |
| 88 | +grid_builder.configure_side_bar(filters_panel=True, columns_panel=True) |
| 89 | +grid_builder.configure_selection(selection_mode="multiple") |
| 90 | +grid_builder.configure_pagination(enabled=True, paginationAutoPageSize=False, paginationPageSize=20) |
| 91 | +grid_options = grid_builder.build() |
| 92 | + |
| 93 | +AgGrid(df, gridOptions=grid_options, enable_enterprise_modules=True) |
| 94 | + |
| 95 | +# Button to download the df |
| 96 | +df_csv = df.to_csv(sep=',', header=True, index=False).encode('utf-8') |
| 97 | +st.download_button( |
| 98 | + label="Download dataframe as CSV", |
| 99 | + data=df_csv, |
| 100 | + file_name=f"dataframe_{df_index}.csv", |
| 101 | + mime='text/csv', |
| 102 | + key=f"download_button_{df_index}") |
| 103 | +df_index += 1 |
| 104 | +st.markdown('''<h4 style='text-align: center; color: #2b8cbe;'>Example Xlsx</h4>''', unsafe_allow_html=True) |
| 105 | +selected_sheet = 0 |
| 106 | +df = pd.read_excel('/Users/heweb/Documents/repos/vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/5_example_xlsx.xlsx', sheet_name=selected_sheet) |
| 107 | + |
| 108 | + |
| 109 | +# Displays a DataFrame using AgGrid with configurable options. |
| 110 | +grid_builder = GridOptionsBuilder.from_dataframe(df) |
| 111 | +grid_builder.configure_default_column(editable=True, groupable=True, filter=True) |
| 112 | +grid_builder.configure_side_bar(filters_panel=True, columns_panel=True) |
| 113 | +grid_builder.configure_selection(selection_mode="multiple") |
| 114 | +grid_builder.configure_pagination(enabled=True, paginationAutoPageSize=False, paginationPageSize=20) |
| 115 | +grid_options = grid_builder.build() |
| 116 | + |
| 117 | +AgGrid(df, gridOptions=grid_options, enable_enterprise_modules=True) |
| 118 | + |
| 119 | +# Button to download the df |
| 120 | +df_csv = df.to_csv(sep=',', header=True, index=False).encode('utf-8') |
| 121 | +st.download_button( |
| 122 | + label="Download dataframe as CSV", |
| 123 | + data=df_csv, |
| 124 | + file_name=f"dataframe_{df_index}.csv", |
| 125 | + mime='text/csv', |
| 126 | + key=f"download_button_{df_index}") |
| 127 | +df_index += 1 |
| 128 | +footer = '''<style type="text/css"> |
| 129 | +.footer { |
| 130 | + position: relative; |
| 131 | + left: 0; |
| 132 | + width: 100%; |
| 133 | + text-align: center; |
| 134 | +} |
| 135 | +</style> |
| 136 | +<footer class="footer"> |
| 137 | + This report was generated with |
| 138 | + <a href="https://github.com/Multiomics-Analytics-Group/vuegen" target="_blank"> |
| 139 | + <img src="https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.svg" alt="VueGen" width="65px"> |
| 140 | + </a> |
| 141 | + | Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank"> |
| 142 | + Multiomics Network Analytics Group (MoNA) |
| 143 | + </a> |
| 144 | +</footer>''' |
| 145 | + |
| 146 | +st.markdown(footer, unsafe_allow_html=True) |
0 commit comments