Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,6 +67,15 @@ mutation_site_headers = [
|
|
67 |
4510, 4561, 4615, 4668, 4720, 4773, 4828, 4882
|
68 |
]
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
st.title("ASCII & Binary Label Converter")
|
71 |
|
72 |
# Create tabs
|
@@ -157,32 +166,27 @@ with tab2:
|
|
157 |
|
158 |
with tab3:
|
159 |
st.write("Upload an Editing Frequency CSV or fill in manually:")
|
160 |
-
threshold_file = st.file_uploader("Upload Column Threshold CSV", type=["csv"], key="threshold")
|
161 |
ef_file = st.file_uploader("Upload Editing Frequency CSV", type=["csv"], key="ef")
|
162 |
|
163 |
-
if threshold_file:
|
164 |
-
thresholds_df = pd.read_csv(threshold_file, index_col=0)
|
165 |
-
thresholds = thresholds_df.squeeze()
|
166 |
-
|
167 |
if ef_file:
|
168 |
ef_df = pd.read_csv(ef_file)
|
169 |
else:
|
170 |
-
ef_df = pd.DataFrame(columns=thresholds.index
|
171 |
|
172 |
edited_df = st.data_editor(ef_df, num_rows="dynamic")
|
173 |
|
174 |
if st.button("Convert to Binary Labels"):
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
# Future: integrate DNA editor mapping for each mutation site here
|
|
|
67 |
4510, 4561, 4615, 4668, 4720, 4773, 4828, 4882
|
68 |
]
|
69 |
|
70 |
+
# Built-in thresholds
|
71 |
+
built_in_thresholds = {
|
72 |
+
3244: 0.5, 3297: 0.5, 3350: 0.5, 3399: 0.5, 3455: 0.5, 3509: 0.5, 3562: 0.5, 3614: 0.5,
|
73 |
+
3665: 0.5, 3720: 0.5, 3773: 0.5, 3824: 0.5, 3879: 0.5, 3933: 0.5, 3985: 0.5, 4039: 0.5,
|
74 |
+
4089: 0.5, 4145: 0.5, 4190: 0.5, 4245: 0.5, 4298: 0.5, 4349: 0.5, 4402: 0.5, 4455: 0.5,
|
75 |
+
4510: 0.5, 4561: 0.5, 4615: 0.5, 4668: 0.5, 4720: 0.5, 4773: 0.5, 4828: 0.5, 4882: 0.5
|
76 |
+
}
|
77 |
+
thresholds = pd.Series(built_in_thresholds)
|
78 |
+
|
79 |
st.title("ASCII & Binary Label Converter")
|
80 |
|
81 |
# Create tabs
|
|
|
166 |
|
167 |
with tab3:
|
168 |
st.write("Upload an Editing Frequency CSV or fill in manually:")
|
|
|
169 |
ef_file = st.file_uploader("Upload Editing Frequency CSV", type=["csv"], key="ef")
|
170 |
|
|
|
|
|
|
|
|
|
171 |
if ef_file:
|
172 |
ef_df = pd.read_csv(ef_file)
|
173 |
else:
|
174 |
+
ef_df = pd.DataFrame(columns=thresholds.index)
|
175 |
|
176 |
edited_df = st.data_editor(ef_df, num_rows="dynamic")
|
177 |
|
178 |
if st.button("Convert to Binary Labels"):
|
179 |
+
common_cols = list(set(edited_df.columns) & set(thresholds.index))
|
180 |
+
binary_part = edited_df[common_cols].ge(thresholds[common_cols]).astype(int)
|
181 |
+
non_binary_part = edited_df.drop(columns=common_cols, errors='ignore')
|
182 |
+
binary_df = pd.concat([non_binary_part, binary_part], axis=1)
|
183 |
+
st.subheader("Binary Labels")
|
184 |
+
st.dataframe(binary_df)
|
185 |
+
st.download_button(
|
186 |
+
label="Download Binary Labels Table as CSV",
|
187 |
+
data=binary_df.to_csv(index=False),
|
188 |
+
file_name="ef_binary_labels_table.csv",
|
189 |
+
mime="text/csv"
|
190 |
+
)
|
191 |
+
|
192 |
+
# Future: integrate DNA editor mapping for each mutation site here
|