packages
# install if required
if(!require(tidyverse)){install.packages("tidyverse")}
if(!require(googlesheets4)){install.packages("googlesheets4")}
if(!require(vegan)){install.packages("vegan")}
if(!require(ggrepel)){install.packages("ggrepel")}
if(!require(plotly)){install.packages("plotly")}
if(!require(BiodiversityR)){install.packages("BiodiversityR")}
# Load
library(tidyverse)
library(googlesheets4); gs4_deauth()
library(vegan)
library(ggrepel)
library(BiodiversityR) # also loads vegan
library(readxl)
library(ggsci)
library(ggrepel)
library(ggforce)
Base de datos. Google Sheet
ss= "https://docs.google.com/spreadsheets/d/1NKOlD_JM-rQaAAozckglz4csL85TdwYLNToGv3nHcjY/edit?usp=sharing"
hoja= "adonis_ejemplo"
rango="J1:FC114"
#
cr.sp <- read_sheet(ss,
sheet=hoja,
range=rango,
col_names = TRUE,
col_types = NULL,
na= "NA")
cr.sp <- as.data.frame(cr.sp)
spec.columns <- as.character(colnames(cr.sp))
names(cr.sp) <- spec.columns
dim(cr.sp)
## [1] 113 150
str(cr.sp)
## 'data.frame': 113 obs. of 150 variables:
## $ 1 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 2 : num 0 0 0 1 2 2 0 0 0 0 ...
## $ 3 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 4 : num 0 1 0 1 0 0 0 3 0 0 ...
## $ 5 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 6 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 7 : num 0 0 0 0 0 0 0 0 1 0 ...
## $ 8 : num 0 0 0 0 0 0 0 0 0 1 ...
## $ 9 : num 0 0 0 11 0 0 0 0 0 2 ...
## $ 10 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 11 : num 2 0 1 2 0 0 0 2 0 0 ...
## $ 12 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 13 : num 3 0 0 0 0 0 0 0 0 1 ...
## $ 14 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 15 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 16 : num 0 0 0 2 0 0 0 0 0 4 ...
## $ 17 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 18 : num 0 1 0 0 0 3 4 0 0 0 ...
## $ 19 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 20 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 21 : num 0 0 8 0 0 0 0 0 0 0 ...
## $ 22 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 23 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 24 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 26 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 28 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 29 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 30 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 31 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 32 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 33 : num 0 0 0 0 0 0 0 0 4 0 ...
## $ 34 : num 0 0 0 1 1 0 0 0 0 0 ...
## $ 35 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 36 : num 2 0 8 0 2 2 0 0 0 0 ...
## $ 37 : num 0 0 1 0 0 6 1 0 0 0 ...
## $ 38 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 39 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 40 : num 0 1 13 8 4 3 8 6 3 0 ...
## $ 41 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 42 : num 0 0 0 5 0 3 2 0 0 1 ...
## $ 43 : num 0 0 0 0 0 0 0 1 1 0 ...
## $ 45 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 46 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 47 : num 0 0 0 0 0 0 2 0 0 0 ...
## $ 48 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 49 : num 1 0 1 0 0 0 0 0 0 0 ...
## $ 50 : num 1 0 4 2 1 1 1 2 0 0 ...
## $ 51 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 52 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 53 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 54 : num 0 0 0 0 0 0 2 0 0 0 ...
## $ 55 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 56 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 57 : num 0 0 0 0 0 0 0 1 0 0 ...
## $ 58 : num 1 0 0 0 0 0 4 1 0 1 ...
## $ 59 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 60 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 61 : num 5 0 5 2 0 2 3 0 0 0 ...
## $ 63 : num 0 0 0 0 0 0 0 0 0 2 ...
## $ 64 : num 5 0 0 0 0 0 0 0 0 2 ...
## $ 65 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 66 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 67 : num 1 0 2 0 0 0 1 0 0 0 ...
## $ 68 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 69 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 70 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 71 : num 0 0 0 0 0 4 0 0 0 0 ...
## $ 72 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 73 : num 0 0 0 0 0 0 2 0 0 0 ...
## $ 74 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 75 : num 4 2 0 3 3 0 0 0 4 3 ...
## $ 76 : num 2 0 0 2 0 0 0 0 0 0 ...
## $ 77 : num 0 1 0 1 1 0 1 2 0 0 ...
## $ 78 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 79 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 80 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 81 : num 0 0 0 2 0 0 1 0 0 0 ...
## $ 82 : num 1 0 0 0 0 1 0 0 0 0 ...
## $ 83 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 84 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 85 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 86 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 87 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 88 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 89 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 90 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 91 : num 1 0 0 0 0 0 0 0 0 0 ...
## $ 92 : num 0 1 0 0 0 0 1 0 0 0 ...
## $ 93 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 94 : num 1 0 1 2 1 0 0 1 0 1 ...
## $ 96 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 97 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 98 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ 99 : num 0 0 0 4 0 0 0 2 0 1 ...
## $ 100: num 0 0 0 0 0 0 0 0 0 0 ...
## $ 101: num 0 0 0 0 0 0 0 0 0 4 ...
## $ 102: num 0 0 0 0 0 0 0 0 0 0 ...
## $ 103: num 0 0 0 0 0 0 0 0 0 0 ...
## $ 104: num 0 0 0 0 0 0 0 0 0 0 ...
## [list output truncated]
## EnV Data
ss= "https://docs.google.com/spreadsheets/d/1NKOlD_JM-rQaAAozckglz4csL85TdwYLNToGv3nHcjY/edit?usp=sharing"
hoja="adonis_ejemplo"
rango="A1:H114"
cr.env <- read_sheet(ss,
sheet=hoja,
range=rango,
col_names = TRUE,
col_types = NULL,
na= "NA")
cr.env <- as.data.frame(cr.env)
site.rows <- as.character(cr.env[,1])
cr.env <- cr.env[,2:8]
rownames(cr.env) <- site.rows
cr.env$UsoDSuelo <- as.factor(cr.env$UsoDSuelo)
cr.env$Uso2 <- as.factor(cr.env$Uso2)
cr.env$DenArbol <- as.factor(cr.env$DenArbol)
str(cr.env)
## 'data.frame': 113 obs. of 7 variables:
## $ cobdos : num 65.3 65.3 51.7 46.7 55 ...
## $ alt.arbol: num 9.57 9.57 8.1 9 11.3 7 8.2 9.69 11.6 11.7 ...
## $ riqveg : num 5 5 1 4 5 9 3 5 5 8 ...
## $ num.arb : num 27 27 5 8 15 51 74 13 7 40 ...
## $ UsoDSuelo: Factor w/ 12 levels "Bf","Bp","Br",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Uso2 : Factor w/ 3 levels "bosques","Intermedio",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ DenArbol : Factor w/ 2 levels "ADArbol","BDArbol": 1 1 2 2 2 1 1 2 2 1 ...
summary(cr.env)
## cobdos alt.arbol riqveg num.arb
## Min. : 0.00 Min. : 0.000 Min. : 0.000 Min. : 0.00
## 1st Qu.: 21.88 1st Qu.: 6.640 1st Qu.: 3.000 1st Qu.: 7.00
## Median : 64.06 Median : 8.800 Median : 6.000 Median : 23.00
## Mean : 56.74 Mean : 8.623 Mean : 6.969 Mean : 29.21
## 3rd Qu.: 87.66 3rd Qu.:11.510 3rd Qu.: 9.000 3rd Qu.: 46.25
## Max. :100.00 Max. :20.200 Max. :27.000 Max. :101.00
##
## UsoDSuelo Uso2 DenArbol
## Bf :10 bosques :33 ADArbol:69
## Br :10 Intermedio:30 BDArbol:44
## Bsi :10 usedLand :50
## Cp :10
## Pma :10
## Pmb :10
## (Other):53
# checking, rownames
check.datasets(cr.sp, cr.env)
## Warning: rownames for community and environmental datasets are different
rownames(cr.sp) <- rownames(cr.env)
## managing empty cells
check.datasets(cr.sp, cr.env)
## OK
M1 <- cr.sp
M2 <- cr.env
ord.model1 <- metaMDS(M1, distance = "bray", k=2)
## Wisconsin double standardization
## Run 0 stress 0.2963264
## Run 1 stress 0.2970664
## Run 2 stress 0.299017
## Run 3 stress 0.3021013
## Run 4 stress 0.2982188
## Run 5 stress 0.299308
## Run 6 stress 0.3000689
## Run 7 stress 0.2987725
## Run 8 stress 0.2992489
## Run 9 stress 0.3020818
## Run 10 stress 0.3004153
## Run 11 stress 0.2987448
## Run 12 stress 0.2995411
## Run 13 stress 0.2984778
## Run 14 stress 0.2985865
## Run 15 stress 0.3019039
## Run 16 stress 0.3003421
## Run 17 stress 0.2977457
## Run 18 stress 0.2972788
## Run 19 stress 0.2977385
## Run 20 stress 0.2968612
## *** Best solution was not repeated -- monoMDS stopping criteria:
## 20: stress ratio > sratmax
plot2 <- ordiplot(ord.model1, choices = c(1,2))
sites.long2 <- sites.long(plot2, env.data=M2)
species.long2 <- species.long(plot2)
axis.long <- axis.long(ord.model1, choices = c(1,2))
#spec.envfit <- envfit(plot2, env=M2)
#spec.data.envfit <- data.frame(r=spec.envfit$vectors$r, p=spec.envfit$vectors$pvals)
#species.long2 <- species.long(plot2, spec.data=spec.data.envfit)
#species.long2
## Vector Fit
vectors.envfit <- envfit(plot2, env= M2)
vectors.long3 <- vectorfit.long(vectors.envfit)
vectors.long3
## vector axis1 axis2 r p
## cobdos cobdos 0.9311406 0.3646603 0.5327556 0.001
## alt.arbol alt.arbol 0.9695208 0.2450092 0.4831007 0.001
## riqveg riqveg 0.9891275 0.1470603 0.5410070 0.001
## num.arb num.arb 0.9623273 0.2718936 0.4383360 0.001
### Spec >= 0 %
#species.long3 <- species.long2[species.long2$r >= 0.0, ]
#species.long3
### Var Ambientales r >= 0.2
vectors.long3 <- vectors.long3[vectors.long3$r >= 0.25, ]
vectors.long3
## vector axis1 axis2 r p
## cobdos cobdos 0.9311406 0.3646603 0.5327556 0.001
## alt.arbol alt.arbol 0.9695208 0.2450092 0.4831007 0.001
## riqveg riqveg 0.9891275 0.1470603 0.5410070 0.001
## num.arb num.arb 0.9623273 0.2718936 0.4383360 0.001
plot2 <- ordiplot(ord.model1, choices=c(1,2))
plot2
usosuelo.ellipses <- ordiellipse(plot2, groups=M2$DenArbol, display="sites", kind="sd")
usosuelo.ellipses.long <- ordiellipse.long(usosuelo.ellipses, grouping.name="UsoDeSuelo")
plot2 <- ordiplot(ord.model1, choices=c(1,2))
plot2
centroids.long1 <- centroids.long(sites.long2, grouping=sites.long2$DenArbol, FUN = mean, centroids.only = TRUE)
f = 1
plotgg2 <- ggplot() +
geom_vline(xintercept = c(0), color = "grey70", linetype = 2) +
geom_hline(yintercept = c(0), color = "grey70", linetype = 2) +
xlab(axis.long[1, "label"]) +
ylab(axis.long[2, "label"]) +
scale_x_continuous(sec.axis = dup_axis(labels=NULL, name=NULL)) +
scale_y_continuous(sec.axis = dup_axis(labels=NULL, name=NULL)) +
geom_point(data=sites.long2,
aes(x=axis1, y=axis2, col= sites.long2$DenArbol), size=1,shape=19) +
#geom_point(data=species.long3,aes(x=axis1*f, y=axis2*f)) +
#geom_segment(data=species.long3,aes(x=0, y=0, xend=axis1*f, yend=axis2*f),colour="red", linewidth=0.7, arrow=arrow(angle=20)) +
#geom_text_repel(data=sites.long2,aes(x=axis1*f, y=axis2*f, label=labels),colour="red") +
#geom_segment(data=vectors.long3,aes(x=0, y=0, xend=axis1*f, yend=axis2*f),colour="blue", linewidth=0.7, arrow=arrow(angle=20)) +
#geom_text_repel(data=vectors.long3,aes(x=axis1*f, y=axis2*f, label=vector),colour="blue") +
geom_polygon(data=usosuelo.ellipses.long,
aes(x=axis1, y=axis2, colour= usosuelo.ellipses.long$UsoDeSuelo,
fill=after_scale(alpha(colour, 0.2))),
linewidth=0.2, show.legend=TRUE) +
geom_point(data=centroids.long1,
aes(x=axis1c,y=axis2c, col=centroids.long1$Centroid)) +
#ggsci::scale_color_cosmic() +
coord_fixed(ratio=1)
plotgg2
adonis2(M1~ M2$DenArbol, method = "bray", permutations = 999)
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
##
## adonis2(formula = M1 ~ M2$DenArbol, permutations = 999, method = "bray")
## Df SumOfSqs R2 F Pr(>F)
## M2$DenArbol 1 1.484 0.03824 4.414 0.001 ***
## Residual 111 37.324 0.96176
## Total 112 38.808 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot2 <- ordiplot(ord.model1, choices=c(1,2))
plot2
## $sites
## NMDS1 NMDS2
## Bf03 -0.0112725034 -0.094121415
## Bf05 0.1850278231 -0.166977376
## Bf01 -0.1594904560 0.036758942
## Bf10 -0.0276241996 0.081212829
## Bf02 -0.1915483064 -0.063654284
## Bf04 -0.1594367759 -0.249330049
## Bf06 -0.1065623458 0.130394256
## Bf07 0.1530763321 0.216300326
## Bf08 -0.1717527962 0.172837434
## Bf09 0.0004715869 0.286819364
## Bp01 -0.2459093017 0.302580795
## Bp02 0.6247917521 -0.174995077
## Bp03 0.1168092186 0.198503128
## Bp04 0.3631184228 -0.382867293
## Bp05 0.2293078367 0.201014197
## Bp06 0.0898426897 -0.342765231
## Br05 0.3823631797 -0.046275494
## Br08 0.1438706847 -0.457863077
## Br01 -0.0427330324 -0.023617422
## Br10 0.4175357683 -0.124287921
## Br02 -0.0164580460 0.012482842
## Br03 0.1950522494 -0.126657879
## Br04 0.3232465341 -0.008413851
## Br06 0.1974964291 0.077532555
## Br07 0.2706381767 0.119719232
## Br09 0.2598384212 0.072730108
## Bs01 -0.0387694441 -0.061542021
## Bs02 0.3682802212 -0.179927230
## Bs03 -0.0458157960 -0.132022689
## Bs04 0.4966637022 0.079524054
## Bs05 0.2683968382 -0.130990709
## Bs06 0.3915827312 0.256865640
## Bs07 0.5089918362 -0.232324497
## Bsi03 0.2214485949 -0.034225851
## Bsi07 0.3719728415 0.094219068
## Bsi01 -0.0605304500 -0.003012225
## Bsi10 0.4955540484 0.162552426
## Bsi02 0.3095202888 0.023047297
## Bsi04 0.4819812630 -0.048301835
## Bsi05 -0.0586765852 0.143093878
## Bsi06 0.2025586397 0.367056667
## Bsi08 0.1347916353 0.155878598
## Bsi09 0.2975126289 0.291168695
## Cp06 0.1068464425 0.024732046
## Cp07 -0.0995387361 0.075070082
## Cp01 -0.1200885613 -0.170922114
## Cp10 -0.0589037714 0.226641761
## Cp02 0.0927421230 0.089568537
## Cp03 -0.1028404247 0.150744134
## Cp04 0.1902911873 0.142048497
## Cp05 -0.1819077696 0.227006860
## Cp08 -0.1916278225 0.116572824
## Cp09 0.0439467259 0.259629346
## Pma04 0.0117476057 -0.044012621
## Pma05 -0.1266797147 -0.091602961
## Pma01 -0.1639403376 -0.111563303
## Pma10 0.1029744397 0.335702058
## Pma02 -0.1910791767 -0.197799205
## Pma03 -0.0680694038 -0.048351433
## Pma06 0.1835161092 0.321765199
## Pma07 -0.2468873845 0.035306730
## Pma08 0.0259619907 0.001468020
## Pma09 0.1507365068 -0.073741963
## Pmb08 0.0071550112 0.407538729
## Pmb09 0.0060802413 0.241430869
## Pmb01 -0.1973109595 -0.088545497
## Pmb10 -0.3184554709 0.213679620
## Pmb02 -0.2524447510 -0.134745669
## Pmb03 -0.1343389208 -0.367264990
## Pmb04 -0.1154934855 -0.219864511
## Pmb05 -0.1646365164 0.047858023
## Pmb06 -0.4572678107 0.301751314
## Pmb07 -0.2818667115 -0.109389143
## Pna05 0.0727970306 -0.127862511
## Pna01 -0.3342946583 0.128737278
## Pna10 -0.0957714394 0.181750866
## Pna02 -0.2494694371 0.147298346
## Pna03 -0.0450286133 -0.227374422
## Pna04 0.0413026403 0.133229375
## Pna06 0.1660364266 0.101183937
## Pna07 0.0180043140 0.075072220
## Pna08 -0.0177517716 0.149877372
## Pna09 -0.0778601663 0.050248389
## Pnb07 -0.1049198997 0.297596321
## Pnb01 -0.2267505210 -0.007751913
## Pnb10 -0.1187290342 0.256717706
## Pnb02 -0.3777482851 0.035576075
## Pnb03 -0.2716564992 -0.147720187
## Pnb04 -0.0548023449 -0.257039147
## Pnb05 -0.1958686158 0.002219658
## Pnb06 -0.2313968489 -0.160917789
## Pnb08 0.0135369411 0.190899437
## Pnb09 -0.0779712201 0.307030139
## Pns07 -0.2721087027 -0.063390921
## Pns09 -0.6156684412 -0.004454890
## Pns01 -0.3227174900 -0.012173353
## Pns10 -0.4193176192 -0.376149684
## Pns02 -0.4623471510 -0.187482387
## Pns03 -0.1159964798 -0.137255240
## Pns04 -0.1728138840 -0.033595197
## Pns05 -0.3627996922 -0.191940639
## Pns06 -0.4648877217 -0.156863777
## Pns08 -0.3446851978 -0.046237133
## Sv06 0.2298300936 -0.357411774
## Sv08 0.2130811435 -0.199624889
## Sv01 0.0257148226 -0.088020369
## Sv10 0.1911202413 -0.230118501
## Sv02 0.2584433430 -0.174471707
## Sv03 -0.0238069621 -0.160041284
## Sv04 0.1264184014 -0.232738048
## Sv05 0.0745804088 -0.025649483
## Sv07 0.0136413164 -0.186293794
## Sv09 -0.0011214168 -0.223688231
##
## $species
## NMDS1 NMDS2
## 1 0.2281541170 -0.0920912841
## 2 -0.0395983882 0.1310949050
## 3 0.4007104062 -0.0542740166
## 4 0.1732126726 0.0938974548
## 5 -0.3157626731 0.2713698014
## 6 0.2579685756 0.4941069054
## 7 0.1387716938 -0.1110161003
## 8 0.0006756898 0.5063494365
## 9 -0.1366718463 0.2412300380
## 10 0.1328809270 0.1581238366
## 11 0.1747805848 -0.1501606105
## 12 0.4262761372 0.5140277227
## 13 -0.1389337966 -0.0125914461
## 14 0.4460607444 -0.0238360042
## 15 0.5354742268 -0.0073615803
## 16 0.0764418215 0.2766149814
## 17 0.1677866304 -0.1955879218
## 18 -0.0784148552 -0.1215961201
## 19 -0.2445298295 0.2307269772
## 20 -0.0254347409 0.2645927440
## 21 -0.0187132792 0.1607977411
## 22 0.2061379377 -0.8083091296
## 23 -0.5412377969 0.0628058211
## 24 -0.4562830442 0.3772289060
## 26 0.1667146545 0.2099495464
## 28 0.5754427146 -0.3307371507
## 29 0.5166113342 0.0108183255
## 30 -0.1501476702 0.1188117950
## 31 -0.2827071710 -0.1563177660
## 32 0.4262761372 0.5140277227
## 33 -0.0616075929 -0.0607591734
## 34 -0.5173977599 0.1391714717
## 35 -0.1528195504 -0.3006699031
## 36 -0.1857898500 -0.1597313619
## 37 -0.1846464838 -0.0005135200
## 38 -0.1541861684 0.0703196008
## 39 0.4523606436 -0.0086526506
## 40 -0.2154924810 -0.1087346855
## 41 -0.4562830442 0.3772289060
## 42 -0.0676607243 -0.0916896074
## 43 0.1488343519 0.0004114479
## 45 0.2239940827 0.2724725223
## 46 0.3053026928 -0.3524167559
## 47 -0.1526825443 0.2301973511
## 48 0.4631476802 -0.0148537700
## 49 0.1189779981 0.2769211849
## 50 -0.0854423492 0.0735568618
## 51 -0.1701149772 0.4532081231
## 52 -0.1292327195 0.0249846146
## 53 -0.2468192789 0.1020752494
## 54 -0.1761813204 0.1241874212
## 55 0.4491612407 -0.4429121235
## 56 0.2161580996 0.3125317412
## 57 0.0475588764 0.3475864665
## 58 0.0248839919 0.1357516328
## 59 -0.2606374782 0.4007567479
## 60 -0.0656448791 -0.2330721780
## 61 -0.0057453592 0.1024722378
## 63 0.0665061012 0.0993399841
## 64 -0.0007574885 -0.0420162052
## 65 -0.1924808249 -0.6483677320
## 66 -0.3240502702 -0.2529505007
## 67 -0.3834805351 -0.0636452047
## 68 0.7348676380 -0.1028908592
## 69 0.6008519393 -0.5734542195
## 70 -0.6035215183 -0.2027083609
## 71 -0.1673921484 -0.3429281664
## 72 0.3308674154 -0.3648848652
## 73 0.3243612482 0.0983421348
## 74 0.5610597933 0.4534692854
## 75 -0.0315656115 -0.1550813848
## 76 -0.0154032940 -0.2765453206
## 77 0.1010131538 0.1331016510
## 78 0.3903261757 -0.4022687798
## 79 0.4435409129 -0.3387985164
## 80 0.4174940080 0.4459443748
## 81 -0.2925640566 0.3323530709
## 82 -0.0160699821 -0.0889341218
## 83 0.4771260314 -0.2558429013
## 84 0.7116198235 0.1403913569
## 85 0.1328241892 -0.1664881860
## 86 0.1979516676 0.3554281863
## 87 0.1043035958 -0.2257278226
## 88 0.5329627404 0.1663338604
## 89 -0.0656448791 -0.2330721780
## 90 0.6905828224 -0.0852718114
## 91 0.0486573065 0.0022395730
## 92 -0.0372491708 -0.0993297063
## 93 0.0775539665 0.0364391279
## 94 -0.2860306648 -0.0774710709
## 96 0.3983484535 -0.5214336145
## 97 0.4194935938 -0.6459247485
## 98 0.3343393222 -0.4746828051
## 99 0.0117707649 0.2358223624
## 100 0.0421147446 -0.0906519116
## 101 0.0985851372 0.1923091429
## 102 0.3090759852 0.0291781850
## 103 0.4061458834 -0.1459881977
## 104 0.4564219443 0.1978360508
## 105 0.1638806862 0.0479558754
## 106 0.1361704800 0.1031147278
## 107 0.0591784289 0.2352024564
## 108 0.0697734383 0.0980460832
## 109 -0.1992523541 0.0225961480
## 110 0.1490313763 -0.1774535577
## 111 -0.3143940823 -0.1820276201
## 112 0.1095270371 -0.1098948316
## 113 0.2324571823 -0.2774048918
## 114 -0.2755511120 0.3453000008
## 115 0.2885908884 -0.2036353851
## 116 0.5367332744 -0.2366836432
## 117 0.3020898987 0.4021148303
## 118 -0.0975298515 -0.0853593720
## 119 -0.0050955957 -0.1581327410
## 120 0.3309114780 0.2797295493
## 121 0.5527013040 -0.0251730157
## 122 0.5116695201 0.2824479034
## 123 0.2485746736 0.0710352440
## 124 0.2761681743 -0.1363318881
## 125 -0.3019696710 0.1892914947
## 126 -0.1964149158 -0.2900792692
## 127 -0.5913236409 -0.2992294618
## 128 0.1532018985 0.5405453397
## 130 0.0659822287 -0.2008335404
## 131 0.2046686825 -0.1943675272
## 132 0.0807302185 0.1454957114
## 133 -0.0720021012 0.2723452069
## 134 0.5982453085 -0.2194172589
## 135 0.2090767120 -0.2386292893
## 136 0.3845741255 -0.1566395532
## 137 -0.1230690935 0.3331859258
## 138 -0.0722951828 -0.0683443935
## 139 -0.0264246599 0.1937815485
## 140 0.1891901021 0.0270072155
## 141 -0.1169247440 0.1347569343
## 142 0.1158420553 -0.0924580601
## 143 -0.0062375161 -0.0007602115
## 145 0.0659402328 0.1377461101
## 146 -0.2723528505 -0.1864058062
## 147 -0.3407817188 -0.1110809171
## 148 -0.4452262360 -0.1301688431
## 149 -0.0785208076 -0.4537755932
## 150 0.3877704183 0.2113517195
## 151 -0.0065877326 -0.1586290725
## 152 0.0681534420 0.1834418465
## 153 0.0752709900 -0.1903099046
## 154 0.2126951761 0.2531979508
## 155 -0.1952832573 -0.0946519739
## 156 0.5261130782 0.0911629836
## 157 0.3298841144 0.1804829785
##
## attr(,"class")
## [1] "ordiplot"
usosuelo.ellipses <- ordiellipse(plot2, groups=M2$Uso2, display="sites", kind="sd")
usosuelo.ellipses.long <- ordiellipse.long(usosuelo.ellipses, grouping.name="UsoDeSuelo")
plot2 <- ordiplot(ord.model1, choices=c(1,2))
plot2
centroids.long1 <- centroids.long(sites.long2, grouping=sites.long2$Uso2, FUN = mean, centroids.only = TRUE)
f = 1
plotgg2 <- ggplot() +
geom_vline(xintercept = c(0), color = "grey70", linetype = 2) +
geom_hline(yintercept = c(0), color = "grey70", linetype = 2) +
xlab(axis.long[1, "label"]) +
ylab(axis.long[2, "label"]) +
scale_x_continuous(sec.axis = dup_axis(labels=NULL, name=NULL)) +
scale_y_continuous(sec.axis = dup_axis(labels=NULL, name=NULL)) +
geom_point(data=sites.long2,
aes(x=axis1, y=axis2, col= sites.long2$Uso2), size=1,shape=19) +
#geom_point(data=species.long3,aes(x=axis1*f, y=axis2*f)) +
#geom_segment(data=species.long3,aes(x=0, y=0, xend=axis1*f, yend=axis2*f),colour="red", linewidth=0.7, arrow=arrow(angle=20)) +
#geom_text_repel(data=sites.long2,aes(x=axis1*f, y=axis2*f, label=labels),colour="red") +
#geom_segment(data=vectors.long3,aes(x=0, y=0, xend=axis1*f, yend=axis2*f),colour="blue", linewidth=0.7, arrow=arrow(angle=20)) +
#geom_text_repel(data=vectors.long3,aes(x=axis1*f, y=axis2*f, label=vector),colour="blue") +
geom_polygon(data=usosuelo.ellipses.long,
aes(x=axis1, y=axis2, colour= usosuelo.ellipses.long$UsoDeSuelo,
fill=after_scale(alpha(colour, 0.2))),
linewidth=0.2, show.legend=TRUE) +
geom_point(data=centroids.long1,
aes(x=axis1c,y=axis2c, col=centroids.long1$Centroid)) +
#ggsci::scale_color_cosmic() +
coord_fixed(ratio=1)
plotgg2
###
library(devtools)
install_github("pmartinezarbizu/pairwiseAdonis/pairwiseAdonis")
library(pairwiseAdonis)
pairwise.adonis(x=M1, factors = M2$Uso2, sim.function=, sim.method = "bray", p.adjust.m = "bonferroni")
## pairs Df SumsOfSqs F.Model R2 p.value p.adjusted
## 1 Intermedio vs bosques 1 1.3209234 3.937601 0.06063669 0.001 0.003
## 2 Intermedio vs usedLand 1 0.7080719 2.295593 0.02858928 0.001 0.003
## 3 bosques vs usedLand 1 2.4354977 7.295676 0.08262778 0.001 0.003
## sig
## 1 *
## 2 *
## 3 *