Mercurial > repos > ecology > tool_anonymization
annotate graph_lcbd.r @ 0:c586703ea141 draft default tip
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
| author | ecology | 
|---|---|
| date | Fri, 13 Aug 2021 18:13:54 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 0 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 1 #Rscript | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 2 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 3 ######################### | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 4 ## Beta diversity ## | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 5 ######################### | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 6 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 7 #####Packages : ggplot2 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 8 # vegan | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 9 # adespatial | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 10 # dplyr | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 11 # tibble | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 12 # tdyr | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 13 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 14 #####Load arguments | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 15 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 16 args <- commandArgs(trailingOnly = TRUE) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 17 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 18 if (length(args) < 2) { | 
| 
c586703ea141
"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") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 20 }else{ | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 21 table <- args[1] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 22 hr <- args[2] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 23 abund <- as.numeric(args[3]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 24 loc <- as.numeric(args[4]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 25 spe <- as.numeric(args[5]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 26 date <- as.numeric(args[6]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 27 map <- as.logical(args[7]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 28 sepa <- as.logical(args[8]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 29 not <- as.logical(args[9]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 30 lat <- as.numeric(args[10]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 31 long <- as.numeric(args[11]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 32 var <- as.numeric(args[12]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 33 source(args[13]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 34 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 35 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 36 if (hr == "false") { | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 37 hr <- FALSE | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 38 }else{ | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 39 hr <- TRUE | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 40 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 41 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 42 #####Import data | 
| 
c586703ea141
"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") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 44 colabund <- colnames(data)[abund] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 45 colloc <- colnames(data)[loc] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 46 if (map) { | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 47 collat <- colnames(data)[lat] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 48 collong <- colnames(data)[long] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 49 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 50 colspe <- colnames(data)[spe] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 51 coldate <- colnames(data)[date] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 52 data[, coldate] <- as.factor(data[, coldate]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 53 | 
| 
c586703ea141
"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), ] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 55 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 56 if (sepa) { | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 57 colvar <- colnames(data)[var] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 58 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 59 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 60 # Data for species | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 62 nb_spe <- length(unique(data[, spe])) | 
| 
c586703ea141
"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 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 64 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 65 #Data with coordinates and environmental | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 66 if (map) { | 
| 
c586703ea141
"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)] | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 68 colnames(data_xy) <- c("latitude", "longitude") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 69 # Data for environment | 
| 
c586703ea141
"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)] | 
| 
c586703ea141
"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") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 72 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 73 | 
| 
c586703ea141
"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 | 
| 
c586703ea141
"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)] | 
| 
c586703ea141
"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]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 77 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 78 #####Your analysis | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 79 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 80 # Computation beta.div {adespatial} | 
| 
c586703ea141
"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 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 83 | 
| 
c586703ea141
"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") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 85 cat("##############################################################################", | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 86 "\n########################### Beta Diversity Summary ###########################", | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 87 "\n##############################################################################", | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 88 "\n\n### All data ###", | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 89 "\nBeta diversity: ", data_beta$beta[[2]], | 
| 
c586703ea141
"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]], | 
| 
c586703ea141
"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 ###", | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 92 "\n", capture.output(data_beta$LCBD), | 
| 
c586703ea141
"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 ###", | 
| 
c586703ea141
"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), | 
| 
c586703ea141
"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 ###", | 
| 
c586703ea141
"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), | 
| 
c586703ea141
"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) ###", | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 99 | 
| 
c586703ea141
"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? | 
| 
c586703ea141
"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)]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 102 write(scbd, "SCBD.txt") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 103 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 104 ##1st fonction | 
| 
c586703ea141
"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) { | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 107 | 
| 
c586703ea141
"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)) + | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 109 ggplot2::geom_point() + | 
| 
c586703ea141
"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") + | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 111 ggplot2::xlab("Longitude") + ggplot2::ylab("Latitude") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 112 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 114 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 115 | 
| 
c586703ea141
"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 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 117 #################################################### | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 118 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 119 ####LCBD#### | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 121 | 
| 
c586703ea141
"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) { | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 123 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 124 ############# | 
| 
c586703ea141
"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]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 126 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 127 ## Map spatio-temp | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 128 ################## | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"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") | 
| 
c586703ea141
"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") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 132 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 134 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 135 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 136 ## Par années | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 137 ############# | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 140 date <- unique(mat_lcbd_site$date) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 141 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 143 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"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") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 146 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 148 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 149 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 150 ## Choose another graph | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 151 ####################### | 
| 
c586703ea141
"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) { | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 153 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 154 ############# | 
| 
c586703ea141
"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]) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 156 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"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") | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 160 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 162 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 163 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 164 ####SCBD### | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 165 # Function to compute SCBD | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 166 library(dplyr) | 
| 
c586703ea141
"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) { | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 168 # Computation using beta.div {adespatial} on | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 169 # Hellinger-transformed species data | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 170 | 
| 
c586703ea141
"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? | 
| 
c586703ea141
"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)] %>% | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 173 as.data.frame() %>% | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 174 tibble::rownames_to_column(var = "Taxon") %>% | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 175 dplyr::mutate("Methode" = z) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 176 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 177 return(spe_scbd) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 178 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 179 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 180 # Function to make a radar plot | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 181 | 
| 
c586703ea141
"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) { | 
| 
c586703ea141
"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")) | 
| 
c586703ea141
"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" | 
| 
c586703ea141
"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, | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 186 direction = sign(direction)), | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 187 is_linear = function(coord) TRUE) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 188 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 189 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 190 # Make the radar plot | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 191 radar_plot <- function(scbd_uvc_tc) { | 
| 
c586703ea141
"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 %>% | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 193 rename(scbd_score = ".") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 194 | 
| 
c586703ea141
"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)) + | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 196 ggplot2::geom_line() + | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 197 ggplot2::geom_point(size = 3) + | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 198 coord_radar() + | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 199 ggplot2::theme_bw() + | 
| 
c586703ea141
"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), | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 201 legend.position = "bottom") | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 202 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 204 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 205 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 206 ## LCBD | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 207 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 208 if (map) { | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 209 #Beta diversity | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 211 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 212 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 213 #Lcbd per places and time | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 215 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 216 #Lcbd of your choice | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 217 if (sepa) { | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 219 } | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 220 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 221 ##SCBD | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 222 | 
| 
c586703ea141
"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) | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 224 | 
| 
c586703ea141
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 ecology parents: diff
changeset | 225 radar_plot(scbd_uvc_tc) | 
