Mercurial > repos > ecology > ecology_homogeneity_normality
annotate graph_lcbd.r @ 1:3df8937fd6fd draft default tip
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
author | ecology |
---|---|
date | Fri, 13 Aug 2021 18:16:46 +0000 |
parents | |
children |
rev | line source |
---|---|
1
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
1 #Rscript |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
2 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
3 ######################### |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
4 ## Beta diversity ## |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
5 ######################### |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
6 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
7 #####Packages : ggplot2 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
8 # vegan |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
9 # adespatial |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
10 # dplyr |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
11 # tibble |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
12 # tdyr |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
13 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
14 #####Load arguments |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
15 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
16 args <- commandArgs(trailingOnly = TRUE) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
17 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
18 if (length(args) < 2) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
19 stop("This tool needs at least 2 arguments") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
20 }else{ |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
21 table <- args[1] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
22 hr <- args[2] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
23 abund <- as.numeric(args[3]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
24 loc <- as.numeric(args[4]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
25 spe <- as.numeric(args[5]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
26 date <- as.numeric(args[6]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
27 map <- as.logical(args[7]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
28 sepa <- as.logical(args[8]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
29 not <- as.logical(args[9]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
30 lat <- as.numeric(args[10]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
31 long <- as.numeric(args[11]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
32 var <- as.numeric(args[12]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
33 source(args[13]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
34 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
35 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
36 if (hr == "false") { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
37 hr <- FALSE |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
38 }else{ |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
39 hr <- TRUE |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
40 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
41 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
42 #####Import data |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
43 data <- read.table(table, sep = "\t", dec = ".", header = hr, fill = TRUE, encoding = "UTF-8") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
44 colabund <- colnames(data)[abund] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
45 colloc <- colnames(data)[loc] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
46 if (map) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
47 collat <- colnames(data)[lat] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
48 collong <- colnames(data)[long] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
49 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
50 colspe <- colnames(data)[spe] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
51 coldate <- colnames(data)[date] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
52 data[, coldate] <- as.factor(data[, coldate]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
53 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
54 data <- data[grep("^$", data[, spe], invert = TRUE), ] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
55 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
56 if (sepa) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
57 colvar <- colnames(data)[var] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
58 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
59 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
60 # Data for species |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
61 data_num <- make_table_analyse(data, colabund, colspe, colloc, coldate) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
62 nb_spe <- length(unique(data[, spe])) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
63 nb_col <- ncol(data_num) - nb_spe + 1 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
64 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
65 #Data with coordinates and environmental |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
66 if (map) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
67 data_xy <- data_num[, c(collat, collong)] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
68 colnames(data_xy) <- c("latitude", "longitude") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
69 # Data for environment |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
70 data_env <- data_num[, c(colloc, collat, collong)] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
71 colnames(data_env) <- c("site", "latitude", "longitude") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
72 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
73 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
74 # Data with only species and their abundance |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
75 data_spe <- data_num[, nb_col:ncol(data_num)] |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
76 rownames(data_spe) <- paste0(data_num[, colloc], " - ", data_num[, coldate]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
77 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
78 #####Your analysis |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
79 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
80 # Computation beta.div {adespatial} |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
81 # Beta.div on Hellinger-transformed species data |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
82 data_beta <- adespatial::beta.div(data_spe, method = "hellinger", nperm = 9999) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
83 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
84 save(data_beta, file = "beta_diversity.Rdata") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
85 cat("##############################################################################", |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
86 "\n########################### Beta Diversity Summary ###########################", |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
87 "\n##############################################################################", |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
88 "\n\n### All data ###", |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
89 "\nBeta diversity: ", data_beta$beta[[2]], |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
90 "\nSum of Squares: ", data_beta$beta[[1]], |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
91 "\n\n### Vector of Local Contributions to Beta Diversity (LCBD) for the sites each date ###", |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
92 "\n", capture.output(data_beta$LCBD), |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
93 "\n\n### Vector of P-values associated with the LCBD indices ###", |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
94 "\n", capture.output(data_beta$p.LCBD), |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
95 "\n\n### Vector of Corrected P-values for the LCBD indices, Holm correction ###", |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
96 "\n", capture.output(data_beta$p.adj), |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
97 "\n\n### Vector of Species contributions to beta diversity (SCBD) ###", |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
98 "\n", capture.output(data_beta$SCBD), file = "LCBD.txt", fill = 1, append = TRUE) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
99 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
100 # Which species have a SCBD larger than the mean SCBD? |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
101 scbd <- capture.output(data_beta$SCBD[data_beta$SCBD >= mean(data_beta$SCBD)]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
102 write(scbd, "SCBD.txt") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
103 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
104 ##1st fonction |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
105 beta_div_ext <- function(data_beta, data_xy, data_env) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
106 data_beta_ext <- data.frame(data_xy, data_env, LCBD = data_beta$LCBD * 100, p.LCBD = data_beta$p.LCBD, signif = data_beta$p.LCBD < 0.05) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
107 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
108 graph_beta_ext <- ggplot2::ggplot(data = data_beta_ext, ggplot2::aes(x = latitude, y = longitude, size = LCBD, col = signif)) + |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
109 ggplot2::geom_point() + |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
110 ggplot2::scale_colour_manual(values = c("#57bce0", "#ce0b0b"), labels = c("Non significant", "Significant"), name = "Significance at 0.05") + |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
111 ggplot2::xlab("Longitude") + ggplot2::ylab("Latitude") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
112 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
113 ggplot2::ggsave("Beta_diversity_through_space.png", graph_beta_ext) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
114 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
115 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
116 ## Boyé et al. 2017 JSR Fig R |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
117 #################################################### |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
118 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
119 ####LCBD#### |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
120 lcbd_site <- adespatial::beta.div(data_spe, "hellinger", nperm = 999) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
121 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
122 compute_lcbd <- function(data_beta, data_spe, data_num) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
123 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
124 ############# |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
125 mat_lcbd_site <- data.frame(data_spe, LCBD = data_beta$LCBD * 100, p.LCBD = data_beta$p.LCBD, signif = data_beta$p.LCBD < 0.05, site = data_num[, colloc], date = data_num[, coldate]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
126 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
127 ## Map spatio-temp |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
128 ################## |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
129 p1 <- ggplot2::qplot(date, site, size = LCBD, col = signif, data = mat_lcbd_site) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
130 p1 <- p1 + ggplot2::scale_colour_manual(values = c("#57bce0", "#ce0b0b"), labels = c("Non significant", "Significant"), name = "Significance at 0.05") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
131 p1 <- p1 + ggplot2::theme_bw() + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90)) + ggplot2::xlab("Date") + ggplot2::ylab("Site") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
132 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
133 ggplot2::ggsave("LCBD_sites_time.png", p1) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
134 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
135 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
136 ## Par années |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
137 ############# |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
138 mean_time <- tapply(mat_lcbd_site$LCBD, mat_lcbd_site$date, mean) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
139 sd_time <- tapply(mat_lcbd_site$LCBD, mat_lcbd_site$date, sd) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
140 date <- unique(mat_lcbd_site$date) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
141 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
142 data <- data.frame(date, mean_time, sd_time) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
143 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
144 time <- ggplot2::ggplot() + ggplot2::geom_pointrange(ggplot2::aes(x = date, y = mean_time, ymin = mean_time - sd_time, ymax = mean_time + sd_time), data = data) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
145 time <- time + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90), axis.line.y = ggplot2::element_line(size = 0.5)) + ggplot2::ylab("mean LCBD") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
146 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
147 ggplot2::ggsave("Mean_LCBD_through_time.png", time) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
148 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
149 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
150 ## Choose another graph |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
151 ####################### |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
152 compute_lcbd2 <- function(data_beta, data_spe, data_num) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
153 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
154 ############# |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
155 mat_lcbd_site <- data.frame(data_spe, LCBD = data_beta$LCBD * 100, p.LCBD = data_beta$p.LCBD, signif = data_beta$p.LCBD < 0.05, site = data_num[, colloc], date = data_num[, coldate], variable = data_num[, colvar]) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
156 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
157 p1 <- ggplot2::qplot(date, variable, size = LCBD, col = signif, data = mat_lcbd_site) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
158 p1 <- p1 + ggplot2::scale_colour_manual(values = c("#57bce0", "#ce0b0b"), labels = c("Non significant", "Significant"), name = "Significance at 0.05") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
159 p1 <- p1 + ggplot2::theme_bw() + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90)) + ggplot2::xlab("Date") + ggplot2::ylab(colvar) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
160 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
161 ggplot2::ggsave(paste0("LCBD_per_", colvar, "_through_time.png"), p1) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
162 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
163 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
164 ####SCBD### |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
165 # Function to compute SCBD |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
166 library(dplyr) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
167 make_scbd_uvc <- function(data_spe, z, data_beta) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
168 # Computation using beta.div {adespatial} on |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
169 # Hellinger-transformed species data |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
170 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
171 # Which species have a SCBD larger than the mean SCBD? |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
172 spe_scbd <- data_beta$SCBD[data_beta$SCBD >= mean(data_beta$SCBD)] %>% |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
173 as.data.frame() %>% |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
174 tibble::rownames_to_column(var = "Taxon") %>% |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
175 dplyr::mutate("Methode" = z) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
176 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
177 return(spe_scbd) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
178 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
179 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
180 # Function to make a radar plot |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
181 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
182 coord_radar <- function(theta = "x", start = 0, direction = 1) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
183 theta <- match.arg(theta, c("x", "y")) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
184 r <- if (theta == "x") "y" else "x" |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
185 ggplot2::ggproto("CordRadar", ggplot2::coord_polar(theta = theta, start = start, |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
186 direction = sign(direction)), |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
187 is_linear = function(coord) TRUE) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
188 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
189 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
190 # Make the radar plot |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
191 radar_plot <- function(scbd_uvc_tc) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
192 uvc_rd_plot_data <- scbd_uvc_tc %>% |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
193 rename(scbd_score = ".") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
194 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
195 rad_uvc <- ggplot2::ggplot(uvc_rd_plot_data, ggplot2::aes(x = Taxon, y = scbd_score, group = Methode)) + |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
196 ggplot2::geom_line() + |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
197 ggplot2::geom_point(size = 3) + |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
198 coord_radar() + |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
199 ggplot2::theme_bw() + |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
200 ggplot2::theme(axis.text.x = ggplot2::element_text(size = 10), |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
201 legend.position = "bottom") |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
202 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
203 ggplot2::ggsave("SCBD_Species_Radar_plot.png", rad_uvc) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
204 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
205 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
206 ## LCBD |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
207 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
208 if (map) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
209 #Beta diversity |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
210 beta_div_ext(data_beta, data_xy, data_env) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
211 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
212 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
213 #Lcbd per places and time |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
214 compute_lcbd(data_beta, data_spe, data_num) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
215 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
216 #Lcbd of your choice |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
217 if (sepa) { |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
218 compute_lcbd2(data_beta, data_spe, data_num) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
219 } |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
220 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
221 ##SCBD |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
222 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
223 scbd_uvc_tc <- make_scbd_uvc(data_spe, z = "TC", data_beta) |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
224 |
3df8937fd6fd
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
ecology
parents:
diff
changeset
|
225 radar_plot(scbd_uvc_tc) |