I try to measure the phylogenetic signal in two variables, a discrete and a continuous one. To do so, I use the δ-statistic (Borges et al 2018) and the K-statistic (Blomberg 2003), respectively. I have a tree, and two vectors corresponding to my variables. The line of code for these two statistics are the following:
1) delta(vector, tree, lambda0, se, sim, thin, burn)
2) phylosig(tree, vector, method = "K")
I get a single value each time. But I would like to randomize my vectors to test the significance of the orignal values. I would like to do 1000 repetitions and then proceed to a simple test of significance but, as I am a new R user, I have no idea how to do it. I think of something like this:
For δ:
%first repetition
random_vector <- sample(vector)
random_delta <- delta(vector, tree, lambda0, se, sim, thin, burn)
write.xlsx(random_delta, path)
%second repetition
random_vector <- sample(random_vector)
random_delta <- delta(vector, tree, lambda0, se, sim, thin, burn)
write.xlsx(random_delta, path, append = TRUE)
And on, and on, until 1000 δ-statistics stored in a single .xlsx, ready to be used in a test.
For K, I guess it is a bit different since it is not a vector anymore but a table with two columns (species, values):
%first repetition
random_vector <- sample(vector)
names(random_vector) <- tree$tip.label
random_K <- phylosig(tree, vector, method = "K")
write.xlsx(random_K, path)
%second rep
random_vector <- sample(random_vector)
names(random_vector) <- tree$tip.label
random_K <- phylosig(tree, vector, method = "K")
write.xlsx(random_delta, path, append = TRUE)
Etc.
I thought of that, but maybe someone has another idea. Either way, I am in.
I hope I have made myself clear.
I thank you in advance for your help.
J.G.
Aucun commentaire:
Enregistrer un commentaire