-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hello!
I'm having some difficulties with using Rethomics to produce polar coordinate plots. The centre of the plot has a grey circle that coincides with what should be the light phase (the right side of the plot, from 0-12h). Also, the activity appears to not be continuous in that it does not fully close at 0/24 h. I've posted my code below, as well as the polar coordinate plot and actogram I produced using this code. Data and metadata are also attached in a zip (archive.zip). Any advice or help is much appreciated!
rm(list=ls())
library(behavr)
library(ggetho)
library(zeitgebr)
library(lubridate)
library(ggplot2)
library(RColorBrewer)
library(tidyverse)
#load data
metadata <- fread("Your/path/to/data.csv")
df <- fread("Your/path/to/data.csv")
df <- na.omit(df)
df$time <- as.POSIXct(df$time, format="%d/%m/%Y %H:%M")
#create a fake time that's one day earlier at ZT0
df$start.time<-paste0(date(min(df$time)-86400)," 18:00:00") #86400 is the number of seconds in one day
df$start.time <- as.POSIXct(df$start.time)
df$t.seconds <- as.numeric(interval(df$start.time,
df$time)) #rethomics wants elapsed seconds since a ZT0, so we choose the ZT0
#from the day before and put all values as elapsed seconds since then
#produce behavr table
dt <- behavr(data.table(id=df$id, #DATA TABLE
t=df$t.seconds,
activity=df$chirp80_r,
key="id"),
data.table(id=metadata$id, #METADATA TABLE
treatment = metadata$treatment,
temp = metadata$temp,
key="id"))
dt[is.na(dt$activity),"activity"] <- 0 #convert missing values to zero
#actogram plot theme
ThemeActo <- theme_bw() +
theme(
plot.title = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank()) +
theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
theme(legend.position="bottom", legend.text=element_text(size=7))
#actogram for an individual cricket
c3_acto <- ggetho(dt, aes(x=t, z=activity), multiplot = 2)+ stat_tile_etho() +
stat_ld_annotations(ld_colours = c("white", "black"),
ypos="top") + ThemeActo + labs(fill=NULL)
#polar coordinate theme
ThemePolCor <- theme_bw() +
theme(title = element_text(size = 12)) +
theme(text = element_text(family = "Helvetica")) +
theme(axis.title.x = element_blank(),
axis.title.y = element_blank()) +
theme(legend.position = "none") +
theme(panel.border = element_blank()) +
theme(plot.title = element_text(hjust=0.5))
#colour palette
MaryPal <- brewer.pal(n=9, "Reds")
#polar coordinate plot code
c3_polcor <- ggetho(dt, aes(y=as.numeric(activity), fill=as.factor(id)), time_wrap = 86400) +
stat_ld_annotations(height=.5,
alpha=.2,
x_limits = c(0, 86400),
outline = NA) +
labs(title = "Cricket 3") +
stat_pop_etho() + coord_polar() + ThemePolCor +
scale_colour_manual(values=MaryPal[8], name=NULL) +
guides(fill=FALSE, colour=guide_legend(override.aes=list(fill=NA)))Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

