use estimated_expression_matrix.parquet
Browse files
app.py
CHANGED
@@ -35,16 +35,13 @@ estimated_expression_meta = estimated_expression_meta["estimated_expression_meta
|
|
35 |
|
36 |
estimated_expression = datasets.load_dataset(
|
37 |
path = "maomlab/CryptoCEN",
|
38 |
-
data_files = {"
|
39 |
estimated_expression = estimated_expression["estimated_expression"].to_pandas()
|
40 |
|
|
|
41 |
print(f"estimated_expression shape: {estimated_expression.shape}")
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
col1, col2, col3 = st.columns(spec = [0.2, 0.2, 0.6])
|
48 |
with col1:
|
49 |
gene_id_1 = st.text_input(
|
50 |
label = "Gene ID 1",
|
@@ -52,7 +49,6 @@ with col1:
|
|
52 |
max_chars = 10,
|
53 |
help = "CNAG Gene ID e.g. CNAG_04365")
|
54 |
|
55 |
-
|
56 |
with col2:
|
57 |
gene_id_2 = st.text_input(
|
58 |
label = "Gene ID 2",
|
@@ -60,20 +56,39 @@ with col2:
|
|
60 |
max_chars = 10,
|
61 |
help = "CNAG Gene ID e.g. CNAG_04222")
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
chart_data = pd.DataFrame({
|
64 |
-
"expression_1": np.log10(estimated_expression.loc[
|
65 |
-
"expression_2": np.log10(estimated_expression.loc[
|
66 |
"run_accession": estimated_expression.columns,
|
67 |
"run_accession_meta": estimated_expression_meta["run_accession"],
|
68 |
"study_accession": estimated_expression_meta["study_accession"]})
|
69 |
|
|
|
70 |
print(f"run_ids are equal: {sum(chart_data['run_accession'] == chart_data['run_accession_meta'])}")
|
71 |
|
72 |
chart = (
|
73 |
alt.Chart(chart_data)
|
74 |
.mark_circle()
|
75 |
-
.encode(
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
|
|
|
35 |
|
36 |
estimated_expression = datasets.load_dataset(
|
37 |
path = "maomlab/CryptoCEN",
|
38 |
+
data_files = {"estimated_expression_matrix": "estimated_expression_matrix.parquet"})
|
39 |
estimated_expression = estimated_expression["estimated_expression"].to_pandas()
|
40 |
|
41 |
+
#DEBUG
|
42 |
print(f"estimated_expression shape: {estimated_expression.shape}")
|
43 |
|
44 |
+
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",
|
|
|
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",
|
|
|
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"]
|
62 |
+
except:
|
63 |
+
st.error(f"Unable to locate cnag_id for Gene ID 1: {gene_id_1}, it should be of the form 'CNAG_######'")
|
64 |
+
|
65 |
+
try:
|
66 |
+
cnag_id_2 = h99_transcript_annotations.loc[h99_transcript_annotations["gene_id"] == gene_id_2]["cnag_id"]
|
67 |
+
except:
|
68 |
+
st.error(f"Unable to locate cnag_id for Gene ID 2: {gene_id_2}, it should be of the form 'CNAG_######'")
|
69 |
+
|
70 |
chart_data = pd.DataFrame({
|
71 |
+
"expression_1": np.log10(estimated_expression.loc[estiamted_expression.index == cnag_id_1].to_numpy()[0] + 1),
|
72 |
+
"expression_2": np.log10(estimated_expression.loc[estimated_expression_index == cnag_id_2].to_numpy()[0] + 1),
|
73 |
"run_accession": estimated_expression.columns,
|
74 |
"run_accession_meta": estimated_expression_meta["run_accession"],
|
75 |
"study_accession": estimated_expression_meta["study_accession"]})
|
76 |
|
77 |
+
# DEBUG
|
78 |
print(f"run_ids are equal: {sum(chart_data['run_accession'] == chart_data['run_accession_meta'])}")
|
79 |
|
80 |
chart = (
|
81 |
alt.Chart(chart_data)
|
82 |
.mark_circle()
|
83 |
+
.encode(
|
84 |
+
x="expression_1",
|
85 |
+
y="expression_2",
|
86 |
+
size=5,
|
87 |
+
color="study_accession",
|
88 |
+
tooltip=["run_accession", "study_accession"]))
|
89 |
+
|
90 |
+
st.altair_chart(
|
91 |
+
chart,
|
92 |
+
use_container_width=True)
|
93 |
|
94 |
|