Spaces:
Build error
Build error
add query params support and gene_symbol
Browse files
app.py
CHANGED
|
@@ -6,6 +6,21 @@ import altair as alt
|
|
| 6 |
|
| 7 |
st.set_page_config(layout='wide')
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
st.markdown("""
|
| 10 |
# CryptoCEN Expression Scatter
|
| 11 |
**CryptoCEN** is a co-expression network for *Cryptococcus neoformans* built on 1,524 RNA-seq runs across 34 studies.
|
|
@@ -45,26 +60,28 @@ col1, col2, padding = st.columns(spec = [0.2, 0.2, 0.6])
|
|
| 45 |
with col1:
|
| 46 |
gene_id_1 = st.text_input(
|
| 47 |
label = "Gene ID 1",
|
| 48 |
-
value = "
|
| 49 |
max_chars = 10,
|
| 50 |
help = "CNAG Gene ID e.g. CNAG_04365")
|
| 51 |
|
| 52 |
with col2:
|
| 53 |
gene_id_2 = st.text_input(
|
| 54 |
label = "Gene ID 2",
|
| 55 |
-
value = "
|
| 56 |
max_chars = 10,
|
| 57 |
help = "CNAG Gene ID e.g. CNAG_04222")
|
| 58 |
|
| 59 |
# check the user input
|
| 60 |
try:
|
| 61 |
-
cnag_id_1 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_1]["cnag_id"].values
|
|
|
|
| 62 |
description_1 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_1]["description"].values[0]
|
| 63 |
except:
|
| 64 |
st.error(f"Unable to locate cnag_id for Gene ID 1: {gene_id_1}, it should be of the form 'CNAG_######'")
|
| 65 |
|
| 66 |
try:
|
| 67 |
-
cnag_id_2 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_2]["cnag_id"].values
|
|
|
|
| 68 |
description_2 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_2]["description"].values[0]
|
| 69 |
except:
|
| 70 |
st.error(f"Unable to locate cnag_id for Gene ID 2: {gene_id_2}, it should be of the form 'CNAG_######'")
|
|
@@ -79,12 +96,14 @@ chart_data = chart_data.merge(
|
|
| 79 |
|
| 80 |
st.markdown(f"""
|
| 81 |
#### Gene 1:
|
| 82 |
-
* *
|
| 83 |
-
* *
|
|
|
|
| 84 |
|
| 85 |
#### Gene 2:
|
| 86 |
-
* *
|
| 87 |
-
* *
|
|
|
|
| 88 |
""")
|
| 89 |
|
| 90 |
chart = (
|
|
|
|
| 6 |
|
| 7 |
st.set_page_config(layout='wide')
|
| 8 |
|
| 9 |
+
# parse out gene_ids from URL query args to it's possible to link to this page
|
| 10 |
+
query_params = st.query_params()
|
| 11 |
+
if "gene_id_1" %in% names(query_params):
|
| 12 |
+
gene_id_1 = query_params["gene_id_1"]
|
| 13 |
+
else:
|
| 14 |
+
gene_id_1 = "CNAG_04365"
|
| 15 |
+
|
| 16 |
+
if "gene_id_2" %in% names(query_params):
|
| 17 |
+
gene_id_2 = query_params["gene_id_2"]
|
| 18 |
+
else:
|
| 19 |
+
gene_id_2 = "CNAG_04222"
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
st.markdown("""
|
| 25 |
# CryptoCEN Expression Scatter
|
| 26 |
**CryptoCEN** is a co-expression network for *Cryptococcus neoformans* built on 1,524 RNA-seq runs across 34 studies.
|
|
|
|
| 60 |
with col1:
|
| 61 |
gene_id_1 = st.text_input(
|
| 62 |
label = "Gene ID 1",
|
| 63 |
+
value = f"{gene_id_1}",
|
| 64 |
max_chars = 10,
|
| 65 |
help = "CNAG Gene ID e.g. CNAG_04365")
|
| 66 |
|
| 67 |
with col2:
|
| 68 |
gene_id_2 = st.text_input(
|
| 69 |
label = "Gene ID 2",
|
| 70 |
+
value = f"{gene_id_2}",
|
| 71 |
max_chars = 10,
|
| 72 |
help = "CNAG Gene ID e.g. CNAG_04222")
|
| 73 |
|
| 74 |
# check the user input
|
| 75 |
try:
|
| 76 |
+
cnag_id_1 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_1]["cnag_id"].values[0]
|
| 77 |
+
gene_symbol_1 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_1]["gene_symbol"].values[0]
|
| 78 |
description_1 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_1]["description"].values[0]
|
| 79 |
except:
|
| 80 |
st.error(f"Unable to locate cnag_id for Gene ID 1: {gene_id_1}, it should be of the form 'CNAG_######'")
|
| 81 |
|
| 82 |
try:
|
| 83 |
+
cnag_id_2 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_2]["cnag_id"].values[0]
|
| 84 |
+
gene_symbol_2 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_2]["gene_symbol"].values[0]
|
| 85 |
description_2 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_2]["description"].values[0]
|
| 86 |
except:
|
| 87 |
st.error(f"Unable to locate cnag_id for Gene ID 2: {gene_id_2}, it should be of the form 'CNAG_######'")
|
|
|
|
| 96 |
|
| 97 |
st.markdown(f"""
|
| 98 |
#### Gene 1:
|
| 99 |
+
* *Gene ID*: [{gene_id_1}](https://fungidb.org/fungidb/app/record/gene/{gene_id_1})
|
| 100 |
+
{'* *Gene Symbol*:' + gene_symbol_1 if gene_symbol_1 is not None else ''}
|
| 101 |
+
* *Description*: {description_1}
|
| 102 |
|
| 103 |
#### Gene 2:
|
| 104 |
+
* *Gene ID*: [{gene_id_2}](https://fungidb.org/fungidb/app/record/gene/{gene_id_2})
|
| 105 |
+
{'* *Gene Symbol*:' + gene_symbol_2 if gene_symbol_2 is not None else ''}
|
| 106 |
+
* *Description*: {description_2}
|
| 107 |
""")
|
| 108 |
|
| 109 |
chart = (
|