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

Create reproducible coloring for census tracts #17

Open
trvrb opened this issue Jul 13, 2019 · 0 comments
Open

Create reproducible coloring for census tracts #17

trvrb opened this issue Jul 13, 2019 · 0 comments
Assignees

Comments

@trvrb
Copy link
Member

trvrb commented Jul 13, 2019

@miparedes ---

We have hundreds of census tracts here: https://github.com/seattleflu/augur-build/blob/master/config/lat_longs.tsv#L49. I'd like a coloring that places nearby census tracts with similar colors, the way that we do things for, say, Zika: https://nextstrain.org/zika. For Zika, I did this color scale by hand. This is obviously impossible for the hundreds of census tracts. Instead, we'd like to automate this. My suggested algorithm:

  1. Load a mapping of census tract to lat/long
  2. Perform PCA on these lat/long values to orient the majority of variation to PC1 with PC2 orthologonal
  3. Use PC1 to pick colors along the official Nextstrain ramp: https://github.com/nextstrain/auspice/blob/master/src/util/globals.js#L128
  4. If you rank order PC1 you can slot the first X census tracts to #511EA8, the second X census tracts to #4928B4, etc... where X is chosen to equally distribute census tracts along the 36 elements of the color ramp.

This should end up as a Python script that takes a lat_longs.tsv and also a label (like region, country or location) and produces a colors.tsv output.

No hurry on this. I've wanted a script like this for a while as it would be generally useful in Nextstrain. And I think it could be a good programming challenge.

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

No branches or pull requests

2 participants