Open matiasandina opened 4 years ago
Looks like this function can repair the lights affecting the baseline and correct everything to baseline zero. For those values below the mean of the 0.1 quantile, the movement will be negative (probably too small so it might not modify things).
repair_baseline <- function(x){
# we take the 0.1 quantile as the lowest values
base <- mean(x[x < quantile(x, 0.1)])
# we return x - base
return(x - base)
}
This app needs to get revisited and redone separate into a separate project, maybe with its own repo. Some thoughts here:
lineplot.R
has to be fixed, it's trying to handle the x axis too much. If x_axis handling has to be done, it might be better to separate it into a different function.light_shade.R
is trying to calculate the shading, this was better done in make_lights.R
on the FED quantification. The specifics might be a tad different but the logic of how to calculate the odd/even moments for the lights might be good to steal from that file. slice(-1)
to remove the first row before calculating repair_baseline
.NA
and fill.solved by
mutate(movement = ifelse(movement > 2e05, NA, movement),
movement = zoo::na.approx(movement, na.rm=F, rule=2))
write functions to aggregate movement data and plot
Baseline can be established within animal within light stage, as the mean of the 10% lowest responses. Then subtract this to the raw movement before aggregation into temporal bins.
Likely Useful plots
Individual
geom_rect()
shades to show light/dark accordinglyButtons to add
Grouped