baeolophus / TAGS_shiny_version

recreating geolocator data processing service TAGS in R shiny
GNU Affero General Public License v3.0
1 stars 1 forks source link

Light threshold defaults (WAS: TAGS erroring out on attached data file with error: "Warning: Error in <-: replacement has length zero") #9

Open dannymandel opened 10 months ago

dannymandel commented 10 months ago

Hello,

I'm attempting to run TAGS on the attached data file (which is generated by Lotek light sensors), and running into the error "Warning: Error in <-: replacement has length zero". When I hit this error, it appears to halt processing. I had an initial problem with the same data file where the default light threshold value (5), wasn't present in the data set, but on the advice of @jcoliver I updated that to a value present in the data set and it allowed processing to continue further. The abbreviated stack trace of the error is as follows:

Warning: Error in <-: replacement has length zero
  i.preSelection [source_iPreselection.R#25]
  TAGS_twilight_calc [source_TAGS_twilightCalc.R#39]
  <reactive:twl> [/Users/mandeld/Library/Mobile Documents/com~apple~CloudDocs/geolocator_data/TAGS_shiny_version/TAGS_shiny/app.R#326]

This is approximately the code that is failing, and it's the ind3 variable which appears to be length zero (note that the line numbers probably won't exactly match up because I've been modifying source locally to try and understand the root cause of the problem).

-    if(smooth[i,3]==1) ind3 <- tmp$id[which.min(tmp[,2])]
-    if(smooth[i,3]==2) ind3 <- tmp$id[which.max(tmp[,2])]
-    ind2[i] <- ind3

I have a few different .csv files I've tried and they all appear to error out with the same problem. I'll continue to add debugging notes to the issue if I'm able to glean anything useful in the debugger.

Here is the file that is failing:

ID000418_2023Mar24T163221.csv

Thank you!

dannymandel commented 10 months ago

This line:

    tmp <- subset(raw,datetime>=(smooth[i,2]-(90*60)) & datetime<=(smooth[i,2]+(90*60)))

is getting an empty value back. So of course both of these lines will get an empty value:

-    if(smooth[i,3]==1) ind3 <- tmp$id[which.min(tmp[,2])]
-    if(smooth[i,3]==2) ind3 <- tmp$id[which.max(tmp[,2])]

To my untrained eye, df1, raw, and smooth look ok here:

image

so I don't fully understand why tmp is coming back empty.

baeolophus commented 9 months ago

Thanks for sharing this error and my apologies for taking so long to get back to you. I've had another user email me about a similar error with the same tag brand. I'm hoping to take a look at it in the next week or so and I'll let you both know what I can figure out.

dannymandel commented 9 months ago

Wonderful, thanks so much!

baeolophus commented 9 months ago

@dannymandel can you provide the calibration and light values that you used? and what "step" in the GUI that the error happens?

baeolophus commented 9 months ago

And were you running this locally, or on the Shiny-hosted web page? If locally, can you provide your R version and package versions please?

baeolophus commented 9 months ago

Note to self: https://stackoverflow.com/questions/74392034/what-r-version-is-used-when-deploying-a-shiny-app-to-shinyapps-io Shinyapps.io should be running the latest R and packages, so it shouldn't be a version problem. The email user couldn't get sample file named GL36_000.lig to run, but GL36_000.lig works on the web version for me. Could not get dannymandel's sample file to run on web.

baeolophus commented 9 months ago

@dannymandel after experimenting for a few hours, I have been able to use your original datafile with the current version after I updated the default light threshold to anywhere 35 or above. I tried this both locally on my computer and on the web version. Can you clarify at what step you are getting "Warning: Error in <-: replacement has length zero"?

jcoliver commented 9 months ago

Related to explanation in #8 .

baeolophus commented 9 months ago

Thanks @jcoliver . Yes, @dannymandel please let us know if increasing light threshold above 35 allows processing to continue for you. It did for me.

baeolophus commented 9 months ago

Ideas:

automatically fill this out based on data's values. what is minimum it will work on?
have a more specific message instead of generic error to remind user to go back to light threshold step.  this would work as this doesn't crash the app, it only throws an error in the two plots.
dannymandel commented 9 months ago

Thank you. I’m fairly certain I tried this and still encountered the issue. I’ll have time this weekend to try this out and report back. I’ll also confirm the R version on the machine I was trying it on.

dannymandel commented 9 months ago

R version on the machine I was trying on:

> R.version.string
[1] "R version 4.3.0 (2023-04-21)"

Will try and reproduce the issue now using a light threshold value of 35.

dannymandel commented 9 months ago

OK, so I tested against the web version (https://tags.shinyapps.io/tags_shiny/) and get the same result. I get an error message below step 5 that says "An error has occurred. Check your logs or contact the app author for clarification."

Including a screen recording of what I was trying to do against the deployed web version. Clearly I am missing some step in the workflow as the error is persisting for me.

https://github.com/baeolophus/TAGS_shiny_version/assets/1188978/f12a4328-d94e-4add-b3ab-5e78299d93a3

dannymandel commented 9 months ago

I had to trim the video to get it to upload (was too big otherwise), so you can't see the values I was using. But they are:

Calibration Latitude: 38.999983 Calibration Longitude: -105.358887

Calibration Start Date: 2020-06-12 Calibration End Date: 2020-12-11

Light Threshold: 35

Problem Threshold (Hours): 5