diff --git a/.github/workflows/cdci.yml b/.github/workflows/cdci.yml index 13652a9..5bf89f2 100644 --- a/.github/workflows/cdci.yml +++ b/.github/workflows/cdci.yml @@ -118,6 +118,15 @@ jobs: echo "Error: One or more protected files have been modified." exit 1 fi + - name: streamlit report based on predefined config file + run: | + cd docs + vuegen -c example_config_files/Basic_example_vuegen_demo_notebook_config.yaml -output_dir ../tests/report_examples/Basic_example_vuegen_demo_notebook_cfg + # Check for changes + if git diff ../tests/report_examples | grep .; then + echo "Error: One or more protected files have been modified." + exit 1 + fi - name: check streamlit report files for chatbot API run: | vuegen -c docs/example_config_files/Chatbot_example_config.yaml -output_dir tests/report_examples/chat_bot @@ -208,7 +217,7 @@ jobs: - name: Build executable run: | cd gui - pyinstaller -n vuegen_gui --onefile --windowed --collect-all pyvis --collect-all streamlit --collect-all st_aggrid --collect-all customtkinter --collect-all quarto_cli --collect-all plotly --collect-all _plotly_utils --collect-all traitlets --collect-all referencing --collect-all rpds --collect-all tenacity --collect-all pandas --collect-all numpy --collect-all matplotlib --collect-all openpyxl --collect-all xlrd --collect-all nbformat --collect-all nbclient --collect-all altair --collect-all itables --collect-all kaleido --collect-all pyarrow --collect-all dataframe_image --collect-all narwhals --collect-all PIL --collect-all vl_convert --collect-all typing-extensions --add-data ../docs/example_data/Basic_example_vuegen_demo_notebook:example_data/Basic_example_vuegen_demo_notebook --add-data ../docs/images/vuegen_logo.png:. app.py + pyinstaller -n vuegen_gui --onefile --windowed --collect-all pyvis --collect-all streamlit --collect-all st_aggrid --collect-all customtkinter --collect-all quarto_cli --collect-all plotly --collect-all _plotly_utils --collect-all traitlets --collect-all referencing --collect-all rpds --collect-all tenacity --collect-all pandas --collect-all numpy --collect-all matplotlib --collect-all openpyxl --collect-all xlrd --collect-all nbformat --collect-all nbclient --collect-all altair --collect-all itables --collect-all kaleido --collect-all pyarrow --collect-all dataframe_image --collect-all narwhals --collect-all PIL --collect-all vl_convert --collect-all typing-extensions --add-data ../docs/example_data/Basic_example_vuegen_demo_notebook:example_data/Basic_example_vuegen_demo_notebook --add-data ../docs/images/logo/vuegen_logo.png:. app.py # --windowed only for mac, see: # https://pyinstaller.org/en/stable/usage.html#building-macos-app-bundles # 'Under macOS, PyInstaller always builds a UNIX executable in dist.' diff --git a/docs/example_config_files/Basic_example_vuegen_demo_notebook_config.yaml b/docs/example_config_files/Basic_example_vuegen_demo_notebook_config.yaml index a54a1a2..cac4260 100644 --- a/docs/example_config_files/Basic_example_vuegen_demo_notebook_config.yaml +++ b/docs/example_config_files/Basic_example_vuegen_demo_notebook_config.yaml @@ -1,8 +1,8 @@ report: title: Basic Example Vuegen Demo Notebook description: A general description of the report. - graphical_abstract: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.png - logo: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.png + graphical_abstract: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png + logo: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png sections: - title: Plots description: This section contains example plots. diff --git a/docs/example_data/Basic_example_vuegen_demo_notebook/5_Markdown/1_All_markdown/README.md b/docs/example_data/Basic_example_vuegen_demo_notebook/5_Markdown/1_All_markdown/README.md index be93449..70ea330 100644 --- a/docs/example_data/Basic_example_vuegen_demo_notebook/5_Markdown/1_All_markdown/README.md +++ b/docs/example_data/Basic_example_vuegen_demo_notebook/5_Markdown/1_All_markdown/README.md @@ -1,8 +1,8 @@ -![VueGen Logo](https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.png) +![VueGen Logo](https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png)

VueGen is a Python library that automates the creation of scientific reports. diff --git a/docs/split_readme.py b/docs/split_readme.py index 22a7870..1792af8 100644 --- a/docs/split_readme.py +++ b/docs/split_readme.py @@ -3,7 +3,7 @@ # Mapping section titles to their corresponding filenames SECTION_MAPPING = { - "![VueGen Logo](https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.svg)": "home_page.md", + "![VueGen Logo](https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/HEAD/docs/images/logo/vuegen_logo.svg)": "home_page.md", "About the project": "about.md", "Installation": "installation.md", "Execution": "execution.md", diff --git a/docs/vuegen_basic_case_study.ipynb b/docs/vuegen_basic_case_study.ipynb index 431511e..6c8bd9d 100644 --- a/docs/vuegen_basic_case_study.ipynb +++ b/docs/vuegen_basic_case_study.ipynb @@ -273,7 +273,7 @@ }, "outputs": [], "source": [ - "vuegen_logo_path = \"https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.svg\"\n", + "vuegen_logo_path = \"https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png\"\n", "\n", "# Load the YAML file\n", "print(\n", @@ -443,7 +443,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "vuegen_py312", "language": "python", "name": "python3" }, @@ -457,7 +457,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.6" + "version": "3.12.9" } }, "nbformat": 4, diff --git a/docs/vuegen_basic_case_study_configfile.md b/docs/vuegen_basic_case_study_configfile.md index 6cb1d71..65d4b9b 100644 --- a/docs/vuegen_basic_case_study_configfile.md +++ b/docs/vuegen_basic_case_study_configfile.md @@ -6,8 +6,8 @@ The [configuration file](https://github.com/Multiomics-Analytics-Group/vuegen/bl report: title: Basic Example Vuegen Demo Notebook description: A general description of the report. - graphical_abstract: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.png - logo: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.png + graphical_abstract: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png + logo: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png sections: - title: Plots description: This section contains example plots. diff --git a/gui/Makefile b/gui/Makefile index 4688457..7cc703f 100644 --- a/gui/Makefile +++ b/gui/Makefile @@ -39,7 +39,7 @@ bundle: --collect-all vl_convert \ --collect-all typing-extensions \ --add-data ../docs/example_data/Basic_example_vuegen_demo_notebook:example_data/Basic_example_vuegen_demo_notebook \ - --add-data ../docs/images/vuegen_logo.png:. \ + --add-data ../docs/images/logo/vuegen_logo.png:. \ app.py diff --git a/src/vuegen/streamlit_reportview.py b/src/vuegen/streamlit_reportview.py index 67023eb..0c08cdb 100644 --- a/src/vuegen/streamlit_reportview.py +++ b/src/vuegen/streamlit_reportview.py @@ -699,7 +699,7 @@ def _generate_plot_content(self, plot) -> List[str]: ) ) else: - fpath = Path(html_plot_file).resolve().relative_to(Path.cwd()) + fpath = get_relative_file_path(html_plot_file).as_posix() plot_content.append( textwrap.dedent( f""" diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/html/quarto_report/quarto_report.qmd b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/html/quarto_report/quarto_report.qmd index 7d70822..c52762f 100644 --- a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/html/quarto_report/quarto_report.qmd +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/html/quarto_report/quarto_report.qmd @@ -52,7 +52,7 @@ report_dir = Path().cwd() ``` A general description of the report. -![](https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.png){fig-alt= width=90%} +![](https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png){fig-alt= width=90%} # Plots This section contains example plots. diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Dataframes/All_Formats.py b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Dataframes/All_Formats.py new file mode 100644 index 0000000..cb35180 --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Dataframes/All_Formats.py @@ -0,0 +1,201 @@ +from st_aggrid import AgGrid, GridOptionsBuilder +from vuegen import table_utils +import pandas as pd +import streamlit as st +df_index = 1 + + +st.markdown( + ( + "

All Formats

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

This subsection contains example dataframes.

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

Phyla Correlation Network Csv

" + ), + unsafe_allow_html=True) + +df = pd.read_csv('example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/1_phyla_correlation_network_csv.csv') + + +# Displays a DataFrame using AgGrid with configurable options. +grid_builder = GridOptionsBuilder.from_dataframe(df) +grid_builder.configure_default_column(editable=True, + groupable=True, + filter=True, +) +grid_builder.configure_side_bar(filters_panel=True, + columns_panel=True) +grid_builder.configure_selection(selection_mode="multiple") +grid_builder.configure_pagination(enabled=True, + paginationAutoPageSize=False, + paginationPageSize=20, +) +grid_options = grid_builder.build() + +AgGrid(df, gridOptions=grid_options, enable_enterprise_modules=True) + +# Button to download the df +df_csv = df.to_csv(sep=',', header=True, index=False + ).encode('utf-8') +st.download_button( + label="Download dataframe as CSV", + data=df_csv, + file_name=f"dataframe_{df_index}.csv", + mime='text/csv', + key=f"download_button_{df_index}") +df_index += 1 + +st.markdown( + ( + "

Abundance Table Example Xls

" + ), + unsafe_allow_html=True) + +selected_sheet = 0 +sheet_names = table_utils.get_sheet_names("example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/2_abundance_table_example_xls.xls") +selected_sheet = st.selectbox("Select a sheet to display", + options=sheet_names, + ) + +df = pd.read_excel('example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/2_abundance_table_example_xls.xls', sheet_name=selected_sheet) + + +# Displays a DataFrame using AgGrid with configurable options. +grid_builder = GridOptionsBuilder.from_dataframe(df) +grid_builder.configure_default_column(editable=True, + groupable=True, + filter=True, +) +grid_builder.configure_side_bar(filters_panel=True, + columns_panel=True) +grid_builder.configure_selection(selection_mode="multiple") +grid_builder.configure_pagination(enabled=True, + paginationAutoPageSize=False, + paginationPageSize=20, +) +grid_options = grid_builder.build() + +AgGrid(df, gridOptions=grid_options, enable_enterprise_modules=True) + +# Button to download the df +df_csv = df.to_csv(sep=',', header=True, index=False + ).encode('utf-8') +st.download_button( + label="Download dataframe as CSV", + data=df_csv, + file_name=f"dataframe_{df_index}.csv", + mime='text/csv', + key=f"download_button_{df_index}") +df_index += 1 + +st.markdown( + ( + "

Sample Info Example Txt

" + ), + unsafe_allow_html=True) + +df = pd.read_table('example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/3_sample_info_example_txt.txt') + + +# Displays a DataFrame using AgGrid with configurable options. +grid_builder = GridOptionsBuilder.from_dataframe(df) +grid_builder.configure_default_column(editable=True, + groupable=True, + filter=True, +) +grid_builder.configure_side_bar(filters_panel=True, + columns_panel=True) +grid_builder.configure_selection(selection_mode="multiple") +grid_builder.configure_pagination(enabled=True, + paginationAutoPageSize=False, + paginationPageSize=20, +) +grid_options = grid_builder.build() + +AgGrid(df, gridOptions=grid_options, enable_enterprise_modules=True) + +# Button to download the df +df_csv = df.to_csv(sep=',', header=True, index=False + ).encode('utf-8') +st.download_button( + label="Download dataframe as CSV", + data=df_csv, + file_name=f"dataframe_{df_index}.csv", + mime='text/csv', + key=f"download_button_{df_index}") +df_index += 1 + +st.markdown( + ( + "

Sample Info Example Parquet

" + ), + unsafe_allow_html=True) + +df = pd.read_parquet('example_data/Basic_example_vuegen_demo_notebook/2_Dataframes/1_All_formats/4_sample_info_example_parquet.parquet') + + +# Displays a DataFrame using AgGrid with configurable options. +grid_builder = GridOptionsBuilder.from_dataframe(df) +grid_builder.configure_default_column(editable=True, + groupable=True, + filter=True, +) +grid_builder.configure_side_bar(filters_panel=True, + columns_panel=True) +grid_builder.configure_selection(selection_mode="multiple") +grid_builder.configure_pagination(enabled=True, + paginationAutoPageSize=False, + paginationPageSize=20, +) +grid_options = grid_builder.build() + +AgGrid(df, gridOptions=grid_options, enable_enterprise_modules=True) + +# Button to download the df +df_csv = df.to_csv(sep=',', header=True, index=False + ).encode('utf-8') +st.download_button( + label="Download dataframe as CSV", + data=df_csv, + file_name=f"dataframe_{df_index}.csv", + mime='text/csv', + key=f"download_button_{df_index}") +df_index += 1 +footer = ''' + + +''' + +st.markdown(footer, unsafe_allow_html=True) diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Home/Homepage.py b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Home/Homepage.py new file mode 100644 index 0000000..0131be5 --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Home/Homepage.py @@ -0,0 +1,32 @@ +import streamlit as st + +st.markdown( + ( + "

A general description of the report.

" + ), + unsafe_allow_html=True) + + +st.image('https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png', use_column_width=True) +footer = ''' + + +''' + +st.markdown(footer, unsafe_allow_html=True) diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Html/All_Html.py b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Html/All_Html.py new file mode 100644 index 0000000..cf89824 --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Html/All_Html.py @@ -0,0 +1,87 @@ +import requests +import streamlit as st + + +st.markdown( + ( + "

All Html

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

Plot

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/4_Html/1_All_html/1_plot.html', 'r', encoding='utf-8') as f: + html_content = f.read() + +st.components.v1.html(html_content, height=600, scrolling=True) + + +st.markdown( + ( + "

Ckg Network

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/4_Html/1_All_html/2_ckg_network.html', 'r') as html_file: + html_content = html_file.read() + + +st.markdown(("

" + "Number of nodes: 33

"), + unsafe_allow_html=True) +st.markdown(("

" + " Number of relationships: 35" + "

"), + unsafe_allow_html=True) + +# Streamlit checkbox for controlling the layout +control_layout = st.checkbox('Add panel to control layout', value=True) +net_html_height = 1200 if control_layout else 630 +# Load HTML into HTML component for display on Streamlit +st.components.v1.html(html_content, height=net_html_height) + + +st.markdown( + ( + "

Multiqc Report

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/4_Html/1_All_html/3_multiqc_report.html', 'r', encoding='utf-8') as f: + html_content = f.read() + +st.components.v1.html(html_content, height=600, scrolling=True) + +footer = ''' + + +''' + +st.markdown(footer, unsafe_allow_html=True) diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Markdown/All_Markdown.py b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Markdown/All_Markdown.py new file mode 100644 index 0000000..0bc96cd --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Markdown/All_Markdown.py @@ -0,0 +1,46 @@ +import requests +import streamlit as st + + +st.markdown( + ( + "

All Markdown

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

Readme

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/5_Markdown/1_All_markdown/README.md', 'r') as markdown_file: + markdown_content = markdown_file.read() + +st.markdown(markdown_content, unsafe_allow_html=True) + +footer = ''' + + +''' + +st.markdown(footer, unsafe_allow_html=True) diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Networks/Interactive_Networks.py b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Networks/Interactive_Networks.py new file mode 100644 index 0000000..3970cf1 --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Networks/Interactive_Networks.py @@ -0,0 +1,81 @@ +import requests +import streamlit as st + + +st.markdown( + ( + "

Interactive Networks

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

Optional description for subsection

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

Man Example

" + ), + unsafe_allow_html=True) + + +with open('../tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/static/Man_Example.html', 'r') as html_file: + html_content = html_file.read() + + +st.markdown(("

" + "Number of nodes: 9

"), + unsafe_allow_html=True) +st.markdown(("

" + " Number of relationships: 14" + "

"), + unsafe_allow_html=True) + +# Streamlit checkbox for controlling the layout +control_layout = st.checkbox('Add panel to control layout', value=True) +net_html_height = 1200 if control_layout else 630 +# Load HTML into HTML component for display on Streamlit +st.components.v1.html(html_content, height=net_html_height) + + +st.markdown( + ( + "

Description

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/3_Networks/1_Interactive_networks/description.md', 'r') as markdown_file: + markdown_content = markdown_file.read() + +st.markdown(markdown_content, unsafe_allow_html=True) + +footer = ''' + + +''' + +st.markdown(footer, unsafe_allow_html=True) diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Networks/Static_Networks.py b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Networks/Static_Networks.py new file mode 100644 index 0000000..6694581 --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Networks/Static_Networks.py @@ -0,0 +1,42 @@ +import streamlit as st + + +st.markdown( + ( + "

Static Networks

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

Phyla Correlation Network

" + ), + unsafe_allow_html=True) + + +st.image('example_data/Basic_example_vuegen_demo_notebook/3_Networks/2_Static_networks/1_phyla_correlation_network.png', caption='', use_column_width=True) + +footer = ''' + + +''' + +st.markdown(footer, unsafe_allow_html=True) diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Plots/Interactive_Plots.py b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Plots/Interactive_Plots.py new file mode 100644 index 0000000..4203a71 --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Plots/Interactive_Plots.py @@ -0,0 +1,151 @@ +import altair as alt +import json +import requests +import streamlit as st + + +st.markdown( + ( + "

Interactive Plots

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

Optional description for section.

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

Top Species Plot By Biome Plotly

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/1_top_species_plot_by_biome_plotly.json', 'r') as plot_file: + plot_json = json.load(plot_file) + +# Keep only 'data' and 'layout' sections +plot_json = {key: plot_json[key] for key in plot_json + if key in ['data', 'layout']} + +# Remove 'frame' section in 'data' +plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} + for entry in plot_json.get('data', [])] +st.plotly_chart(plot_json, use_container_width=True) + + +st.markdown( + ( + "

Multiline Plot Altair

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/2_multiline_plot_altair.json', 'r') as plot_file: + plot_json = json.load(plot_file) + +altair_plot = alt.Chart.from_dict(plot_json) +st.vega_lite_chart(json.loads(altair_plot.to_json()), + use_container_width=True) + + +st.markdown( + ( + "

Pie Plot Countries Plotly

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/3_pie_plot_countries_plotly.json', 'r') as plot_file: + plot_json = json.load(plot_file) + +# Keep only 'data' and 'layout' sections +plot_json = {key: plot_json[key] for key in plot_json + if key in ['data', 'layout']} + +# Remove 'frame' section in 'data' +plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} + for entry in plot_json.get('data', [])] +st.plotly_chart(plot_json, use_container_width=True) + + +st.markdown( + ( + "

Pie Plots Biomes Plotly

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/4_pie_plots_biomes_plotly.json', 'r') as plot_file: + plot_json = json.load(plot_file) + +# Keep only 'data' and 'layout' sections +plot_json = {key: plot_json[key] for key in plot_json + if key in ['data', 'layout']} + +# Remove 'frame' section in 'data' +plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} + for entry in plot_json.get('data', [])] +st.plotly_chart(plot_json, use_container_width=True) + + +st.markdown( + ( + "

Saline Metagenomics Samples Map Altair

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/5_saline_metagenomics_samples_map_altair.json', 'r') as plot_file: + plot_json = json.load(plot_file) + +altair_plot = alt.Chart.from_dict(plot_json) +st.vega_lite_chart(json.loads(altair_plot.to_json()), + use_container_width=True) + + +st.markdown( + ( + "

Description

" + ), + unsafe_allow_html=True) + + +with open('example_data/Basic_example_vuegen_demo_notebook/1_Plots/1_Interactive_plots/description.md', 'r') as markdown_file: + markdown_content = markdown_file.read() + +st.markdown(markdown_content, unsafe_allow_html=True) + +footer = ''' + + +''' + +st.markdown(footer, unsafe_allow_html=True) diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Plots/Static_Plots.py b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Plots/Static_Plots.py new file mode 100644 index 0000000..8d20e3f --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/Plots/Static_Plots.py @@ -0,0 +1,75 @@ +import streamlit as st + + +st.markdown( + ( + "

Static Plots

" + ), + unsafe_allow_html=True) + + +st.markdown( + ( + "

Number Samples Per Study

" + ), + unsafe_allow_html=True) + + +st.image('example_data/Basic_example_vuegen_demo_notebook/1_Plots/2_Static_plots/1_number_samples_per_study.png', caption='', use_column_width=True) + + +st.markdown( + ( + "

Animal Metagenomics Samples Map

" + ), + unsafe_allow_html=True) + + +st.image('example_data/Basic_example_vuegen_demo_notebook/1_Plots/2_Static_plots/2_animal_metagenomics_samples_map.png', caption='', use_column_width=True) + + +st.markdown( + ( + "

Alpha Diversity Host Associated Samples

" + ), + unsafe_allow_html=True) + + +st.image('example_data/Basic_example_vuegen_demo_notebook/1_Plots/2_Static_plots/3_alpha_diversity_host_associated_samples.png', caption='', use_column_width=True) + + +st.markdown( + ( + "

Graphical overview of VueGen workflow and components

" + ), + unsafe_allow_html=True) + + +st.image('https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_graph_abstract.png', caption='The diagram illustrates the processing pipeline of VueGen, starting from either a directory or a YAML configuration file. Reports consist of hierarchical sections and subsections, each containing various components such as plots, dataframes, Markdown, HTML, and data retrieved via API calls.', use_column_width=True) + +footer = ''' + + +''' + +st.markdown(footer, unsafe_allow_html=True) diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/report_manager.py b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/report_manager.py new file mode 100644 index 0000000..afb89c3 --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/sections/report_manager.py @@ -0,0 +1,58 @@ +import os +import time + +import psutil +import streamlit as st + +st.set_page_config(layout="wide", + page_title="Basic Example Vuegen Demo Notebook", + page_icon="https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png" +) +st.logo("https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/logo/vuegen_logo.png") + + +st.markdown( + ( + "

Basic Example Vuegen Demo Notebook

" + ), + unsafe_allow_html=True) + + +sections_pages = {} +homepage = st.Page('Home/Homepage.py', title='Homepage') +sections_pages['Home'] = [homepage] + +Interactive_Plots = st.Page('Plots/Interactive_Plots.py', title='Interactive Plots') +Static_Plots = st.Page('Plots/Static_Plots.py', title='Static Plots') +sections_pages['Plots'] = [Interactive_Plots, Static_Plots] + +All_Formats = st.Page('Dataframes/All_Formats.py', title='All Formats') +sections_pages['Dataframes'] = [All_Formats] + +Interactive_Networks = st.Page('Networks/Interactive_Networks.py', title='Interactive Networks') +Static_Networks = st.Page('Networks/Static_Networks.py', title='Static Networks') +sections_pages['Networks'] = [Interactive_Networks, Static_Networks] + +All_Html = st.Page('Html/All_Html.py', title='All Html') +sections_pages['Html'] = [All_Html] + +All_Markdown = st.Page('Markdown/All_Markdown.py', title='All Markdown') +sections_pages['Markdown'] = [All_Markdown] + +report_nav = st.navigation(sections_pages) + +# Following https://discuss.streamlit.io/t/close-streamlit-app-with-button-click/35132/5 +exit_app = st.sidebar.button("Shut Down App", + icon=":material/power_off:", + use_container_width=True) +if exit_app: + st.toast("Shutting down the app...") + time.sleep(1) + # Terminate streamlit python process + pid = os.getpid() + p = psutil.Process(pid) + p.terminate() + + +report_nav.run() diff --git a/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/static/Man_Example.html b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/static/Man_Example.html new file mode 100644 index 0000000..5aa9c86 --- /dev/null +++ b/tests/report_examples/Basic_example_vuegen_demo_notebook_cfg/streamlit_report/static/Man_Example.html @@ -0,0 +1,179 @@ + + + + + + + + + +
+

+
+ + + + + + +
+

+
+ + + + + +
+ + +
+
+ + + +
+ + + + + \ No newline at end of file