Spaces:
Paused
Paused
Erva Ulusoy commited on
Commit Β·
799a0a4
1
Parent(s): 8659531
add known annotation filtering
Browse filesAdd Novel/Known prediction filters to GO and EC result tables and document how existing knowledge graph annotations affect predictions.
Files changed (2)
- ProtHGT_app.py+24-2
- pages/User_Guide.py+22-6
467 unmodified lines4684694704714724738 unmodified lines4824834844854864874884 unmodified lines49349449549649749848 unmodified lines5475485495505515525532 unmodified lines556557558559560561467 unmodified linesreturn df.sort_values("Probability", ascending=False, ignore_index=True)@st.fragmentdef render_predictions(df, threshold):if df.empty:8 unmodified linesaspects = f2.pills("Aspect", available, selection_mode="multi", default=available,format_func=lambda c: ASPECT_SHORT[CATEGORY_TO_KEY[c]])text = f3.text_input("Search GO ID or term", placeholder="e.g. GO:0005524 or binding")min_score = st.slider("Minimum score", float(threshold), 1.0, float(threshold), step=0.01)view = dfif protein != "All proteins":4 unmodified linesview = view[view["GO_ID"].str.contains(t, case=False, regex=False)| view["GO_term"].str.contains(t, case=False, regex=False)]view = view[view["Probability"] >= min_score]display = view.assign(UniProt_ID="https://www.uniprot.org/uniprotkb/" + view["UniProt_ID"] + "/entry",48 unmodified linesavailable = [lv for lv in all_levels if lv in set(df["EC_level"])]levels = f2.pills("Level", available, selection_mode="multi", default=available, key="ec_levels")text = f3.text_input("Search EC number", placeholder="e.g. 2.7.11", key="ec_search")min_score = st.slider("Minimum score", float(threshold), 1.0, float(threshold), step=0.01, key="ec_min")view = dfif protein != "All proteins":2 unmodified linesif text.strip():view = view[view["EC"].str.contains(text.strip(), case=False, regex=False)]view = view[view["Probability"] >= min_score]display = view.assign(UniProt_ID="https://www.uniprot.org/uniprotkb/" + view["UniProt_ID"] + "/entry",467 unmodified lines4684694704714724734744754764774784794804814824834844858 unmodified lines4944954964974984995005015025035044 unmodified lines50951051151251351451548 unmodified lines5645655665675685695705715725735742 unmodified lines577578579580581582583467 unmodified linesreturn df.sort_values("Probability", ascending=False, ignore_index=True)KNOWN_FILTERS = ("All predictions", "Novel only", "Known only")def _filter_known(view, choice):"""Keep all rows, only those not annotated in the knowledge graph, or only the annotated ones."""if choice == "Novel only":return view[~view["known_annotation"]]if choice == "Known only":return view[view["known_annotation"]]return view@st.fragmentdef render_predictions(df, threshold):if df.empty:8 unmodified linesaspects = f2.pills("Aspect", available, selection_mode="multi", default=available,format_func=lambda c: ASPECT_SHORT[CATEGORY_TO_KEY[c]])text = f3.text_input("Search GO ID or term", placeholder="e.g. GO:0005524 or binding")s1, s2 = st.columns([2.8, 1.2])min_score = s1.slider("Minimum score", float(threshold), 1.0, float(threshold), step=0.01)known = s2.selectbox("Known annotations", KNOWN_FILTERS, key="go_known",help="Novel: not annotated to the protein in the ProtHGT knowledge graph. ""Known: already annotated there.")view = dfif protein != "All proteins":4 unmodified linesview = view[view["GO_ID"].str.contains(t, case=False, regex=False)| view["GO_term"].str.contains(t, case=False, regex=False)]view = view[view["Probability"] >= min_score]view = _filter_known(view, known)display = view.assign(UniProt_ID="https://www.uniprot.org/uniprotkb/" + view["UniProt_ID"] + "/entry",48 unmodified linesavailable = [lv for lv in all_levels if lv in set(df["EC_level"])]levels = f2.pills("Level", available, selection_mode="multi", default=available, key="ec_levels")text = f3.text_input("Search EC number", placeholder="e.g. 2.7.11", key="ec_search")s1, s2 = st.columns([2.8, 1.2])min_score = s1.slider("Minimum score", float(threshold), 1.0, float(threshold), step=0.01, key="ec_min")known = s2.selectbox("Known annotations", KNOWN_FILTERS, key="ec_known",help="Novel: not annotated to the protein in the ProtHGT knowledge graph. ""Known: already annotated there.")view = dfif protein != "All proteins":2 unmodified linesif text.strip():view = view[view["EC"].str.contains(text.strip(), case=False, regex=False)]view = view[view["Probability"] >= min_score]view = _filter_known(view, known)display = view.assign(UniProt_ID="https://www.uniprot.org/uniprotkb/" + view["UniProt_ID"] + "/entry",
51 unmodified lines525354555657585960616263646566672 unmodified lines70717273747551 unmodified linesst.markdown("""Each selected prediction type gets its own tab.- **GO terms** β a sortable table with links to UniProt and QuickGO. Filter by protein, aspect,GO ID / term text and minimum score. Hover the table and use its toolbar (top-right) to search it,download it as CSV, or open it full-screen.- **EC numbers** β EC predictions as a consistent top-down chain (L1 class β L4 full number), with theenzyme class/name and links to the ExPASy ENZYME database. A protein can stop at an intermediate levelwhen no deeper level passes the threshold, and non-enzymes return no EC number. Filter by protein,level, EC text and minimum score; the table toolbar downloads, searches and expands it as above.- **Known annotation** β both tables have a column that is ticked when the prediction is already anannotation of the protein in the knowledge graph: the same GO term, the same EC number, or (for EC levelsL1βL3) a class containing one of the protein's EC numbers. The model sees these annotations as input,so they usually score high; unticked rows are new candidate predictions.- **Knowledge graph** β for runs of up to 10 proteins, view the subgraph around a protein (with optionalsecond-degree edges) and download the shown edges as JSON.2 unmodified linesThe first run after the Space starts downloads the knowledge graph (~1 GB), which can take a few extra minutes.""")st.subheader("Knowledge graph view")st.markdown(KG_VIEW_GUIDE)51 unmodified lines52535455565758596061626364652 unmodified lines68697071727374757677787980818283848586878889909151 unmodified linesst.markdown("""Each selected prediction type gets its own tab.- **GO terms** β a sortable table with links to UniProt and QuickGO. Filter by protein, aspect,GO ID / term text, minimum score and known annotations. Hover the table and use its toolbar (top-right) to search it,download it as CSV, or open it full-screen.- **EC numbers** β EC predictions as a consistent top-down chain (L1 class β L4 full number), with theenzyme class/name and links to the ExPASy ENZYME database. A protein can stop at an intermediate levelwhen no deeper level passes the threshold, and non-enzymes return no EC number. Filter by protein,level, EC text, minimum score and known annotations; the table toolbar downloads, searches and expands it as above.- **Known** column β in both tables, marks predictions that are already annotations of the protein(see *Known annotations in the results* below).- **Knowledge graph** β for runs of up to 10 proteins, view the subgraph around a protein (with optionalsecond-degree edges) and download the shown edges as JSON.2 unmodified linesThe first run after the Space starts downloads the knowledge graph (~1 GB), which can take a few extra minutes.""")st.subheader("Known annotations in the results")st.markdown("""Predictions are generated on the full ProtHGT knowledge graph, so the existing GO and EC annotations of thequeried proteins are available to the model during inference. This makes the tool suited to **annotationcompletion**: suggesting functions that are missing from a protein's current annotation profile.Each result table includes a **Known** (known annotation) column, which marks predictions that are alreadypresent in the knowledge graph for that protein. For EC predictions at the class levels (L1βL3), a predictionis marked as known if it is a prefix of one of the protein's known complete EC numbers. To see only novelcandidate functions, set the **Known annotations** filter above the table to *Novel only*. For EC numbers,this can hide the known parent classes of a novel prediction.For predictions without access to a protein's existing annotations of the predicted type (e.g. forvalidation), use the command-line `predict.py` with the `--mask_existing` flag in the[ProtHGT repository](https://github.com/HUBioDataLab/ProtHGT). It hides the GO annotations for GO termprediction and the EC annotations for EC number prediction.""")st.subheader("Knowledge graph view")st.markdown(KG_VIEW_GUIDE)
ProtHGT_app.py+24-2
pages/User_Guide.py+22-6