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

Calculate variance explained #88

Merged
merged 9 commits into from
Aug 8, 2024
Merged

Calculate variance explained #88

merged 9 commits into from
Aug 8, 2024

Conversation

ejiawustl
Copy link
Collaborator

Added new file util.py in the probability models folder to include the function to calculate the explained variance using sklearn. Also added a new test suite to check that the function runs properly. Also have been playing around with the visualizing_and_testing_data_generation_methods notebook - will need to polish it further but it can become a good tutorial in the future

@ejiawustl ejiawustl requested a review from cmatKhan June 7, 2024 21:29
This is already in the dev dependencies. I forgot to go over that.

To add 'production' depdencies with python, you add to the default dependencies section with just:

```
poetry add <package>
```

You can also add dependencies to a group, eg:

```
poetry add --group dev <package>
```

See https://python-poetry.org/docs/cli/#options-4

That way, you can control what dependencies get installed.

For a typical user, I don't think we'll want to install jupyter in the environment. They should have jupyter in their environment, and then install yeastdnnexplorer into it.
@cmatKhan

This comment was marked as outdated.

Copy link
Member

@cmatKhan cmatKhan left a comment

Choose a reason for hiding this comment

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

I think the variance explained is still in the notebook -- is that correct?

I made a mistake when I had you change all the single/noise -- I should have used that as the example of the fork/branch/pull process. So many changes makes it difficult to focus on what is meaningful. My fault.

@cmatKhan
Copy link
Member

cmatKhan commented Jul 6, 2024

@ejiawustl see my last comment.

If you make a push to this branch on your fork, it will update this pull request automatically

@cmatKhan
Copy link
Member

cmatKhan commented Jul 6, 2024

closes #84

@cmatKhan
Copy link
Member

cmatKhan commented Jul 23, 2024

@ejiawustl -- it is not always obvious when it is necessary to add a function that wraps a scikit/numpy/whatever function for ease of use in the package context, and when not to. That is part of the art.

In this case, my decision is not to wrap the scikit variance explained function. That function seems to link together a couple steps -- basically evaluating the model -- and then uses the output to call the variance explained function. Since the modelling is something that the user should be doing themselves -- they'll need to make decisions, we can't automate that -- they should be able to also use the scikit variance explained function. We can certainly demonstrate how -- that should go into a tutorial.

Think about this. If there is a good reason to have this function in the codebase, please explain.

@ejiawustl
Copy link
Collaborator Author

@ejiawustl -- it is not always obvious when it is necessary to add a function that wraps a scikit/numpy/whatever function for ease of use in the package context, and when not to. That is part of the art.

In this case, my decision is not to wrap the scikit variance explained function. That function seems to link together a couple steps -- basically evaluating the model -- and then uses the output to call the variance explained function. Since the modelling is something that the user should be doing themselves -- they'll need to make decisions, we can't automate that -- they should be able to also use the scikit variance explained function. We can certainly demonstrate how -- that should go into a tutorial.

Think about this. If there is a good reason to have this function in the codebase, please explain.

Ok, after thinking about it some more I agree with this as well. We don't need the wrapper function, I think it was only something I was using at the time and was told to make it a function in the codebase.

…lained and adding the function to the visualizing_and_testing_data_generation_methods notebook
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

Add a top level heading and divide the rest of the notebook into subheadings where approproate. Top level heading could be, eg


Visualizing and Testing Data Generation


Reply via ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

You could even put a subheading here, eg

Generating the Data


Reply via ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

This would be a good place for a subheading, eg

Visualizing the Results


Reply via ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

Explain the axes, identify what each point means, then interpret


Reply via ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

Line #1.    def get_data_module(max_mean_adjustment, adjustment_function = default_perturbation_effect_adjustment_function, tf_relationships_dict = {}):

There should be type hints and a docstring, but if this isn't your function, don't worry about it


Reply via ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

Do not leave in commented out code unless there is a good reason


Reply via ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

Yes, explain the plot -- axes, what the point means, and what the plot overall means


Reply via ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

same thing re: output


Reply via ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

same thing re: output


Reply via ReviewNB

@@ -29,6 +29,8 @@
"\n",
Copy link
Member

@cmatKhan cmatKhan Jul 23, 2024

Choose a reason for hiding this comment

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

Describe the plot -- axes, what each point means, then what the plot overall means


Reply via ReviewNB

@ejiawustl ejiawustl requested a review from cmatKhan August 8, 2024 17:05
@cmatKhan cmatKhan merged commit 94a0313 into BrentLab:main Aug 8, 2024
7 checks passed
cmatKhan added a commit that referenced this pull request Aug 23, 2024
* Calculate variance explained (#88)

* fixed adjustment function so its based on enrichment strength

* added new file util.py and new test suite and updated notebook

* Update pyproject.toml

This is already in the dev dependencies. I forgot to go over that.

To add 'production' depdencies with python, you add to the default dependencies section with just:

```
poetry add <package>
```

You can also add dependencies to a group, eg:

```
poetry add --group dev <package>
```

See https://python-poetry.org/docs/cli/#options-4

That way, you can control what dependencies get installed.

For a typical user, I don't think we'll want to install jupyter in the environment. They should have jupyter in their environment, and then install yeastdnnexplorer into it.

* parameterizing the max_adjustment value and adding the calculate_variance_explained function and test suite

* removing the function and test suite for calculating the variance explained and adding the function to the visualizing_and_testing_data_generation_methods notebook

* Added docstrings and typehinting, removed unnecessary work and added exposition to graphs and methods

* updated notebook to use sphinx docstrings, added headings and subheadings and improved exposition

---------

Co-authored-by: Eric Jia <[email protected]>
Co-authored-by: Chase Mateusiak <[email protected]>

* fixed adjustment function so its based on enrichment strength (#86)

Co-authored-by: Eric Jia <[email protected]>

* Database Interface (#90)

* adding new file for explanation

* adding ParamsDict

* init implementation of the API classes. Documentation and some testing included. RankResponse is not, and the testing is minimal due to the difficulty of testing futures

* adding some words to the project ignore settings

* rank response api working

* addressing unused imports in RankResponseAPI

* updating the database_interface notebook for the new database backend; addressing logging warning on instantiation

* updating the tutorial to show how to use the aggregated data (#91)

* table data retrieved as gzip; addtiional columns now present from DB

* Update README.md

closes #81

* Adding update to manualqc (#96)

* removing new file, part of a demo

* adding update() method to bindingmanualqc; added _delimiter_detect method to AbstractRecords

* addressing pre-commit issues

---------

Co-authored-by: ejiawustl <[email protected]>
Co-authored-by: Eric Jia <[email protected]>
cmatKhan added a commit that referenced this pull request Aug 28, 2024
* adding perturbation response relationship tutorial

* addressed the changes to the notebook: added analysis to all graphs, typehinting and docstrings to methods, and other misc changes

* added new methods and analysis to enable comparison between different dataset combinations. Added everything under the last subtitle, with each section having smaller subheadings underneath to group everything

* Calculate variance explained (#88)

* fixed adjustment function so its based on enrichment strength

* added new file util.py and new test suite and updated notebook

* Update pyproject.toml

This is already in the dev dependencies. I forgot to go over that.

To add 'production' depdencies with python, you add to the default dependencies section with just:

```
poetry add <package>
```

You can also add dependencies to a group, eg:

```
poetry add --group dev <package>
```

See https://python-poetry.org/docs/cli/#options-4

That way, you can control what dependencies get installed.

For a typical user, I don't think we'll want to install jupyter in the environment. They should have jupyter in their environment, and then install yeastdnnexplorer into it.

* parameterizing the max_adjustment value and adding the calculate_variance_explained function and test suite

* removing the function and test suite for calculating the variance explained and adding the function to the visualizing_and_testing_data_generation_methods notebook

* Added docstrings and typehinting, removed unnecessary work and added exposition to graphs and methods

* updated notebook to use sphinx docstrings, added headings and subheadings and improved exposition

---------

Co-authored-by: Eric Jia <[email protected]>
Co-authored-by: Chase Mateusiak <[email protected]>

* fixed adjustment function so its based on enrichment strength (#86)

Co-authored-by: Eric Jia <[email protected]>

* Database Interface (#90)

* adding new file for explanation

* adding ParamsDict

* init implementation of the API classes. Documentation and some testing included. RankResponse is not, and the testing is minimal due to the difficulty of testing futures

* adding some words to the project ignore settings

* rank response api working

* addressing unused imports in RankResponseAPI

* updating the database_interface notebook for the new database backend; addressing logging warning on instantiation

* updating the tutorial to show how to use the aggregated data (#91)

* table data retrieved as gzip; addtiional columns now present from DB

* Update README.md

closes #81

* Adding update to manualqc (#96)

* removing new file, part of a demo

* adding update() method to bindingmanualqc; added _delimiter_detect method to AbstractRecords

* addressing pre-commit issues

* This is getting the dev branch rebased onto the main branch (#100)

* Calculate variance explained (#88)

* fixed adjustment function so its based on enrichment strength

* added new file util.py and new test suite and updated notebook

* Update pyproject.toml

This is already in the dev dependencies. I forgot to go over that.

To add 'production' depdencies with python, you add to the default dependencies section with just:

```
poetry add <package>
```

You can also add dependencies to a group, eg:

```
poetry add --group dev <package>
```

See https://python-poetry.org/docs/cli/#options-4

That way, you can control what dependencies get installed.

For a typical user, I don't think we'll want to install jupyter in the environment. They should have jupyter in their environment, and then install yeastdnnexplorer into it.

* parameterizing the max_adjustment value and adding the calculate_variance_explained function and test suite

* removing the function and test suite for calculating the variance explained and adding the function to the visualizing_and_testing_data_generation_methods notebook

* Added docstrings and typehinting, removed unnecessary work and added exposition to graphs and methods

* updated notebook to use sphinx docstrings, added headings and subheadings and improved exposition

---------

Co-authored-by: Eric Jia <[email protected]>
Co-authored-by: Chase Mateusiak <[email protected]>

* fixed adjustment function so its based on enrichment strength (#86)

Co-authored-by: Eric Jia <[email protected]>

* Database Interface (#90)

* adding new file for explanation

* adding ParamsDict

* init implementation of the API classes. Documentation and some testing included. RankResponse is not, and the testing is minimal due to the difficulty of testing futures

* adding some words to the project ignore settings

* rank response api working

* addressing unused imports in RankResponseAPI

* updating the database_interface notebook for the new database backend; addressing logging warning on instantiation

* updating the tutorial to show how to use the aggregated data (#91)

* table data retrieved as gzip; addtiional columns now present from DB

* Update README.md

closes #81

* Adding update to manualqc (#96)

* removing new file, part of a demo

* adding update() method to bindingmanualqc; added _delimiter_detect method to AbstractRecords

* addressing pre-commit issues

---------

Co-authored-by: ejiawustl <[email protected]>
Co-authored-by: Eric Jia <[email protected]>

* Add branch protection CI to prevent pulls directly to main (#101)

This should only allow pulls from a branch called `dev` or `patch` directly to main. otherwise, pull requests will be required to be against `dev`

* fixed adjustment function so its based on enrichment strength (#86)

Co-authored-by: Eric Jia <[email protected]>

* adding perturbation response relationship tutorial

* addressed the changes to the notebook: added analysis to all graphs, typehinting and docstrings to methods, and other misc changes

* added new methods and analysis to enable comparison between different dataset combinations. Added everything under the last subtitle, with each section having smaller subheadings underneath to group everything

* added docstring and typehinting to all methods, and added exposition to better explain the different conditions we use the model in. TODO: need to hide some of the output when training models or create an issue if I am unable to do so.

* Update exploring_perturbation_response_relationship notebook, still WIP

* adding notebook, new pyproject

* updated notebook: including a lot of new things based on the research work we have been doing for the last month. This notebook currently ends with a guide on creating the linear models on the cluster, but I can include more recent work involving the correlations and models we have been experimenting with

* went through all notebooks in vim and resolved merges by keeping the current changes

* adding statsmodels to pyproject

---------

Co-authored-by: Eric Jia <[email protected]>
Co-authored-by: Chase Mateusiak <[email protected]>
Co-authored-by: Chase Mateusiak <[email protected]>
cmatKhan added a commit to cmatKhan/yeastdnnexplorer that referenced this pull request Aug 28, 2024
* adding perturbation response relationship tutorial

* addressed the changes to the notebook: added analysis to all graphs, typehinting and docstrings to methods, and other misc changes

* added new methods and analysis to enable comparison between different dataset combinations. Added everything under the last subtitle, with each section having smaller subheadings underneath to group everything

* Calculate variance explained (BrentLab#88)

* fixed adjustment function so its based on enrichment strength

* added new file util.py and new test suite and updated notebook

* Update pyproject.toml

This is already in the dev dependencies. I forgot to go over that.

To add 'production' depdencies with python, you add to the default dependencies section with just:

```
poetry add <package>
```

You can also add dependencies to a group, eg:

```
poetry add --group dev <package>
```

See https://python-poetry.org/docs/cli/#options-4

That way, you can control what dependencies get installed.

For a typical user, I don't think we'll want to install jupyter in the environment. They should have jupyter in their environment, and then install yeastdnnexplorer into it.

* parameterizing the max_adjustment value and adding the calculate_variance_explained function and test suite

* removing the function and test suite for calculating the variance explained and adding the function to the visualizing_and_testing_data_generation_methods notebook

* Added docstrings and typehinting, removed unnecessary work and added exposition to graphs and methods

* updated notebook to use sphinx docstrings, added headings and subheadings and improved exposition

---------

Co-authored-by: Eric Jia <[email protected]>
Co-authored-by: Chase Mateusiak <[email protected]>

* fixed adjustment function so its based on enrichment strength (BrentLab#86)

Co-authored-by: Eric Jia <[email protected]>

* Database Interface (BrentLab#90)

* adding new file for explanation

* adding ParamsDict

* init implementation of the API classes. Documentation and some testing included. RankResponse is not, and the testing is minimal due to the difficulty of testing futures

* adding some words to the project ignore settings

* rank response api working

* addressing unused imports in RankResponseAPI

* updating the database_interface notebook for the new database backend; addressing logging warning on instantiation

* updating the tutorial to show how to use the aggregated data (BrentLab#91)

* table data retrieved as gzip; addtiional columns now present from DB

* Update README.md

closes BrentLab#81

* Adding update to manualqc (BrentLab#96)

* removing new file, part of a demo

* adding update() method to bindingmanualqc; added _delimiter_detect method to AbstractRecords

* addressing pre-commit issues

* This is getting the dev branch rebased onto the main branch (BrentLab#100)

* Calculate variance explained (BrentLab#88)

* fixed adjustment function so its based on enrichment strength

* added new file util.py and new test suite and updated notebook

* Update pyproject.toml

This is already in the dev dependencies. I forgot to go over that.

To add 'production' depdencies with python, you add to the default dependencies section with just:

```
poetry add <package>
```

You can also add dependencies to a group, eg:

```
poetry add --group dev <package>
```

See https://python-poetry.org/docs/cli/#options-4

That way, you can control what dependencies get installed.

For a typical user, I don't think we'll want to install jupyter in the environment. They should have jupyter in their environment, and then install yeastdnnexplorer into it.

* parameterizing the max_adjustment value and adding the calculate_variance_explained function and test suite

* removing the function and test suite for calculating the variance explained and adding the function to the visualizing_and_testing_data_generation_methods notebook

* Added docstrings and typehinting, removed unnecessary work and added exposition to graphs and methods

* updated notebook to use sphinx docstrings, added headings and subheadings and improved exposition

---------

Co-authored-by: Eric Jia <[email protected]>
Co-authored-by: Chase Mateusiak <[email protected]>

* fixed adjustment function so its based on enrichment strength (BrentLab#86)

Co-authored-by: Eric Jia <[email protected]>

* Database Interface (BrentLab#90)

* adding new file for explanation

* adding ParamsDict

* init implementation of the API classes. Documentation and some testing included. RankResponse is not, and the testing is minimal due to the difficulty of testing futures

* adding some words to the project ignore settings

* rank response api working

* addressing unused imports in RankResponseAPI

* updating the database_interface notebook for the new database backend; addressing logging warning on instantiation

* updating the tutorial to show how to use the aggregated data (BrentLab#91)

* table data retrieved as gzip; addtiional columns now present from DB

* Update README.md

closes BrentLab#81

* Adding update to manualqc (BrentLab#96)

* removing new file, part of a demo

* adding update() method to bindingmanualqc; added _delimiter_detect method to AbstractRecords

* addressing pre-commit issues

---------

Co-authored-by: ejiawustl <[email protected]>
Co-authored-by: Eric Jia <[email protected]>

* Add branch protection CI to prevent pulls directly to main (BrentLab#101)

This should only allow pulls from a branch called `dev` or `patch` directly to main. otherwise, pull requests will be required to be against `dev`

* fixed adjustment function so its based on enrichment strength (BrentLab#86)

Co-authored-by: Eric Jia <[email protected]>

* adding perturbation response relationship tutorial

* addressed the changes to the notebook: added analysis to all graphs, typehinting and docstrings to methods, and other misc changes

* added new methods and analysis to enable comparison between different dataset combinations. Added everything under the last subtitle, with each section having smaller subheadings underneath to group everything

* added docstring and typehinting to all methods, and added exposition to better explain the different conditions we use the model in. TODO: need to hide some of the output when training models or create an issue if I am unable to do so.

* Update exploring_perturbation_response_relationship notebook, still WIP

* adding notebook, new pyproject

* updated notebook: including a lot of new things based on the research work we have been doing for the last month. This notebook currently ends with a guide on creating the linear models on the cluster, but I can include more recent work involving the correlations and models we have been experimenting with

* went through all notebooks in vim and resolved merges by keeping the current changes

* adding statsmodels to pyproject

---------

Co-authored-by: Eric Jia <[email protected]>
Co-authored-by: Chase Mateusiak <[email protected]>
Co-authored-by: Chase Mateusiak <[email protected]>
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