Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding web explore #14

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import variant_deconv
import resistance_mut
import resistance_mut_silo
import web_explorer

PAGES = {
"Home": {"module": index},
"Mutation Frequency": {"module": mutation_freq},
"Variant Deconvolution": {"module": variant_deconv},
"Resistance Mutations (clinical)": {"module": resistance_mut},
"Resistance Mutations (ww)": {"module": resistance_mut_silo}
"Resistance Mutations (ww)": {"module": resistance_mut_silo},
"Web Explore": {"module": web_explorer}
}

def sidebar():
Expand Down
5 changes: 3 additions & 2 deletions resistance_mut_silo.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ def app():
# Apply the lambda function to each element in the mutations list
formatted_mutations = [format_mutation(mutation) for mutation in mutations]

st.write(f"Selected mutations:")
st.write(formatted_mutations)
if st.button("Show Mutations"):
st.write(f"Selected mutations:")
st.write(formatted_mutations)


# Allow the user to choose a date range
Expand Down
59 changes: 59 additions & 0 deletions web_explorer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import streamlit as st
import streamlit.components.v1 as components
import pandas as pd

LAPIS_URL = "http://localhost:8080"


def app():

## Add a title
st.title("V-Pipe Web Explorer")

## Add a header
st.header("Explore Mutations Over Time")

## Add a subheader
st.subheader("This page allows you to explore mutations over time by gene and proportion.")

## select dat range
st.write("Select a date range:")
date_range = st.date_input("Select a date range:", [pd.to_datetime("2024-09-30"), pd.to_datetime("2024-10-16")])

## Add a horizontal line
st.markdown("---")

start_date = date_range[0].strftime("%Y-%m-%d")
end_date = date_range[1].strftime("%Y-%m-%d")

components.html(
f"""
<html>
<head>
<script type="module" src="https://unpkg.com/@genspectrum/dashboard-components@latest/standalone-bundle/dashboard-components.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@genspectrum/dashboard-components@latest/dist/style.css" />
</head>
<body>
<!-- Component documentation: https://genspectrum.github.io/dashboard-components/?path=/docs/visualization-mutations-over-time--docs -->
<gs-app lapis="{LAPIS_URL}">
<gs-mutations-over-time
lapisFilter='{{"sampling_dateFrom":"{start_date}", "sampling_dateTo": "{end_date}"}}'
sequenceType='amino acid'
views='["grid"]'
width='100%'
height='100%'
granularity='day'
lapisDateField='sampling_date'
/>
</gs-app>
</head>
<body>
</body>
</html>
""",
height=3000,
)


if __name__ == "__main__":
app()