rethomics / ggetho

Visualise high throughput behavioural data in R, based on ggplot2
http://rethomics.github.io
8 stars 3 forks source link

implement time_offset in ggetho #12

Closed qgeissmann closed 6 years ago

qgeissmann commented 6 years ago

if #11 is closed, we can do that rather simply

qgeissmann commented 6 years ago

I think we are there, with the time_offset argument:

image

metadata <- data.table(id= sprintf("toy_experiment|%02d", 1:20),
                       condition=c("A","B"))
dt <- toy_activity_data(metadata, 3)
dt[, moving := ifelse(t %% hours(24) > hours(12), moving & rnorm(.N) > -.2, moving)]

my_layers <- list(stat_pop_etho(), stat_ld_annotations())
pl_a <- ggetho(dt, aes(y=moving), time_wrap=hours(24)) + my_layers
pl_b <- ggetho(dt, aes(y=moving), time_wrap=hours(24), time_offset = hours(12)) + my_layers
pl_c <- ggetho(dt, aes(y=moving), time_wrap=hours(24), time_offset = hours(6)) + my_layers
pl_d <- ggetho(dt, aes(y=moving), time_wrap=hours(24), time_offset = hours(-6)) + my_layers

cowplot::plot_grid(pl_a,pl_b,pl_c,pl_d, labels=letters[1:4])