mild-blue / txmatching

Solver for kidney pair donation matching problems.
https://txm.demo.mild.blue
Other
2 stars 2 forks source link

Add soft cutoff #929

Open kubantjan opened 2 years ago

kubantjan commented 2 years ago

Add soft cutoff parameter to configuration

In matchings, send another set of antibodies to FE that have MFI between cutoff and soft cutoff with their crossmatch calculated.

jogobeny commented 2 years ago

Hello there (@kubantjan),

I guess I should add soft_cutoff to ConfigParameters in config_parameters.py.

For the second task, I can filter antibody matches from antibody_matches_dict (soft_cutoff <= MFI <= cutoff) in matching_service.get_matchings_detailed_for_pairing_result_model (or maybe get new antibody_matches_dict where I'd pass filtered recipient.hla_antibodies with the same filter I've used above), but I am not sure what to do with it then - shall I add new attribute to MatchingsDetailed?

kubantjan commented 2 years ago

I see the description is quite brief, so it needs some clarification. So here it is: 1) add soft_cutoff to ConfigParameters in config_parameters.py. 2) Add new attribute to MatchingsDetailed is a good idea. I guess smth like antibody_soft_matches_tuples would probably make good sense. But if you come up with another approach, please propose it. I will confirm that with FE people. But for the moment you can do it like that. Notes

jogobeny commented 2 years ago

Hi @kubantjan,

https://github.com/mild-blue/txmatching/blob/77d3a664c6ca5cea81de43f2108065ff75eb17f4/txmatching/database/services/matching_service.py#L96-L99 Is that what you mean? I mean recipient.hla_antibodies.hla_antibodies_per_groups.hla_antibody_list is also a list of antibodies with mfi & cutoff parameter and I'm not sure if I should filter that as well.

kristinagalik commented 2 years ago
  • I am asking here comment from @kristinagalik and @NotLubo whether my proposed placement of antibodies makes sense to them (related FE issue Show soft match antibodies #943 )

If it is supposed to be a new column or smth, then I think its fine. Maybe @NotLubo can still confirm this though.

Is that what you mean?

I would rather filter from recipient.hla_antibodies.hla_antibodies_per_groups... (you can see that it is accessed even in get_crossmatched_antibodies) because you can have recipient.hla_antibodies.hla_antibodies_raw_list empty. (why? no idea, dont have much time now, i can try to find out why this happens in the afternoon)

luborepka commented 2 years ago

I think that another column in situations, like presented in screenshot, would substantially decrease the readability. Better approach would be to think of way to distinguish them in present column – maybe by dividing them in to 2 groups, changing the color or perhaps both.

image
kubantjan commented 2 years ago

@NotLubo yep, here i was not after the design, more after the data format sent ot frontend, whether the proposed one will be ok. Otherwies I aggree. Maybe best would be to show just the ones that have some crossmatch in some less serious color (orange for example)

luborepka commented 2 years ago

Well if divide antibodies in 2 seperate arrays than if we wanted to show them in diferent colors we would have to join and sort them again in FE. I think we should keep all antibodies in one array and set them property soft_match or maybe we could use match_type?

kubantjan commented 2 years ago

EDIT: I have deleted the text about the extra property in the end. My original propsal is valid and should be the best way to approach this. I am sorry. finally we have discussed this in detail today with @kristinagalik and think that in the end it will be better to send the soft crossmatch antibodies in a separate array. Because we will never want to sort them toghether with the normal antibodies. We will want to put them behind the normal antibodies (maybe differ them by color or put them behind some line, I do not know yet, but surely we will not want to mix the normal and soft (so the argument of @NotLubo that the ordering on FE would be needed is not valid)

What is maybe missing in the description is that the matching types that are in the normal antibodies over cuttof dont make all sense in the case of soft antibodies. More specifically almost all matching types do.

What does not? an example: when we have a donor with A1 and a recipient with cutoff 2000 antibododies A*01:01, mfi 2500 and A01:02, mfi 1500 and A\02:01, mfi 1200

the system returns A*01:01, antibody_match_type.high_res_with_split

but in case of when we have a donor with A1,A3 and a recipient with cutoff 2000 antibododies A*01:01, mfi 2500 and A*01:02, mfi 2500 it would return A*01:01, antibody_match_type.high_res A*01:02, antibody_match_type.high_res

i.e. the match type of A*01:01 depends on the other antibodies.

But with soft ones we do not want to do that. in case we have soft_cutoff 1000 then:

when we have a donor with A1,A3 and a recipient with cutoff 2000 antibododies A*01:01, mfi 2500 and A*01:02, mfi 1500 and A*02:01, mfi 1200

the system returns antibodies: A*01:01, antibody_match_type.high_res_with_split antibodies_with_soft_crossmatch: A*01:02, antibody_match_type.hig_res_with_split (A*02:01 is not sent at all!)

and in case of when we have a donor with A1,A3 and a recipient with cutoff 2000 antibododies A*01:01, mfi 1500 and A*01:02, mfi 1500 and A*02:01, mfi 1200 it would return antibodies: [] antibodies_with_soft_crossmatch A*01:01, antibody_match_type.hig_res_with_split A*01:02, antibody_match_type.hig_res_with_split

So you see that even if both are above the soft crossmatch it does not make the overall crossmatch high res.

jogobeny commented 2 years ago

Hi @kubantjan,

do I get it right, that the only change in behaviour of using soft_cutoff is: we don't care about this case: if set(matching_antibodies) == set(antibodies_over_cutoff) == set(antibodies_with_high_res)?

So that means, the only case when antibodies with soft crossmatch can have AntibodyMatchTypes.HIGH_RES is: We have a donor with A*01:01, A*01:02 and a recipient with cutoff=2000, soft_cutoff=1000, [A*01:01, mfi=1500], [A*01:03, mfi=1500]: antibodies: [] antibodies_with_soft_crossmatch: ["A*01:01"]

And do antibodies_with_soft_crossmatch have AntibodyMatchTypes.NONE as well?

kubantjan commented 2 years ago

@jogobeny

kubantjan commented 1 year ago

presouvam do backlogu, ikem uzitecnost rozporoval, tak to neni uplne priorita..