You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now we have the wrapper function calculate_distance() which processes all the necessary arguments and invokes the correct method without users needing to call multiple different functions. Now we want to write another wrapper, say agdist() or whatever, that takes a vector of methods and returns all of the differences.
agdist() should have two methods: one for data frames and one for named vectors.
the method should validate the input, for dataframes we will need a way of specifying which columns to use e.g. by tidy evaluation (or requiring users to pass strings of the column names).
Then, the function should validate the methods argument and ensure its a valid character vector with only names of allowed methods.
Finally, we iterate through the methods argument and run compute_distance() with each method and the necessary other arguments. This function already validates the arguments for each method, so we don't need to do that again (e.g. compute_distance() will error if the user tries to get cartographic distances without passing in a map -- although we do need to implement a validation step that checks that the input data is compatible with the tree or map supplied see cartograpic and tree dist interfaces that accept sequence vector #3).
Once we have a list of distance matrices, we can then use the implemented tidy_dist_mat() to get clean dataframes and rbind them together to get an output matrix -- this will be the default output form although there should be an argument that allows users to get the list of distance matrices as well (sometimes this is useful, e.g. for making neighbor joining trees).
The data frame method will be easy to implement once the vector method is implemented. We would just take the two columns of strains to be compared, create a unique vector with all of the pairwise combos, and then run the vector method on that. Then the tidy distance matrix can be joined back to the original data frame. This is more memory intensive than doing it a different way but it's the easiest implemention that doesn't break any of the existing code.
Now we have the wrapper function
calculate_distance()which processes all the necessary arguments and invokes the correct method without users needing to call multiple different functions. Now we want to write another wrapper, sayagdist()or whatever, that takes a vector of methods and returns all of the differences.agdist()should have two methods: one for data frames and one for named vectors.methodsargument and ensure its a valid character vector with only names of allowed methods.methodsargument and runcompute_distance()with each method and the necessary other arguments. This function already validates the arguments for each method, so we don't need to do that again (e.g.compute_distance()will error if the user tries to get cartographic distances without passing in a map -- although we do need to implement a validation step that checks that the input data is compatible with the tree or map supplied see cartograpic and tree dist interfaces that accept sequence vector #3).tidy_dist_mat()to get clean dataframes andrbindthem together to get an output matrix -- this will be the default output form although there should be an argument that allows users to get the list of distance matrices as well (sometimes this is useful, e.g. for making neighbor joining trees).