hagenaue / bHRbLR_Enrichment_Stress_BehaviorAndHormoneData

Code used for the analysis of behavioral and hormonal data within the publication "Adolescent environmental enrichment induces social resilience and alters neural gene expression in a selectively bred rodent model with anxious phenotype" by O'Connor, Hagenauer, et al.
1 stars 0 forks source link

Functionalizing the Time Series Plotting Code #3

Closed hagenaue closed 4 years ago

hagenaue commented 4 years ago

The Time Series plotting code (5_TimeSeriesPlots.R) is an ugly beast. There is a lot of redundancy within it, and then it is adapted for each of the time series variables (the current code is just the plot for one of the time series variables). Let's make a function that can construct a panel within the code, and then use that to make a streamlined version of the code for a plot for a single time series variable. Then, we can functionalize that plotting code to make it generic so that it can be used quickly and easily for any of the time series variables. To get started, here's background on making functions. https://swcarpentry.github.io/r-novice-inflammation/02-func-R/

hagenaue commented 4 years ago

Looks like Liam finished functionalizing the plotting code for the individual panels. This is something that might be helpful to change - the determine_starting_point code is currently specific to this particular variable (maybe - if we're lucky, it may not matter...). Basically we just need a row of data (rat) to start on for any particular group that has data for at least two time points, so we might be able to replace this code with something similar to the if/else statement used in the loop that we used to calculate intercept/slope for each animal. ... but it is also possible that if we're lucky it won't matter, so we could just leave it be and then alter it later if it turns out that it is an issue.

hagenaue commented 4 years ago

I added a list of the social defeat time series variables to apply the plotting function to (once the function is complete...)