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.
Problem summary
Recent Ebola work has highlighted some errors in how numerical dates are handled in augur & auspice. Specifically, an isolate had collection date of
2019-12-01
which was represented in auspice as2019-11-30
due to errors converting between string & numerical date representations.Context
Note that auspice only receives numerical dates via the dataset JSON, and that augur performs string -> numeric conversion using the TreeTime utility function
numeric_date()
.numeric_date()
as written in Treetime v0.6* contained some bugs. Due to happy coincidence, @rneher made some changes to TreeTime in Treetime #98 today, so I didn’t have to 😄 These changes are reflected in Treetime v0.7* (I’m using commit d4450aac32cfafbb62492554d87e23ee4efa168f for this testing) which can be seen in the results below.Auspice v2.2.0 contains bugs
The auspice implementation of
calendarToNumeric
(our utility function to convert between string & numeric formats) contained a few different bugs and produced erroneous results:Similarly, the conversion of calendar dates to numeric didn’t really match either version of
numeric_date()
:(P.S. View the console to see this output, I’ll remove the commit printing this before merge.)
Code choices taken in this PR
Auspice has used a d3 time scale to convert between dates. While dates are notoriously hard to deal with, for the purposes of our use case (converting between string & numeric formats, and given that we know how TreeTime does it) it is prudent to do this ourselves instead of using external libraries.
Results from this PR:
Should this be merged?
From the results above, auspice (as per this PR) now matches TreeTime v0.7*. While it does not match TreeTime 0.6.4.1, which is used in the current augur release, neither does the current auspice release! This PR (as well as TreeTime v0.7) contain the “correct” implementations of numeric dates. I think this should be merged.
Note
We should consider not representing days over, say, 100 years ago as YYYY-MM-DD as this coveys a sense of accuracy which is misleading.