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

feat: convert samples arg in Genotypes classes into a set #230

Merged
merged 6 commits into from
Dec 2, 2023

Conversation

aryarm
Copy link
Member

@aryarm aryarm commented Nov 30, 2023

closes #228 and overrides it

background

The Genotypes.read and Genotypes.__init__ methods expect samples to be provided as a list but make no guarantee that the samples will be loaded in the ordering requested. (This is because the underlying libraries that we use do not make this guarantee either.)

We first attempted to solve this issue in #225 by automatically reordering after reading the genotypes. But then we realized this would double the memory of the read() method.

PR #228 takes a different approach to the problem by adding a reorder_samples argument to the Genotypes classes that would do the reordering only if it is requested. This approach would also have required us to do more work to implement extra checks (see #228 (comment)). It also got us asking, from a design perspective, what makes the samples argument any different than the variants argument, which is currently typed as a set?

proposal

We ultimately decided that a better design approach would be to just copy the type of the variants argument and make the samples argument into a set, as well. If a user passes anything that isn't a set, we warn them and request that they use the subset() method after loading the genotypes. This approach ended up being a bit cleaner since the GenotypesPLINK classes actually need it to be a set, anyway.

@aryarm aryarm requested a review from mlamkin7 November 30, 2023 07:04
@aryarm
Copy link
Member Author

aryarm commented Nov 30, 2023

@mlamkin7, what do you think of this? Can you double-check that I managed to make changes in all of the places that I needed to? Should I try to add any tests, since this PR doesn't really add any? Is there anything else I can try to do to make it more obvious that the samples will not follow the requested ordering or catch that mistake and warn about it before it happens?

Copy link
Collaborator

@mlamkin7 mlamkin7 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. I know previously with my other PR I was going to have included the fix to having the TR Harmonizer dependency already downloaded. Is there any way we can port that into this PR. It should be under my PR I put out with the lazy param.

@mlamkin7
Copy link
Collaborator

mlamkin7 commented Dec 2, 2023

@mlamkin7, what do you think of this? Can you double-check that I managed to make changes in all of the places that I needed to? Should I try to add any tests, since this PR doesn't really add any? Is there anything else I can try to do to make it more obvious that the samples will not follow the requested ordering or catch that mistake and warn about it before it happens?

@mlamkin7 mlamkin7 closed this Dec 2, 2023
@mlamkin7 mlamkin7 reopened this Dec 2, 2023
@aryarm aryarm merged commit 2f2dea8 into sort_str_samples Dec 2, 2023
8 checks passed
@aryarm aryarm deleted the feat/samples-set branch December 2, 2023 17:50
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.

2 participants