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

init code refactoring #742

Merged

Conversation

Alexanderlacuna
Copy link
Contributor

Description

How should this be tested?

Any background context you want to provide?

What are the relevant pivotal tracker stories?

Screenshots (if appropriate)

Questions

Comment on lines 79 to 80
return not (float(trait.get('corr_coefficient', 0.0)) >= p_lower and
float(trait.get('corr_coefficient', 0.0)) <= p_upper)
Copy link
Collaborator

Choose a reason for hiding this comment

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

A more pythonic (and readable way) to write this is:

Suggested change
return not (float(trait.get('corr_coefficient', 0.0)) >= p_lower and
float(trait.get('corr_coefficient', 0.0)) <= p_upper)
return not (float(p_upper >= trait.get('corr_coefficient', 0.0)) >= p_lower)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome


def __min_filter__(min_expr):
if (target_dataset['type'] in ["ProbeSet", "Publish"] and target_trait['mean']):
return (min_expr != None) and (float(target_trait['mean']) < min_expr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar comment to above:

Suggested change
return (min_expr != None) and (float(target_trait['mean']) < min_expr)
return float(target_trait['mean']) > min_expr != None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BonfaceKilz the above example may lead to unintended results
for example

min_expr = None

return 2.4 < min_expr is not None

results to 
TypeError: '<' not supported between instances of 'float' and 'str'

and if you use bracket that means you will be comparing int to boolean

Comment on lines 93 to 100
return ((location_chr != None and (target_trait["chr"] != location_chr)
or
(min_location_mb != None) and (
float(target_trait['mb']) < min_location_mb)
or
max_location_mb != None) and
(float(target_trait['mb']) > float(max_location_mb)
))
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case too, you could chain operations together as demo'd above.

Comment on lines 102 to 109
return ((location_chr != None and (target_trait["lrs_chr"] != location_chr)
or
(min_location_mb != None) and (
float(target_trait['lrs_mb']) < float(min_location_mb))
or
(max_location_mb != None) and (
float(target_trait['lrs_mb']) > float(max_location_mb))
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same sentiment as above.

Comment on lines 278 to 281
dataset_metadata = generate_table_metadata({name for trait in corr_results
for (name, _val) in trait.items()},
correlation_data["traits_metadata"],
target_dataset_ob)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This nested "for" loop would be difficult to maintain. I'd advise using a more simpler, albeit verbose, loop instead.

@BonfaceKilz
Copy link
Collaborator

BonfaceKilz commented Nov 17, 2022 via email

@Alexanderlacuna
Copy link
Contributor Author

@zsloan could try this out and see if there are any issues?
Also check this out https://github.com/genenetwork/genenetwork2/pull/746/files

@fredmanglis fredmanglis merged commit da60eb2 into genenetwork:testing Nov 22, 2022
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.

None yet

3 participants