Skip to content
Snippets Groups Projects
Commit d40f5b14 authored by Francesco Sabatini's avatar Francesco Sabatini
Browse files

Fixed bug in 99, started alignign 01

parent 1cd0f72e
No related branches found
No related tags found
No related merge requests found
......@@ -170,20 +170,25 @@ traits <- traits %>%
#### ## Import output ####
myfilelist <- list.files(path="_derived/Mesobromion/", pattern="HIDDEN_[0-9]+.RData", full.names = T)
myfilelist <- list.files(path="_derived/Mesobromion/", pattern="HIDDEN(\\.[A-Za-z]+|_[A-Za-z]+)_[0-9]+.RData", full.names = T)
corXY <- NULL
corXY.perm <- NULL
corXY.bootstr <- NULL
#corXY.perm <- NULL
#corXY.bootstr <- NULL
for(ff in myfilelist){
index <- as.numeric(regmatches(ff, gregexpr("[[:digit:]]+", ff))[[1]])
load(ff)
corXY <- rbind(corXY, cor.obs)
corXY.perm <- rbind(corXY.perm, cor.perm)
corXY.bootstr <- rbind(corXY.bootstr, cor.bootstr)
corXY <- bind_rows(corXY, cor.obs)
#corXY.perm <- rbind(corXY.perm, cor.perm)
#corXY.bootstr <- rbind(corXY.bootstr, cor.bootstr)
print(index)
}
dataFiles = map(myfilelist, load)
dat = bind_rows(dataFiles)
diffs <- corXY.bootstr - corXY.perm
sign <- apply(diffs, MARGIN=1, function(x){sum(x>0)>190})
sign <- data.frame(Trait.comb=names(sign), sign=sign)
......@@ -293,8 +298,7 @@ ggplot(data=mydata) +
traits.sign <- traits %>%
rownames_to_column("species0") %>%
dplyr::select(traits.sign.alone)
dplyr::select(species0, traits.sign.alone)
write_delim(traits.sign, path="_data/Mesobromion/traits.out.10perc.sign.txt", delim="\t")
break()
......
......@@ -47,8 +47,7 @@ get.corXY <- function(comm, traits, trait.sel="all", stat=c("mantel", "RV", "pro
}
### Cor XY bootstrap
#### Function 1 - CorXY ####
#### Function 1b - CorXY bootstrap####
get.corXY.bootstrap <- function(comm, traits, trait.sel="all", stat="RV", bootstrap=199){
if(identical(trait.sel, "all")) {trait.sel <- 1:ncol(traits)}
ii <- trait.sel
......@@ -77,6 +76,7 @@ get.corXY.bootstrap <- function(comm, traits, trait.sel="all", stat="RV", bootst
index.bootstr <- lapply(1:bootstrap, function(x){sample(1:n.sites, replace=T)})
for(b in 1:bootstrap){
RV.tmp <- RV.rtest(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.tmp)[index.bootstr[[b]],])
syn.out.perm.tmp <- matrix.x(comm=comm, traits=traits[index.traits[[bootstrap]],ii,drop=F], scale=T)$matrix.X
RV.perm.tmp <- RV.rtest(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.perm.tmp)[index.bootstr[[b]],])
corXY <- rbind(corXY,
data.frame(Trait.comb=lab.tmp, bootstr.n=b, Test="RV", Coef.obs=RV.tmp$obs, Coef.perm=RV.perm.tmp$obs))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment