ctmm-initiative / ctmmweb

Web app for analyzing animal tracking data, built upon ctmm R package
http://biology.umd.edu/movement.html
GNU General Public License v3.0
32 stars 21 forks source link

Overlap #36

Closed NoonanM closed 4 years ago

NoonanM commented 6 years ago

Are there any plans to implement the overlap() function? My guess is a lot of users would want to use this function for subsequent analyses and it would be good to provide the option within the app.

chfleming commented 6 years ago

I think col.grid=NA disables the grid.

xhdong-umd commented 6 years ago

col.grid=NA worked, thanks!

screen shot 2018-02-23 at 11 04 24 am screen shot 2018-02-23 at 11 04 34 am
xhdong-umd commented 6 years ago

I found legend positioning in base plot is really cumbersome.

I'm thinking maybe just put animal names in plot title, and color the overlap table cells instead.

xhdong-umd commented 6 years ago

In home range plots we can give a vector of level.UD and several polygons can be plotted. When using plot with a list of home range UD, a vector of level.UD seemed to be distributed to each UD object, so we cannot have multiple level polygons.

Should we just put a single value input for this level.UD?

chfleming commented 6 years ago

You mean different level.UD per individual? I'm not sure that anyone would want that.

xhdong-umd commented 6 years ago

Oh I was thinking the confidence levels of contour in home range page, that was level.

(EDIT: previously I used an old screen shot, the current description is like this)

screen shot 2018-03-05 at 3 42 55 pm

Do we need a level input here, or a level.UD input here?

chfleming commented 6 years ago

My assumption is that people will mostly want to specify level.UD, with 0.95 and 0.50 being the most popular choices. However, some people will also want to disable level with level=NA to avoid clutter.

xhdong-umd commented 6 years ago

It's easy to confuse between level and level.UD for me. Howe should we describe them in the app? We will need to show both of them here.

xhdong-umd commented 6 years ago

I added controls but not really satisfied with the descriptions.

screen shot 2018-03-05 at 3 29 30 pm
chfleming commented 6 years ago

How about something like "% coverage of the individuals" for level.UD and "% coverage of the uncertainty" for level.

xhdong-umd commented 6 years ago

That's much better. I'll also add notes in help document, though many users probably will not look at it, so it's better to be more clear in app from the beginning.

xhdong-umd commented 6 years ago

@chfleming , I'm trying to turn of the contours with level.UD = NA. However there will be error if both home range and location points are plotted.

# this works
plot(hrange_list_sub2[[1]], level.UD = NA)
# with point there is error
plot(tele_list_sub2[1], UD = hrange_list_sub2[[1]], level.UD = NA)
# Error in if (level.UD == 1 || (!is.na(level) && level == 1 && !is.null(x$DOF.area))) { : 
#  missing value where TRUE/FALSE needed
xhdong-umd commented 6 years ago

@NoonanM I tried to call title twice to use two colors in plot title. The second call need to adjust the position, but we don't know beforehand how much space will be needed. So it's easy to create one time use script with some tweaking, but difficult to place two names (they could be quite long) reliably.

I found some hack using expression, but that format cannot be used directly because I need to use variable here, which will not be evaluated inside expression. Maybe it's possible to do that with some advanced non-standard evaluation tricks, but the whole approach goes too far in hacking.

title(expression("title (" * phantom("slope=1)") * ")"), col.main = "black")
title(expression(phantom("title (") * "slope=1"), col.main = "red")
chfleming commented 6 years ago

This function looks like it would work using a black comma as the middle input:

http://r.789695.n4.nabble.com/title-words-in-different-colors-td878698.html#a878700

xhdong-umd commented 6 years ago

OK, so they just calculate the name width and place them...

Hope it will not break by some special characters in animal names.

chfleming commented 6 years ago

It looks like they use the phantom trick, which should work unless there are bugs in phantom.

xhdong-umd commented 6 years ago

Is it possible to draw location points but with contours off for home range? If that's not possible, I can simple make a radiobutton to switch between location points and hide contours.

chfleming commented 6 years ago

Regarding level.UD=NA, there were 2 issues:

1) plot.UD was not passing level or level.UD arguments to the plot extent calculation. It should have crashed for you as well. I have fixed this in the master branch just now. 2) level.UD is necessary to calculate the plotting extent of the UD, even if the contours are not wanted.

Regardless, col.level=NA turns off the contour plotting.

xhdong-umd commented 6 years ago

OK. So I'll just use col.level = NA, and don't allow NA of level.UD.

xhdong-umd commented 6 years ago

We have a checkbox confidence envelops in overlap home range plot to turn off level. Do we need this option in home range and occurence page too?

chfleming commented 6 years ago

Its less important there because there is less clutter and the CIs are one of the more important features of the software, but it wouldn't hurt anything to have it.

xhdong-umd commented 6 years ago

So add the checkbox but make the default to be on? The overlap home range page have default to off.

Also should we add a checkbox in home range to turn location points on/off?

chfleming commented 6 years ago

So add the checkbox but make the default to be on?

Yes, the default should definitely be CIs on in the home-range page.

The overlap home range page have default to off.

That's probably okay.

Also should we add a checkbox in home range to turn location points on/off?

It wouldn't hurt anything and the default should be on.

xhdong-umd commented 6 years ago

For occurence plot, the interval level doesn't have effect?

And the location point in occurrence plot doesn't provide more information, right?

chfleming commented 6 years ago

We don't put uncertainty on the occurrence distribution contours because the occurrence distribution itself is uncertainty in where the animal was.

Locations on the occurrence plot should be optional.

xhdong-umd commented 6 years ago

OK. These are some screenshot with each one's default values.

screen shot 2018-03-10 at 7 43 04 pm screen shot 2018-03-10 at 7 43 21 pm screen shot 2018-03-10 at 7 44 51 pm
xhdong-umd commented 6 years ago

I made the multi color title to be separate lines, otherwise the margin is probably not enough for long names

screen shot 2018-03-11 at 3 26 01 pm screen shot 2018-03-11 at 3 25 36 pm
vestlink commented 6 years ago

Will the Occurence distirubution overlap be considered at some point?

chfleming commented 6 years ago

Hi @vestlink , I don't know what legitimate use an occurrence distribution overlap would have. Integrating the occurrence distribution over an area gives the point estimate for the fraction of time spent in that area. Similarity in occurrence would come down to similarities in times spent, which I do not think would relate to statistical/distribution overlap, but something else.

More likely people would use occurrence distribution overlap to compare space use, which would be an incorrect interpretation.

NoonanM commented 6 years ago

A user just ran into an issue with the visuals on the overlap tab. See attached screenshot. screenshot error

xhdong-umd commented 6 years ago

That seemed to be the group plot of home ranges. So there are 630 pairs? By default the home range plot only draw pairs with positive overlap, but that could be still too much. It's impossible to show hundreds of plot in same page.

I think I need to add some limit, like the visualization page, only draw plot for current page.

NoonanM commented 6 years ago

The overlap pairs generally look very good, but I've noticed that sometimes you can get pairs of animals with very similar colours, making some plots hard to interpret. Would it be possible to include an option to e.g., make the contours black, or greyscale the colours of certain plots?

xhdong-umd commented 6 years ago

When we plotting multiple pairs, the colors are chosen automatically on a color space using max distance possible. With a lot of pairs, it's unavoidable that some colors will become similar (the color started in another round, so color c might be different from d but close to a).

Right now the density color and contours color are same for one animal, and we use that color for animal name in plot as legend.

If you want to just change the contours color and keep the density color, we will need to describe two colors in legend. That's still doable, like [Cilla], use contour color for [], density color for Cilla. This is not perfect since density color will be similar, but at least we have some boundaries. This may not look as good as current color for smaller numbers of animal though. We can make it an option, so still use same color for contour, but switch to blue/red pair for contour when checked.

If you want to change individual plot color, that'll break the automatic color mapping and create too many problems, since we also want to maintain the color consistency in other plots and maps. Actually if you have too many animals selected, the visualization page plots also can have points with similar colors, there is no way to avoid this problem when the animals count is large.

Another approach to temporarily reduce the problem is to select a smaller subset in visualization page, so that the colors will not be used up.

chfleming commented 6 years ago

When we plotting multiple pairs, the colors are chosen automatically on a color space using max distance possible. With a lot of pairs, it's unavoidable that some colors will become similar (the color started in another round, so color c might be different from d but close to a).

On that topic, getting the color wheel to cycle through the animals while optimizing some objective on neighboring color separation versus distance is more complicated than I expected. You have to first define an objective function that penalizes vertices that are close in both color and distance. Then you have to be able to minimize that objective function via color assignment with reasonable computational cost. Its not a high priority, fortunately.

NoonanM commented 6 years ago

Ok, I had hoped it might be easy to be able to adjust the contours of individual plots on the overlap page (like a black/white tick box that only applies to the overlap page), but if that's not the case then I think you can just leave everything like it is.

xhdong-umd commented 6 years ago

We can make a simple change for the similar color case, just have an option to use fixed colors (blue/red) for every plot. This is simple enough and will not be too hard to implement. It does have several disadvantages:

We can make it to be a non-default option so only enable it when needed. @NoonanM Will this solve the problem you found?

xhdong-umd commented 6 years ago

And for the error above, I checked and found the app is already only plotting the pairs in the current page.

It seemed that the app in case is showing 72 rows in one page, and that means the app need to draw 72 plot together. That will be unnecessary, since each plot will be too small to see anything. And the method to plot base plots in group seemed cannot handle this number of subplots.

I don't think there is a solution for this, you have to choose a smaller count for page.

NoonanM commented 6 years ago

Ok, in terms of the error, maybe it might be worth mentioning in the help file that the fix is to use a smaller count? That way users at least have a path forward.

As for the color issue, it's not a major problem, but can make certain figures difficult to interpret. I think the non-default option you mentioned would be a pretty good way of taking care of that.

xhdong-umd commented 6 years ago

I added notes in help, also just removed the page length option of 72, which is too much for this page.

xhdong-umd commented 6 years ago

This is the two colors mode

screen shot 2018-03-30 at 4 29 32 pm
NoonanM commented 6 years ago

That looks great. I think it will definitely be useful for those cases where colours are too similar to distinguish clearly.

NoonanM commented 5 years ago

On the overlap page, it is not currently possible to subset individuals. It would be useful to have the option to select what individuals overlap is calculated for.

xhdong-umd commented 5 years ago

I think overlap of all combinations of selected individuals have been calculated. To change selected individuals, user need to go back to visualization page, since this is the assumption throughout the app, and all modeling calculations are based on same individual selection - - if you change selection in overlap page, you still need to get model results for these individuals first, before getting the overlap.

NoonanM commented 5 years ago

But if a user has done model fitting on all individuals, and then wants to only look at overlap on a subset, they would need to re-run all of their analyses. The main use here is so that users can have plots of overlap values that reflect the individuals they are interested in.

xhdong-umd commented 5 years ago

I will need to look at the details of the page. It could be possible to limit to a subset within page, but not changing to a different individual set with model results unavailable.

NoonanM commented 5 years ago

Yes, the use case would be only for individuals that have model results. Maybe some type of drop down menu, or clickable list of individuals with all selected by default?

xhdong-umd commented 4 years ago

I'm closing this issue as it's quite long, and move the newest request as an independent issue #103