Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable apps based on study metadata #732

Merged
merged 17 commits into from
Dec 20, 2023
Merged

Conversation

asizemore
Copy link
Member

@asizemore asizemore commented Dec 14, 2023

Resolves #731 , child of #407

The two correlation apps require particular data to run. Some studies don't have these data, so for those cases we want to show a disabled app. More specifically,

  • correlation assay x metadata requires at least one continuous metadata variable on an entity that is on a one-to-one path with the assay
  • correlation assay x assay is specifically for taxa vs functional data. "Functional data" means data from a metagenomic assay, which is an entity that not all studies have.

I also used the same architecture for the above checks to address #723

To Dos

  • add some isEnabled function to the apps
  • disable all vizs in the app if the app is disabled
  • can also do this one Hide apps if no collections exist #723 ?
  • have the app give a reason that it's not available
  • remove all the ts-ignores :)
  • repeat for correlation assay v metadata
  • improve comments

For testing, some helpful studies include:

  • BONUS. Both corrleation apps should be available
  • DailyBaby. Should have only the assay x metadata correlation app
  • HMP WGS. Should have only the assay x assay (Functional associations) app
  • HMP V1-V3. Should have neither app

@asizemore asizemore marked this pull request as ready for review December 19, 2023 11:37
@asizemore
Copy link
Member Author

Dear reviewers,

Please pay close attention to

  1. The logic in correlationAssayMetadata.tsx for checking the right variables
  2. The typing of entityTreeToArray output to ensure that wouldn't break anything else

Thank you!

@asizemore
Copy link
Member Author

@reviewers i added some studies in the description to help with testing

Copy link
Member

@dmfalke dmfalke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks great. Just a couple of suggestions.

I'm not crazy about the look:
image

It sort of looks like that app is selected.

What about something like this:

image

I removed the background color, and dropped the opacity to 0.4.

Co-authored-by: Dave Falke <dfalke@uga.edu>
@asizemore
Copy link
Member Author

I removed the background color, and dropped the opacity to 0.4.

Ahh this looks much much better. Good idea. I'll see if i can get the "Not applicable..." text to show up a bit more... to be continued!

And @dmfalke thank you for your other suggestions - they've all been added!

Copy link
Member

@bobular bobular left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks great but no correlation apps are enabled for DailyBaby 😞

It should have the Correlation "Discover taxa or genes correlated with metadata" app, right? Because it has 1:1:1 PRM:Samples:Assays and there is a continuous Age variable on PRM.

const studyHasCollections = entities.some(
(e): e is StudyEntity & Required<Pick<StudyEntity, 'collections'>> =>
!!e.collections?.length
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How important is the type predicate assertion here? If we were filtering and then doing something with the result (especially if an array result of StudyEntities), it would be useful. But I'm not sure the extra complication wins us anything here because the some just returns true/false.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Simplified in the latest commit!

const entities = entityTreeToArray(studyMetadata.rootEntity);
const hasMetagenomicData =
entities.filter((entity) => entity.id === 'OBI_0002623').length > 0; // OBI_0002623 = Metagenomic sequencing assay

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to check for non-zero length collections here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right we should. I was making the assumption that if that entity existed, then it would have a collection. But just becasue that's generally true doesn't mean it will always be the case! I'll add a check

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, an entities.find(...) !== undefined might be very very slightly marginally more efficient! (because it stops the search as soon as it finds something - but these arrays are tiny, so it will make very little difference)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I guess entities.some(...) works too!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still possible that the study with collections and a OBI_0002623 assay with no collections could get through, I think?

Maybe just this?

  const hasMetagenomicData = entities.some((entity) => entity.id === 'OBI_0002623' && !!entity.collections?.length);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack you're right! All fixed now!

I was interested so I looked into the difference in performance between some and find. It seems some is ever so slightly more efficient, since find calls some. But you're right it wouldn't matter on an array of this size anyway.

'EUPATH_0000809',
'EUPATH_0000813',
'EUPATH_0000812',
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a long term plan (e.g. ticket) to annotate entities appropriately to reduce the amount of hardcoded entity IDs? (If that's agreed to be a plan.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question. I just made a ticket for it but i think it could use some more discussion. There wasn't originally a long-term plan because i didn't think that i would end up needing these assay ids at all until i got into the implementation.

To completely remove the hardcoded ids we'd need to add the following annotations:

  1. To the study, add hasMetagenomicData. I think there's a similar hasMapData annotation?
  2. To each entity, add isAssay. Or i suppose it could be something like entityType = 'assay', if there are other entity types that might be useful to us.

Also open to other solutions!

(entity) => entity.isManyToOneWithParent
);
const oneToOneAncestors = ancestorEntities.slice(
1, // removing the assay itself
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we assume there are no continuous 'metadata variables' on the same entity as the assay entity?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. That assay entity should only have assay data.

@asizemore
Copy link
Member Author

@dmfalke what do you think of the below? I faked transparency by lightening the gray of the text to a hue that matches what it'd look like if it was transparent.
The implementation isn't elegant, though. Check it out in the latest commit!

Screen Shot 2023-12-20 at 5 41 02 AM

@asizemore
Copy link
Member Author

no correlation apps are enabled for DailyBaby 😞

Oh no! Turns out that Age variable is an integer, not a number, so i was missing it. Fixed in the latest commit. Good catch @bobular !

@bobular
Copy link
Member

bobular commented Dec 20, 2023

Transparency faking looks good to me. I don't think there's another way.

Copy link
Member

@bobular bobular left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me (though I haven't fired it up again to test).

I left one pedantic logic query.

const entities = entityTreeToArray(studyMetadata.rootEntity);
const hasMetagenomicData =
entities.filter((entity) => entity.id === 'OBI_0002623').length > 0; // OBI_0002623 = Metagenomic sequencing assay

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still possible that the study with collections and a OBI_0002623 assay with no collections could get through, I think?

Maybe just this?

  const hasMetagenomicData = entities.some((entity) => entity.id === 'OBI_0002623' && !!entity.collections?.length);

@asizemore asizemore merged commit 1f0a13d into main Dec 20, 2023
1 check passed
@asizemore asizemore deleted the feature-731-disable-apps-by-study branch December 20, 2023 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mbio: Studies with no appropriate metadata should not see the assay v metadata correlation app
3 participants