Mercurial > repos > ecology > ecology_link_between_var
annotate funct_anomy.r @ 1:3d132544bd80 draft default tip
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
| author | ecology | 
|---|---|
| date | Fri, 13 Aug 2021 18:15:08 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 
1
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
1 #Rscript | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
2 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
3 ########################### | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
4 ## Anonymization ## | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
5 ########################### | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
6 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
7 #####Packages : tangles | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
8 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
9 #Load arguments | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
10 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
11 args <- commandArgs(trailingOnly = TRUE) | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
12 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
13 if (length(args) == 0) { | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
14 stop("This tool needs at least one argument") | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
15 }else{ | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
16 table <- args[1] | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
17 hr <- args[2] | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
18 latitude <- as.numeric(args[3]) | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
19 longitude <- as.numeric(args[4]) | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
20 } | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
21 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
22 if (hr == "false") { | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
23 hr <- FALSE | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
24 }else{ | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
25 hr <- TRUE | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
26 } | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
27 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
28 #####Import data | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
29 data <- read.table(table, sep = "\t", dec = ".", header = hr, fill = TRUE, encoding = "UTF-8") | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
30 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
31 randomized_data <- tangles::tangles(data = as.matrix(data[, c(latitude, longitude)]), depth = 3, rasterdata = FALSE, raster_object = FALSE, saveTangles = FALSE, path = NULL) | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
32 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
33 data[, c(latitude, longitude)] <- NULL | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
34 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
35 tab_anon <- data.frame(longitude = randomized_data[[1]]$X, latitude = randomized_data[[1]]$Y) | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
36 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
37 tab_anon <- cbind(data, tab_anon) | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
38 | 
| 
 
3d132544bd80
"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
 
ecology 
parents:  
diff
changeset
 | 
39 write.table(tab_anon, "anonym_data.tabular", row.names = FALSE, quote = FALSE, sep = "\t", dec = ".", fileEncoding = "UTF-8") | 
