Skip to content

Commit

Permalink
Add Triptych for set to set comparison (#591)
Browse files Browse the repository at this point in the history
(making a PR from the branch because I want to play with the deploy
preview)

---------

Co-authored-by: Vincent Rubinetti <[email protected]>
  • Loading branch information
kevinschaper and vincerubinetti authored Feb 16, 2024
1 parent fd3abac commit 7761950
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 180 deletions.
Empty file removed .DS_Store
Empty file.
10 changes: 5 additions & 5 deletions backend/tests/fixtures/phenotype_explorer_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ def phenotype_explorer_compare():
"HP:0004325": {
"match_source": "HP:0004325",
"match_source_label": "Decreased body weight (HPO)",
"match_target": "MP:0010771",
"match_target_label": "integument phenotype (MPO)",
"match_target": "MP:0002169",
"match_target_label": "no abnormal phenotype detected (MPO)",
"score": 1.5540019332516637,
"match_subsumer": None,
"match_subsumer_label": None,
"similarity": {
"subject_id": "HP:0004325",
"subject_label": None,
"subject_source": None,
"object_id": "MP:0010771",
"object_id": "MP:0002169",
"object_label": None,
"object_source": None,
"ancestor_id": "UPHENO:0001003",
Expand All @@ -87,10 +87,10 @@ def phenotype_explorer_compare():
"object_information_content": None,
"subject_information_content": None,
"ancestor_information_content": 1.5540019332516637,
"jaccard_similarity": 0.24,
"jaccard_similarity": 0.23076923076923078,
"cosine_similarity": None,
"dice_similarity": None,
"phenodigm_score": 0.61070489107293,
"phenodigm_score": 0.5988454147360435,
},
}
},
Expand Down
26 changes: 13 additions & 13 deletions backend/tests/fixtures/phenotype_explorer_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def phenotype_explorer_search():
"ZP:0018569": TermInfo(id="ZP:0018569", label="myeloid cell development absent, abnormal (ZPO)")
},
object_termset={
"HP:0002104": TermInfo(id="HP:0002104", label="Apnea (HPO)"),
"HP:0012378": TermInfo(id="HP:0012378", label="Fatigue (HPO)"),
"HP:0002104": TermInfo(id="HP:0002104", label="Apnea (HPO)"),
},
subject_best_matches={
"ZP:0018569": BestMatch(
Expand Down Expand Up @@ -427,8 +427,8 @@ def phenotype_explorer_search():
"ZP:0018568": TermInfo(id="ZP:0018568", label="primitive hemopoiesis absent, abnormal (ZPO)"),
},
object_termset={
"HP:0012378": TermInfo(id="HP:0012378", label="Fatigue (HPO)"),
"HP:0002104": TermInfo(id="HP:0002104", label="Apnea (HPO)"),
"HP:0012378": TermInfo(id="HP:0012378", label="Fatigue (HPO)"),
},
subject_best_matches={
"ZP:0018568": BestMatch(
Expand Down Expand Up @@ -622,8 +622,8 @@ def phenotype_explorer_search():
score=7.234842285670967,
similarity=TermSetPairwiseSimilarity(
subject_termset={
"ZP:0018569": TermInfo(id="ZP:0018569", label="myeloid cell development absent, abnormal (ZPO)"),
"ZP:0018568": TermInfo(id="ZP:0018568", label="primitive hemopoiesis absent, abnormal (ZPO)"),
"ZP:0018569": TermInfo(id="ZP:0018569", label="myeloid cell development absent, abnormal (ZPO)"),
},
object_termset={
"HP:0002104": TermInfo(id="HP:0002104", label="Apnea (HPO)"),
Expand Down Expand Up @@ -716,16 +716,16 @@ def phenotype_explorer_search():
"HP:0012378": BestMatch(
match_source="HP:0012378",
match_source_label="Fatigue (HPO)",
match_target="ZP:0018569",
match_target_label="myeloid cell development absent, abnormal (ZPO)",
match_target="ZP:0018568",
match_target_label="primitive hemopoiesis absent, abnormal (ZPO)",
score=1.6836208034928104,
match_subsumer=None,
match_subsumer_label=None,
similarity=TermPairwiseSimilarity(
subject_id="HP:0012378",
subject_label=None,
subject_source=None,
object_id="ZP:0018569",
object_id="ZP:0018568",
object_label=None,
object_source=None,
ancestor_id="UPHENO:0001005",
Expand All @@ -734,10 +734,10 @@ def phenotype_explorer_search():
object_information_content=None,
subject_information_content=None,
ancestor_information_content=1.6836208034928104,
jaccard_similarity=0.47058823529411764,
jaccard_similarity=0.4444444444444444,
cosine_similarity=None,
dice_similarity=None,
phenodigm_score=0.8901079388591847,
phenodigm_score=0.8650294287846346,
),
),
},
Expand Down Expand Up @@ -881,16 +881,16 @@ def phenotype_explorer_search():
"HP:0002104": BestMatch(
match_source="HP:0002104",
match_source_label="Apnea (HPO)",
match_target="ZP:0018569",
match_target_label="myeloid cell development absent, abnormal (ZPO)",
match_target="ZP:0018568",
match_target_label="primitive hemopoiesis absent, abnormal (ZPO)",
score=9.08524944639702,
match_subsumer=None,
match_subsumer_label=None,
similarity=TermPairwiseSimilarity(
subject_id="HP:0002104",
subject_label=None,
subject_source=None,
object_id="ZP:0018569",
object_id="ZP:0018568",
object_label=None,
object_source=None,
ancestor_id="UPHENO:0034024",
Expand All @@ -899,10 +899,10 @@ def phenotype_explorer_search():
object_information_content=None,
subject_information_content=None,
ancestor_information_content=9.08524944639702,
jaccard_similarity=0.34615384615384615,
jaccard_similarity=0.3333333333333333,
cosine_similarity=None,
dice_similarity=None,
phenodigm_score=1.773384910034319,
phenodigm_score=1.7402346054863809,
),
),
"HP:0012378": BestMatch(
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/search_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def search_response():
return {
"responseHeader": {
"QTime": 3,
"QTime": 0,
"params": {
"mm": "100%",
"q": "fanconi",
Expand Down
10 changes: 7 additions & 3 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,26 @@ Include the widget on your page like so:
The widget accepts several URL parameters:

- `source` - Comma-separated list of "source" phenotype IDs (set A).
- `target` - Comma-separated list of "target" phenotype IDs (set B).
- `target` - "target" group of phenotypes to compare to (group B).
See `src/api/phenotype-explorer.ts` groups for enumerated options.
- `stylesheet` - A URI-encoded URL to a stylesheet that will be applied to the widget, for the purposes of matching its styles to your webpage.

### Events

The widget also emits `message` events to the parent window when certain things change, and listens for `message` events from the parent window to receive information.

#### Listens for `MessageEvent<{ source: string[], target: string[] }>`
#### Listens for `MessageEvent<{ source: string[], target: string }>`

Provide input phenotype lists to the widget when they might be [too long for a URL](https://www.google.com/search?q=max+url+length).

```js
// get your iframe dom element somehow
const iframe = document.querySelector("iframe");
// send it a message
iframe.contentWindow.postMessage({ source: ["abc"], target: ["def"] }, "*");
iframe.contentWindow.postMessage(
{ source: ["HP:123,HP:456"], target: "Human Diseases" },
"*",
);
```

#### Emits `MessageEvent<{ width: number; height: number; }>`
Expand Down
10 changes: 5 additions & 5 deletions frontend/fixtures/phenotype-explorer-compare.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@
"HP:0004325": {
"match_source": "HP:0004325",
"match_source_label": "Decreased body weight (HPO)",
"match_target": "MP:0010771",
"match_target_label": "integument phenotype (MPO)",
"match_target": "MP:0002169",
"match_target_label": "no abnormal phenotype detected (MPO)",
"score": 1.5540019332516637,
"match_subsumer": null,
"match_subsumer_label": null,
"similarity": {
"subject_id": "HP:0004325",
"subject_label": null,
"subject_source": null,
"object_id": "MP:0010771",
"object_id": "MP:0002169",
"object_label": null,
"object_source": null,
"ancestor_id": "UPHENO:0001003",
Expand All @@ -93,10 +93,10 @@
"object_information_content": null,
"subject_information_content": null,
"ancestor_information_content": 1.5540019332516637,
"jaccard_similarity": 0.24,
"jaccard_similarity": 0.23076923076923078,
"cosine_similarity": null,
"dice_similarity": null,
"phenodigm_score": 0.61070489107293
"phenodigm_score": 0.5988454147360435
}
}
},
Expand Down
Loading

0 comments on commit 7761950

Please sign in to comment.