Skip to content

Commit

Permalink
Update truthiness checks for phenotype frequency to always check for …
Browse files Browse the repository at this point in the history
…undefined to allow for zeroes (#784)

Also slightly updates the logic for the hover, to show original values
rather than anything computed
  • Loading branch information
kevinschaper authored Aug 15, 2024
1 parent 118dce1 commit 400ab72
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions frontend/src/pages/node/AssociationsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,34 +214,21 @@ const cols = computed((): Cols<Datum> => {
heading: "Frequency",
sortable: true,
},
// {
// key: "has_percentage",
// heading: "Frequency %",
// sortable: true,
// },
// {
// key: "has_count",
// heading: "Count",
// sortable: true,
// },
// {
// key: "has_total",
// heading: "Total",
// sortable: true,
// },
{
key: "onset_qualifier_label",
heading: "Onset",
sortable: true,
},
{
key: "original_subject",
heading: "Original Subject",
sortable: true,
},
);
}

//include original subject and call it Source for D2P
if (props.category.id.includes("DiseaseToPhenotypicFeature")) {
extraCols.push({
key: "original_subject",
heading: "Source",
sortable: true,
});
}
/** publication specific columns */
// if (props.category.label === "biolink:Publication")
// extraCols.push(
Expand Down Expand Up @@ -336,13 +323,14 @@ async function download() {
/** get phenotype frequency percentage 0-1 */
const frequencyPercentage = (row: DirectionalAssociation) => {
/** frequency from % out of 100 */
if (row.has_percentage) return row.has_percentage / 100;
if (row.has_percentage !== undefined) return row.has_percentage / 100;

/** frequency from ratio */
if (row.has_count && row.has_total) return row.has_count / row.has_total;

if (row.has_count !== undefined && row.has_total !== undefined) {
return row.has_count / row.has_total;
}
/** enumerated frequencies */
if (row.frequency_qualifier)
if (row.frequency_qualifier !== undefined)
switch (row.frequency_qualifier) {
case "HP:0040280":
return 1;
Expand All @@ -361,14 +349,19 @@ const frequencyPercentage = (row: DirectionalAssociation) => {

/** get frequency tooltip */
const frequencyTooltip = (row: DirectionalAssociation) => {
if (row.has_percentage)
return `${row.has_percentage.toFixed(0)}% of ${row.has_total} cases`;

if (row.has_count && row.has_total)
// display fraction if possible
if (row.has_count !== undefined && row.has_total !== undefined) {
return `${row.has_count} of ${row.has_total} cases`;
}

// if percentage is present but fraction isn't, that's what was originally in the data
if (row.has_percentage !== undefined && row.has_total !== undefined) {
return `${row.has_percentage.toFixed(0)}%`;
}
// if no percentage or fraction, display the qualifier label
if (row.frequency_qualifier) return `${row.frequency_qualifier_label}`;

// finally, there is no frequency info at all
return "No info";
};

Expand Down

0 comments on commit 400ab72

Please sign in to comment.