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

Fix output issues #32

Merged
merged 1 commit into from
Aug 15, 2024
Merged

Fix output issues #32

merged 1 commit into from
Aug 15, 2024

Conversation

smthfrmn
Copy link
Collaborator

@smthfrmn smthfrmn commented Aug 13, 2024

This PR fixes:

  • App completes run even with error #30: @sarahcd the fix I put in is that the app will return an empty output file (as it does now) and will not return the pdf file to the user, which should make it more clear that things did not work. Just a note here, the failure happens for one particular animal/track, so several animal parturition analyses can succeed and then one fails which fails the whole thing. In the current app version, the way we generate the pdf makes it so that the pdf of the so-far successful animals still saves, now it won't.
  • Output not matching that of previous app #22: I removed the duplicate business (columns ending in .x or .y) and also added trackID back in as a column header, keep in mind this will be a duplicate with whatever the actual name is for trackID, in the case of hart river, individual_local_identifier_year. @sarahcd please let me know if this is the desired behavior.

@nilanjanchatterjee most of the changes are actually just linting, I commented where there are real changes

@@ -21,12 +21,13 @@ plot_speed <- function(dat, dat_outp, yul, track_id, threshold) {
abline(h = ifelse(is.null(threshold), mean(dat$speed, na.rm = T), threshold), lty = 3, lwd = 2, col = "coral")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly linting changes

@@ -164,7 +168,11 @@ rFunction <- function(data, threshold = NULL, window = 72, events_file = NULL, y
)

if (is.null(data_temp)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real change

@@ -288,14 +303,14 @@ rFunction <- function(data, threshold = NULL, window = 72, events_file = NULL, y
dat_final <- left_join(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real change

@nilanjanchatterjee
Copy link
Owner

The changes look good to me...merging the branch with the main one

@sarahcd
Copy link
Contributor

sarahcd commented Aug 19, 2024

* [App completes run even with error #30](https://github.com/nilanjanchatterjee/parturition/issues/30): @sarahcd the fix I put in is that the app will return an empty output file (as it does now) and will not return the pdf file to the user, which should make it more clear that things did not work. Just a note here, the failure happens for one particular animal/track, so several animal parturition analyses can succeed and then one fails which fails the whole thing. In the current app version, the way we generate the pdf makes it so that the pdf of the so-far successful animals still saves, now it won't.

Ok thanks for the explanation. Getting a result for each individual has been a core requirement, so it's important that the user gets some clear signal if some tracks fail. I think this is good for now. I can add some explanation in the readme.

* [Output not matching that of previous app #22](https://github.com/nilanjanchatterjee/parturition/issues/22): I removed the duplicate business (columns ending in .x or .y) and also added `trackID` back in as a column header, keep in mind this will be a duplicate with whatever the actual name is for `trackID`, in the case of hart river, `individual_local_identifier_year`. @sarahcd please let me know if this is the desired behavior.

I'm not sure, we can see how it looks after the update! For now the redundancy is ok. @annescharf refers us to the move2 app documentation:
For track ID, to get the output working correctly we should refer to mt_track_id_column() to account for differences in how this is defined in the incoming move2 object.

More generally, Anne points out that the app converts the move2 object to a new df and then hard-codes the attributes for timestamps, IDs and coordinates rather than using the move2 retrieval functions described in the manual. With the current code, the app will work for data coming from the Movebank Location App, but is likely to break in any other case, even if someone uploads a CSV of data downloaded from Movebank. For example in RFunction.R, line 116, a file from Movebank will have column name 'individual-local-identifier' (possibly converted by R to individual.local.identifier), in which case selecting individual_local_identifier won't work. A fix to work with these other inputs will take more work, so let's see how it looks in the current update and change further in a later update.

@annescharf , now that I look at it again, I have another question relating to this issue: The cargo agent does seem to get the animals_total_number correct, even when this is different than the number of tracks. How is it doing this? Wouldn't this require a function like mt_animal_id() to retrieve IDs for individual animals?

@annescharf
Copy link
Contributor

@sarahcd, I just had a look at code of the cargo agent and realized that it will also only work with data directly downloaded from movebank. It searches for the individual.local.identifier and counts the number of unique names. I'll make an issue, and try to find a way of generalizing this. In the long run maybe it would be useful to have an additional marker in move2 to identify the column with the animal ids. Lets see

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.

4 participants