Skip to content

Commit

Permalink
Merge pull request #207 from biothings/pfocr-score-fix
Browse files Browse the repository at this point in the history
fix calculation of pfocr score
  • Loading branch information
tokebe authored Aug 20, 2024
2 parents 5789f6c + 9f7657b commit f29d19d
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/results_assembly/pfocr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,17 @@ export async function enrichTrapiResultsWithPfocrFigures(response: TrapiResponse
const matchedFigures: Set<string> = new Set();
const matchedTrapiResults: Set<TrapiResult> = new Set();

// const allGenesInAllFigures = figures.reduce((set, fig) => {
// fig.associatedWith.mentions.genes.ncbigene.forEach((gene) => set.add(gene));
// return set;
// }, new Set() as Set<string>);
const allGenesInAllFigures = figures.reduce((set, fig) => {
fig.associatedWith.mentions.genes.ncbigene.forEach((gene) => set.add(gene));
return set;
}, new Set() as Set<string>);

for (const trapiResult of results) {
// No figures match this result
if (!figuresByCuries[curieCombosByResult.get(trapiResult)]) continue;

const resultCuries = curiesByResult.get(trapiResult);
const resultGenesInAllFigures = intersection(allGenesInAllFigures, resultCuries);

(figuresByCuries[curieCombosByResult.get(trapiResult)] ?? []).forEach((figure) => {
if (!('pfocr' in trapiResult)) {
Expand All @@ -267,17 +268,12 @@ export async function enrichTrapiResultsWithPfocrFigures(response: TrapiResponse
const figureCurieSet = new Set(figure.associatedWith.mentions.genes.ncbigene);
const resultGenesInFigure = intersection(resultCuries, figureCurieSet);

const otherGenesInFigure = figureCurieSet.size - resultGenesInFigure.size;

const resultGenesInOtherFigures = [...resultCuries].filter((gene) => {
return figures.some((fig) => fig.associatedWith.mentions.genes.ncbigene.includes(gene));
}).length;
// let otherGenesInOtherFigures = [...allGenesInAllFigures].filter((gene) => {
// return !resultCuries.has(gene) && !figureCurieSet.has(gene);
// }).length;

const precision = resultGenesInFigure.size / (resultGenesInFigure.size + otherGenesInFigure);
const recall = resultGenesInFigure.size / (resultGenesInFigure.size + resultGenesInOtherFigures);
const precision = resultGenesInFigure.size / figureCurieSet.size;
const recall = resultGenesInFigure.size / resultGenesInAllFigures.size;

trapiResult.pfocr.push({
figureUrl: figure.associatedWith.figureUrl,
Expand Down

0 comments on commit f29d19d

Please sign in to comment.