I am trying to quantify the reaction of animals to three different stimuli. For this I have noted the number of occurrence of different behaviors per 10 second bins for three minutes before and three minutes after stimulus onset. therefore I have one value for each behaviour per ten second bin. To get a "behavioural score" per 10-sec bin I run a PCA on this dataset, until here it is fine. But I can't find a good way of visualize the results...
Here is a dummy dataset mimicking what I have:
library(tidyverse)
library(FactoMineR)
library(factoextra)
# dummy data
dummy = expand_grid(bird = LETTERS[1:10],
time = seq(-100,100,10),
stimulus = c("Control", "S1", "S2"))
dummy = dummy %>%
mutate(B1 = abs(time)*(.1*rnorm(630,2,2)),
B2 = ifelse(stimulus == "Control", 1,2)*rnorm(630,10,1)) %>%
mutate(B3 = log(abs(B2)),
B4 = 2*(B1+B2),
B5 = rnorm(630,5,5)-B2)
plot(dummy)
An example PCA:
# pca
pca = PCA(dummy, quanti.sup = 2, quali.sup = c(1,3))
here the plot that comes out of the PCA:
# biplot
fviz_pca_biplot(pca,
habillage = c("stimulus", "time"),
# col.ind = "full2",
label = "var",
addEllipses = TRUE,
col.var = "black", pointshape = 12)+
scale_color_viridis_d(option= "C", end = .8)+scale_fill_viridis_d(option= "C", end = .8)+
theme_classic()
I would rather like to see one facet per stimulus, and colors for the time groups... is there an easy way of doing this? (and does it actually make any sense to split data in a PCA? - I am not very familiar with the technique)
