-
Notifications
You must be signed in to change notification settings - Fork 16
Update quidel covidtest (Add Age Groups Signals, Add rest-of-state reports) #1467
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
Merged
Merged
Changes from 25 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
20a46d2
add age groups
801e2f5
update code for adding megacounties
15f7690
update unit tests
010491d
get smoothers out of the complicated loop
d215d6c
fix a linting
a120175
fix an error
b199cad
ignore too-many-branches in pylintrc
e7870e8
fix a linting error
07642fa
update signal names, add two super age groups
1ee31ae
fix a linting error
4eee961
remove 18-64 age group
a81050c
add whitespace and add comments
dc06d9c
add tests for ages 0-17
0c0f9f5
small udpates for suggested changes
1707cfb
add state_id for megacounties
e1226e1
add tests for state_id
562773d
Add minimal censored counties test and get error?
dshemetov ef41f6a
add suggested changes
c81298b
update unit tests based on the current strategy
7721290
geo_id should be integers in the unit tests
b7f94c9
udpate geographical pooling
1fdbe49
update unit tests
52a4aa6
update unit tests in test_run
9f3f6c3
delete trailing whitespaces
49af726
Add a few tests to double check county censoring
dshemetov 3218b1e
Remove faux-breakpoint, update test_data, update test_run
dshemetov 5c6d798
fix the test in test_run
3e9232e
remove the question in comments
ab25b35
add tests for values
8fbff93
add archiver section to quidel params
963bb5a
fix params
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
"""Contains geographic mapping tools.""" | ||
from itertools import product | ||
from functools import reduce | ||
|
||
import pandas as pd | ||
|
||
from delphi_utils import GeoMapper | ||
from .constants import (AGE_GROUPS, MIN_OBS) | ||
|
||
DATA_COLS = ['totalTest', 'numUniqueDevices', 'positiveTest', "population"] | ||
DATA_COLS = ['totalTest', 'numUniqueDevices', 'positiveTest'] | ||
GMPR = GeoMapper() # Use geo utils | ||
GEO_KEY_DICT = { | ||
"county": "fips", | ||
|
@@ -12,21 +18,52 @@ | |
"hhs": "hhs" | ||
} | ||
|
||
|
||
def geo_map(geo_res, df): | ||
"""Map a geocode to a new value.""" | ||
data = df.copy() | ||
geo_key = GEO_KEY_DICT[geo_res] | ||
# Add population for each zipcode | ||
data = GMPR.add_population_column(data, "zip") | ||
# zip -> geo_res | ||
data = GMPR.replace_geocode(data, "zip", geo_key, data_cols=DATA_COLS) | ||
data_cols = ["population"] | ||
for col, agegroup in product(DATA_COLS, AGE_GROUPS): | ||
data_cols.append("_".join([col, agegroup])) | ||
|
||
data = GMPR.replace_geocode( | ||
data, from_code="zip", new_code=geo_key, date_col = "timestamp", | ||
data_cols=data_cols) | ||
if geo_res in ["state", "hhs", "nation"]: | ||
return data, geo_key | ||
# Add parent state | ||
data = add_parent_state(data, geo_res, geo_key) | ||
return data, geo_key | ||
|
||
def add_megacounties(data, smooth=False): | ||
"""Add megacounties to county level report.""" | ||
assert "fips" in data.columns # Make sure the data is at county level | ||
|
||
# For raw signals, the threshold is MIN_OBS | ||
# For smoothed signals, the threshold is MIN_OBS/2 | ||
if smooth: | ||
threshold_visits = MIN_OBS/2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for this change in thresholding here? |
||
else: | ||
threshold_visits = MIN_OBS | ||
pdList = [] | ||
for agegroup in AGE_GROUPS: | ||
data_cols = [f"{col}_{agegroup}" for col in DATA_COLS] | ||
df = GMPR.fips_to_megacounty(data[data_cols + ["timestamp", "fips"]], | ||
threshold_visits, 1, fips_col="fips", | ||
thr_col=f"totalTest_{agegroup}", | ||
date_col="timestamp") | ||
df.rename({"megafips": "fips"}, axis=1, inplace=True) | ||
megacounties = df[df.fips.str.endswith("000")] | ||
pdList.append(megacounties) | ||
mega_df = reduce(lambda x, y: pd.merge( | ||
x, y, on = ["timestamp", "fips"]), pdList) | ||
mega_df = GMPR.add_geocode(mega_df, from_code="fips", new_code="state_id", | ||
from_col="fips", new_col="state_id") | ||
|
||
return pd.concat([data, mega_df]) | ||
|
||
def add_parent_state(data, geo_res, geo_key): | ||
""" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.