diff --git a/02_Mesobromion_ExamineOutput.R b/02_Mesobromion_ExamineOutput.R index 52e9c37d7ca5d7c29a044983c72344a93793b288..da06627846b5ca000d8147517bcd2ddbabdbca1b 100644 --- a/02_Mesobromion_ExamineOutput.R +++ b/02_Mesobromion_ExamineOutput.R @@ -72,10 +72,12 @@ is.binary <- function(x){(all(na.omit(x) %in% 0:1))} ####1.1 Table S3 - Trait recap ##### trait.recap <- traits %>% + mutate_at(.vars=vars(Leaf_Scleroph, LifeSpan, Rosette), + .funs=~as.ordered(.)) %>% dplyr::select(-ends_with("1")) %>% ## exclude two traits that shouldn't be there V_VER_present1 & V_VER_absent1 mutate_if(.predicate = ~is.numeric(.), .funs=~round(.,3)) %>% summarize_all(.funs = list(xxxType.of.variable=~ifelse(is.binary(.), "binary", - ifelse(is.ordered(.), "ordered", + ifelse(is.ordered(.), "ordinal", ifelse(is.numeric(.), "quantitative", ifelse(is.factor(.), "nominal", NA)))), xxxLevels=~( @@ -569,9 +571,7 @@ species.cov <- read_delim("_data/Mesobromion/species.v2.10perc.cov.txt", delim=" #traits <- traits.backup categorical.traits <- colnames(traits)[which(sapply(traits, "is.factor"))] -traits$LeafPersistence <- factor(traits$LeafPersistence, - levels=c("immergrün","sommergrün","überwinternd_grün", "vorsommergrün"), - labels=c("eg", "sg", "wg", "se")) + #traits$Pollination <- factor(traits$Pollination, # levels=c("NEKTAR_HONIG_INSEKTEN","POLLEN","WIND" ), # labels=c("insects", "pollen", "wind")) @@ -764,15 +764,14 @@ ggsave("_pics/FigSXXXb_PCA_Fuzzy_2-3_wSpecies.png", width=8, height=8, dpi=300, #### 4.1 PCA of Y (Bealls) matrix + CWM #### W.beals <- as.data.frame(beals(species.cov %>% - column_to_rownames("RELEVE_NR") %>% - mutate_all(~(.>0)*1), #transform to p\a - include=T, type=2)) + column_to_rownames("RELEVE_NR"), + include=T, type=2)) write.table(W.beals, sep="\t", file="_derived/Mesobromion/MatrixY_Beals.csv") pca.out <- rda(W.beals) varexpl <- round((pca.out$CA$eig)/sum(pca.out$CA$eig)*100,1) cwms.envfit <- envfit(pca.out, CWM.wide, na.rm = T, choices = 1:5) env.envfit <- envfit(pca.out, env %>% - dplyr::select(Temp, Prec, pH=PHIPHOX, C.org=ORCDRC), choices=1:5) + dplyr::select(Temp, Prec, pH=PHIPHOX, C.org=ORCDRC), choices=1:4, na.rm = T) ### Transform to correlations and sink envfits ### see https://www.davidzeleny.net/anadat-r/doku.php/en:suppl_vars_examples for procedure @@ -804,9 +803,9 @@ myvectors <- as.data.frame(env.cor) %>% bind_rows(as.data.frame(cwms.cor) %>% rownames_to_column("mylab") %>% mutate(category="Trait")) %>% - bind_rows(as.data.frame(fuzz.cor) %>% - rownames_to_column("mylab") %>% - mutate(category="Fuzzy-Weighted")) %>% + #bind_rows(as.data.frame(fuzz.cor) %>% + # rownames_to_column("mylab") %>% + # mutate(category="Fuzzy-Weighted")) %>% mutate(fontface0=ifelse(mylab %in% best.4traits, "bold", "italic")) %>% mutate(category=as.factor(category)) %>% mutate(mycol=ifelse(category=="Trait", oilgreen, orange)) %>%