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

Refactor codebase to use AnnData (Fixes #56) #74

Merged
merged 49 commits into from
Mar 29, 2024
Merged

Refactor codebase to use AnnData (Fixes #56) #74

merged 49 commits into from
Mar 29, 2024

Conversation

jvivian
Copy link
Owner

@jvivian jvivian commented Mar 27, 2024

Motivation

  • Make DFM code (and dashboard eventually) agnostic to our covid19 project data
  • H5AD is a superior format for cases where you need to track both observational and variable metadata (along with some numeric data matrix $X$).
  • Despite all of the code already working, I decided "why not rewrite all of it while on vacation?" like some sort of idiot.

Modules

covid19.py

Moved all project-related code to this module (e.g. get_df()). The principle function used from this module is now get_project_h5ad.

io.py

Module for handling interoperability between CSVs/DataFrames and AnnData/H5AD
image

processing.py

Module that prepares all data to run in DFM (such as differencing variables and normalization) via the DataProcessor class.

image

dfm.py

Module that handles running the model via a ModelRunner. A complete example of running the model across all 50 states:

from covid19_drdfm.covid19 import get_project_h5ad
from covid19_drdfm.dfm import ModelRunner

ad = get_project_h5ad()
model = ModelRunner(ad, batch='State')
model.run() # Data will output to `./output` by default
image

Copy link

codecov bot commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 92.12598% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 93.1%. Comparing base (dd5a202) to head (8d7c3c5).

Files Patch % Lines
covid19_drdfm/processing.py 84.5% 6 Missing and 7 partials ⚠️
covid19_drdfm/dfm.py 93.4% 2 Missing and 2 partials ⚠️
covid19_drdfm/cli.py 88.8% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main     #74     +/-   ##
=======================================
- Coverage   96.3%   93.1%   -3.2%     
=======================================
  Files          5       7      +2     
  Lines        193     308    +115     
  Branches      35      50     +15     
=======================================
+ Hits         186     287    +101     
- Misses         5      11      +6     
- Partials       2      10      +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant