Mercurial > repos > ecology > pampa_glmcomm
annotate FunctPAMPAGalaxy.r @ 4:1f19263c44f9 draft
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
| author | ecology | 
|---|---|
| date | Sun, 22 Nov 2020 18:38:33 +0000 | 
| parents | 2a82d3af9577 | 
| children | fc50b570a5ce | 
| rev | line source | 
|---|---|
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1 #Rscript | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
2 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
3 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
4 ################################################################################################################################## | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
5 ####################### PAMPA Galaxy tools functions : Calculate metrics, compute GLM and plot ################################# | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
6 ################################################################################################################################## | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
7 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
8 #### Based on Yves Reecht R script | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
9 #### Modified by Coline ROYAUX for integrating within Galaxy-E | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
10 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
11 ######################################### start of the function fact.def.f called by FunctExeCalcCommIndexesGalaxy.r and FunctExeCalcPresAbsGalaxy.r | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
12 ####### Define the finest aggregation with the observation table | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
13 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
14 fact_det_f <- function(obs, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
15 size_class = "size.class", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
16 code_species = "species.code", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
17 unitobs = "observation.unit") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
18 if (any(is.element(c(size_class), colnames(obs))) && all(! is.na(obs[, size_class]))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
19 factors <- c(unitobs, code_species, size_class) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
20 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
21 factors <- c(unitobs, code_species) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
22 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
23 return(factors) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
24 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
25 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
26 ######################################### end of the function fact.def.f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
27 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
28 ######################################### start of the function def_typeobs_f called by FunctExeCalcCommIndexesGalaxy.r and FunctExeCalcPresAbsGalaxy.r | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
29 ####### Define observation type from colnames | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
30 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
31 def_typeobs_f <- function(obs) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
32 if (any(is.element(c("rotation", "rot", "rotate"), colnames(obs)))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
33 obs_type <- "SVR" | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
34 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
35 obs_type <- "other" | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
36 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
37 return(obs_type) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
38 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
39 ######################################### end of the function fact.def.f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
40 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
41 ######################################### start of the function create_unitobs called by FunctExeCalcCommIndexesGalaxy.r and FunctExeCalcPresAbsGalaxy.r | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
42 ####### Create unitobs column when inexistant | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
43 create_unitobs <- function(data, year = "year", location = "location", unitobs = "observation.unit") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
44 if (is.element(paste(unitobs), colnames(data))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
45 unitab <- data | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
46 }else{ | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
47 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
48 unitab <- tidyr::unite(data, col = "observation.unit", c(year, location)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
49 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
50 return(unitab) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
51 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
52 ######################################### start of the function create_unitobs | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
53 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
54 ######################################### start of the function create_year_location called by FunctExeCalcCommIndexesGalaxy.r and FunctExeCalcPresAbsGalaxy.r | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
55 ####### separate unitobs column when existant | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
56 create_year_location <- function(data, year = "year", location = "location", unitobs = "observation.unit") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
57 if (all(grepl("[1-2][0|8|9][0-9]{2}_.*", data[, unitobs])) == TRUE) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
58 tab <- tidyr::separate(data, col = unitobs, into = c(year, location), sep = "_") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
59 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
60 if (all(grepl("[A-Z]{2}[0-9]{2}.*", data[, unitobs]) == TRUE)) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
61 tab <- tidyr::separate(data, col = unitobs, into = c("site1", year, "obs"), sep = c(2, 4)) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
62 tab <- tidyr::unite(tab, col = location, c("site1", "obs")) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
63 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
64 tab <- data | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
65 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
66 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
67 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
68 tab <- cbind(tab, observation.unit = data[, unitobs]) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
69 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
70 return(tab) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
71 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
72 ######################################### start of the function create_year_location | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
73 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
74 ######################################### start of the function check_file called by every Galaxy Rscripts | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
75 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
76 check_file <- function(dataset, err_msg, vars, nb_vars) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
77 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
78 ## Purpose: General function to check integrity of input file. Will | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
79 ## check numbers and contents of variables(colnames). | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
80 ## return an error message and exit if mismatch detected | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
81 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
82 ## Arguments: dataset : dataset name | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
83 ## err_msg : output error | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
84 ## vars : expected name of variables | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
85 ## nb_vars : expected number of variables | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
86 ## ---------------------------------------------------------------------- | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
87 ## Author: Alan Amosse, Benjamin Yguel | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
88 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
89 if (ncol(dataset) < nb_vars) { #checking for right number of columns in the file if not = error message | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
90 cat("\nerr nb var\n") | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
91 stop(err_msg, call. = FALSE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
92 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
93 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
94 for (i in vars) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
95 if (!(i %in% names(dataset))) { #checking colnames | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
96 stop(err_msg, call. = FALSE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
97 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
98 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
99 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
100 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
101 ######################################### end of the function check_file | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
102 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
103 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
104 ######################################### start of the function stat_rotations_nb_f called by calc_numbers_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
105 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
106 stat_rotations_nb_f <- function(factors, obs) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
107 ## Purpose: Computing abundance statistics by rotation (max, sd) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
108 ## on SVR data | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
109 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
110 ## Arguments: factors : Names of aggregation factors | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
111 ## obs : observation data | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
112 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
113 ## Author: Yves Reecht, Date: 29 oct. 2012, 16:01 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
114 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
115 ## Identification of valid rotations : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
116 if (is.element("observation.unit", factors)) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
117 ## valid rotations (empty must be there as well) : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
118 rotations <- tapply(obs$rotation, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
119 as.list(obs[, c("observation.unit", "rotation"), drop = FALSE]), | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
120 function(x)length(x) > 0) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
121 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
122 ## Changing NA rotations in FALSE : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
123 rotations[is.na(rotations)] <- FALSE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
124 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
125 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
126 ## ########################################################### | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
127 ## Abundance per rotation at chosen aggregation factors : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
128 nombres_rot <- tapply(obs$number, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
129 as.list(obs[, c(factors, "rotation"), drop = FALSE]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
130 function(x, ...) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
131 ifelse(all(is.na(x)), NA, sum(x, ...)) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
132 }, | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
133 na.rm = TRUE) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
134 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
135 ## If valid rotation NA are considered 0 : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
136 nombres_rot <- sweep(nombres_rot, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
137 match(names(dimnames(rotations)), names(dimnames(nombres_rot)), nomatch = NULL), | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
138 rotations, # Tableau des secteurs valides (booléens). | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
139 function(x, y) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
140 x[is.na(x) & y] <- 0 # Lorsque NA et secteur valide => 0. | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
141 return(x) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
142 }) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
143 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
144 ## ################################################## | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
145 ## Statistics : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
146 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
147 ## Means : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
148 nb_mean <- apply(nombres_rot, which(is.element(names(dimnames(nombres_rot)), factors)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
149 function(x, ...) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
150 ifelse(all(is.na(x)), NA, mean(x, ...)) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
151 }, na.rm = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
152 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
153 ## Maxima : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
154 nb_max <- apply(nombres_rot, which(is.element(names(dimnames(nombres_rot)), factors)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
155 function(x, ...) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
156 ifelse(all(is.na(x)), NA, max(x, ...)) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
157 }, na.rm = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
158 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
159 ## SD : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
160 nb_sd <- apply(nombres_rot, which(is.element(names(dimnames(nombres_rot)), factors)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
161 function(x, ...) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
162 ifelse(all(is.na(x)), NA, sd(x, ...)) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
163 }, na.rm = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
164 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
165 ## Valid rotations count : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
166 nombres_rotations <- apply(rotations, 1, sum, na.rm = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
167 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
168 ## Results returned as list : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
169 return(list(nb_mean = nb_mean, nb_max = nb_max, nb_sd = nb_sd, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
170 nombres_rotations = nombres_rotations, nombresTot = nombres_rot)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
171 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
172 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
173 ######################################### end of the function stat_rotations_nb_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
174 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
175 ######################################### start of the function calc_nb_default_f called by calc_numbers_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
176 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
177 calc_nb_default_f <- function(obs, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
178 factors = c("observation.unit", "species.code", "size.class"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
179 nb_name = "number") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
180 ## Purpose : Compute abundances at finest aggregation | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
181 ## --------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
182 ## Arguments: obs : observation table | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
183 ## factors : aggregation factors | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
184 ## nb_name : name of abundance column. | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
185 ## | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
186 ## Output: array with ndimensions = nfactors. | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
187 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
188 ## Author: Yves Reecht, Date: 19 déc. 2011, 13:38 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
189 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
190 ## Sum individuals number : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
191 nbr <- tapply(obs[, nb_name], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
192 as.list(obs[, factors]), | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
193 sum, na.rm = TRUE) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
194 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
195 ## Absences as "true zero" : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
196 nbr[is.na(nbr)] <- 0 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
197 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
198 return(nbr) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
199 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
200 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
201 ######################################### end of the function calc_nb_default_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
202 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
203 ######################################### start of the function calc_numbers_f | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
204 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
205 calc_numbers_f <- function(obs, obs_type = "", factors = c("observation.unit", "species.code", "size.class"), nb_name = "number") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
206 ## Purpose: Produce data.frame used as table from output of calc_nb_default_f(). | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
207 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
208 ## Arguments: obs : observation table | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
209 ## obs_type : Type of observation (SVR, LIT, ...) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
210 ## factors : aggregation factors | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
211 ## nb_name : name of abundance column | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
212 ## | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
213 ## Output: data.frame with (N aggregation factors + 1) columns | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
214 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
215 ## Author: Yves Reecht, Date: 19 déc. 2011, 13:46 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
216 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
217 if (obs_type == "SVR") { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
218 ## Compute SVR abundances statistics : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
219 stat_rotations <- stat_rotations_nb_f(factors = factors, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
220 obs = obs) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
221 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
222 ## Mean for rotating videos (3 rotations at most times) : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
223 nbr <- stat_rotations[["nb_mean"]] | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
224 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
225 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
226 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
227 nbr <- calc_nb_default_f(obs, factors, nb_name) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
228 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
229 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
230 res <- as.data.frame(as.table(nbr), responseName = nb_name) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
231 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
232 if (is.element("size.class", colnames(res))) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
233 res$size.class[res$size.class == ""] <- NA | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
234 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
235 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
236 ## If integer abundances : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
237 if (isTRUE(all.equal(res[, nb_name], as.integer(res[, nb_name])))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
238 res[, nb_name] <- as.integer(res[, nb_name]) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
239 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
240 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
241 if (obs_type == "SVR") { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
242 ## statistics on abundances : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
243 res[, "number.max"] <- as.vector(stat_rotations[["nb_max"]]) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
244 res[, "number.sd"] <- as.vector(stat_rotations[["nb_sd"]]) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
245 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
246 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
247 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
248 return(res) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
249 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
250 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
251 ######################################### end of the function calc_numbers_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
252 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
253 ######################################### start of the function pres_abs_f called by calc_biodiv_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
254 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
255 pres_abs_f <- function(nombres, logical = FALSE) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
256 ## Purpose: Compute presence absence from abundances | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
257 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
258 ## Arguments: nombres : vector of individuals count. | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
259 ## logical : (boolean) results as boolean or 0/1 ? | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
260 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
261 ## Author: Yves Reecht, Date: 29 oct. 2010, 10:20 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
262 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
263 if (any(nombres < 0, na.rm = TRUE)) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
264 stop("Negative abundances!") | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
265 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
266 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
267 if (logical) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
268 return(nombres > 0) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
269 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
270 nombres[nombres > 0] <- 1 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
271 return(nombres) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
272 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
273 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
274 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
275 ######################################### end of the function pres_abs_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
276 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
277 ######################################### start of the function bettercbind called by agregations_generic_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
278 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
279 bettercbind <- function(..., df_list = NULL, deparse.level = 1) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
280 ## Purpose: Apply cbind to data frame with mathcing columns but without | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
281 ## redundancies. | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
282 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
283 ## Arguments: same as cbind... | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
284 ## df_list : data.frames list | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
285 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
286 ## Author: Yves Reecht, Date: 17 janv. 2012, 21:10 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
287 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
288 if (is.null(df_list)) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
289 df_list <- list(...) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
290 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
291 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
292 return(do.call(cbind, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
293 c(list(df_list[[1]][, c(tail(colnames(df_list[[1]]), -1), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
294 head(colnames(df_list[[1]]), 1))]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
295 lapply(df_list[- 1], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
296 function(x, coldel) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
297 return(x[, !is.element(colnames(x), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
298 coldel), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
299 drop = FALSE]) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
300 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
301 coldel = colnames(df_list[[1]])), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
302 deparse.level = deparse.level))) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
303 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
304 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
305 ######################################### end of the function bettercbind | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
306 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
307 ######################################### start of the function agregation_f called by agregations_generic_f | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
308 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
309 agregation_f <- function(metric, d_ata, factors, cas_metric, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
310 nb_name = "number") { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
311 ## Purpose: metric aggregation | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
312 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
313 ## Arguments: metric: colnames of chosen metric | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
314 ## d_ata: Unaggregated data table | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
315 ## factors: aggregation factors vector | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
316 ## cas_metric: named vector of observation types depending | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
317 ## on chosen metric | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
318 ## nb_name : abundance column name | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
319 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
320 ## Author: Yves Reecht, Date: 20 déc. 2011, 14:29 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
321 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
322 switch(cas_metric[metric], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
323 "sum" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
324 res <- tapply(d_ata[, metric], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
325 as.list(d_ata[, factors, drop = FALSE]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
326 function(x) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
327 ifelse(all(is.na(x)), | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
328 NA, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
329 sum(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
330 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
331 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
332 "w.mean" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
333 res <- tapply(seq_len(nrow(d_ata)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
334 as.list(d_ata[, factors, drop = FALSE]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
335 function(ii) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
336 ifelse(all(is.na(d_ata[ii, metric])), | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
337 NA, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
338 weighted.mean(d_ata[ii, metric], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
339 d_ata[ii, nb_name], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
340 na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
341 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
342 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
343 "w.mean.colonies" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
344 res <- tapply(seq_len(nrow(d_ata)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
345 as.list(d_ata[, factors, drop = FALSE]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
346 function(ii) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
347 ifelse(all(is.na(d_ata[ii, metric])), | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
348 NA, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
349 weighted.mean(d_ata[ii, metric], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
350 d_ata[ii, "colonies"], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
351 na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
352 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
353 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
354 "w.mean.prop" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
355 res <- tapply(seq_len(nrow(d_ata)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
356 as.list(d_ata[, factors, drop = FALSE]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
357 function(ii) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
358 ifelse(all(is.na(d_ata[ii, metric])) || sum(d_ata[ii, "nombre.tot"], na.rm = TRUE) == 0, | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
359 NA, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
360 ifelse(all(na.omit(d_ata[ii, metric]) == 0), | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
361 0, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
362 (sum(d_ata[ii, nb_name][!is.na(d_ata[ii, metric])], na.rm = TRUE) / | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
363 sum(d_ata[ii, "nombre.tot"], na.rm = TRUE)) * | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
364 ## Correction if size class isn't an aggregation factor | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
365 ## (otherwise value divided by number of present classes) : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
366 ifelse(is.element("size.class", factors), | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
367 100, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
368 100 * length(unique(d_ata$size.class))))) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
369 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
370 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
371 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
372 "w.mean.prop.bio" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
373 res <- tapply(seq_len(nrow(d_ata)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
374 as.list(d_ata[, factors, drop = FALSE]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
375 function(ii) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
376 ifelse(all(is.na(d_ata[ii, metric])) || sum(d_ata[ii, "tot.biomass"], na.rm = TRUE) == 0, | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
377 NA, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
378 ifelse(all(na.omit(d_ata[ii, metric]) == 0), | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
379 0, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
380 (sum(d_ata[ii, "biomass"][!is.na(d_ata[ii, metric])], na.rm = TRUE) / | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
381 sum(d_ata[ii, "tot.biomass"], na.rm = TRUE)) * | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
382 ## Correction if size class isn't an aggregation factor | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
383 ## (otherwise value divided by number of present classes) : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
384 ifelse(is.element("size.class", factors), | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
385 100, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
386 100 * length(unique(d_ata$size.class))))) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
387 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
388 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
389 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
390 "pres" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
391 res <- tapply(d_ata[, metric], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
392 as.list(d_ata[, factors, drop = FALSE]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
393 function(x) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
394 ifelse(all(is.na(x)), # When only NAs. | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
395 NA, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
396 ifelse(any(x > 0, na.rm = TRUE), # Otherwise... | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
397 1, # ... presence if at least one observation in the group. | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
398 0)) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
399 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
400 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
401 "nbMax" = { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
402 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
403 ## Sum by factor cross / rotation : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
404 nb_tmp2 <- apply(nb_tmp, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
405 which(is.element(names(dimnames(nb_tmp)), c(factors, "rotation"))), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
406 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
407 ifelse(all(is.na(x)), NA, sum(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
408 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
409 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
410 ## Sum by factor cross : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
411 res <- as.array(apply(nb_tmp2, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
412 which(is.element(names(dimnames(nb_tmp)), factors)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
413 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
414 ifelse(all(is.na(x)), NA, max(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
415 })) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
416 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
417 "nbSD" = { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
418 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
419 ## Sum by factor cross / rotation : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
420 nb_tmp2 <- apply(nb_tmp, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
421 which(is.element(names(dimnames(nb_tmp)), c(factors, "rotation"))), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
422 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
423 ifelse(all(is.na(x)), NA, sum(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
424 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
425 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
426 ## Sum by factor cross : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
427 res <- as.array(apply(nb_tmp2, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
428 which(is.element(names(dimnames(nb_tmp)), factors)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
429 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
430 ifelse(all(is.na(x)), NA, sd(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
431 })) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
432 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
433 "densMax" = { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
434 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
435 ## Sum by factor cross / rotation : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
436 dens_tmp2 <- apply(dens_tmp, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
437 which(is.element(names(dimnames(dens_tmp)), c(factors, "rotation"))), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
438 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
439 ifelse(all(is.na(x)), NA, sum(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
440 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
441 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
442 ## Sum by factor cross : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
443 res <- as.array(apply(dens_tmp2, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
444 which(is.element(names(dimnames(dens_tmp)), factors)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
445 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
446 ifelse(all(is.na(x)), NA, max(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
447 })) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
448 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
449 "densSD" = { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
450 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
451 ## Sum by factor cross / rotation : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
452 dens_tmp2 <- apply(dens_tmp, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
453 which(is.element(names(dimnames(dens_tmp)), c(factors, "rotation"))), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
454 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
455 ifelse(all(is.na(x)), NA, sum(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
456 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
457 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
458 ## Sum by factor cross : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
459 res <- as.array(apply(dens_tmp2, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
460 which(is.element(names(dimnames(dens_tmp)), factors)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
461 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
462 ifelse(all(is.na(x)), NA, sd(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
463 })) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
464 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
465 "%.nesting" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
466 res <- tapply(seq_len(nrow(d_ata)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
467 as.list(d_ata[, factors, drop = FALSE]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
468 function(ii) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
469 ifelse(all(is.na(d_ata[ii, metric])), | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
470 NA, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
471 weighted.mean(d_ata[ii, metric], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
472 d_ata[ii, "readable.tracks"], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
473 na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
474 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
475 }, | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
476 stop("Not implemented!") | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
477 ) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
478 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
479 ## dimension names | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
480 names(dimnames(res)) <- c(factors) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
481 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
482 ## Transformation to long format : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
483 reslong <- as.data.frame(as.table(res), responseName = metric) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
484 reslong <- reslong[, c(tail(colnames(reslong), 1), head(colnames(reslong), -1))] # metric first | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
485 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
486 return(reslong) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
487 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
488 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
489 ######################################### end of the function agregation_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
490 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
491 ######################################### start of the function agregations_generic_f called y calc_biodiv_f in FucntExeCalcCommIndexesGalaxy.r | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
492 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
493 agregations_generic_f <- function(d_ata, metrics, factors, list_fact = NULL, unit_sp_sz = NULL, unit_sp = NULL, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
494 nb_name = "number") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
495 ## Purpose: Aggregate data | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
496 ## ---------------------------------------------------------------------- | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
497 ## Arguments: d_ata : data set | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
498 ## metrics : aggregated metric | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
499 ## factors : aggregation factors | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
500 ## list_fact : other factors to aggregate and add to output | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
501 ## unit_sp_sz : Metrics table by unitobs/species/Size Class | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
502 ## unit_sp : Metrics table by unitobs/species | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
503 ## nb_name : abundance colname | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
504 ## | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
505 ## Output : aggregated data frame | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
506 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
507 ## Author: Yves Reecht, Date: 18 oct. 2010, 15:47 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
508 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
509 ## trt depending on metric type : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
510 cas_metric <- c("number" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
511 "mean.length" = "w.mean", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
512 "taille_moy" = "w.mean", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
513 "biomass" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
514 "Biomass" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
515 "weight" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
516 "mean.weight" = "w.mean", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
517 "density" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
518 "Density" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
519 "CPUE" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
520 "CPUE.biomass" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
521 "presence_absence" = "pres", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
522 "abundance.prop.SC" = "w.mean.prop", # Not OK [!!!] ? | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
523 "biomass.prop.SC" = "w.mean.prop.bio", # Not OK [!!!] ? | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
524 ## Benthos : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
525 "colonies" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
526 "coverage" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
527 "mean.size.colonies" = "w.mean.colonies", | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
528 ## SVR (expérimental) : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
529 "number.max" = "nbMax", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
530 "number.sd" = "nbSD", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
531 "density.max" = "densMax", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
532 "density.sd" = "densSD", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
533 "biomass.max" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
534 "spawning.success" = "%.nesting", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
535 "spawnings" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
536 "readable.tracks" = "sum", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
537 "tracks.number" = "sum") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
538 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
539 ## add "readable.tracks" for egg laying percentage : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
540 if (any(cas_metric[metrics] == "%.nesting")) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
541 if (is.element("size.class", colnames(d_ata))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
542 if (is.null(unit_sp_sz)) stop("unit_sp_sz doit être défini") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
543 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
544 d_ata <- merge(d_ata, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
545 unit_sp_sz[, c("species.code", "observation.unit", "size.class", "readable.tracks")], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
546 by = c("species.code", "observation.unit", "size.class"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
547 suffixes = c("", ".y")) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
548 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
549 if (is.null(unit_sp)) stop("unit_sp must be defined") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
550 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
551 d_ata <- merge(d_ata, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
552 unit_sp[, c("species.code", "observation.unit", "readable.tracks")], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
553 by = c("species.code", "observation.unit"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
554 suffixes = c("", ".y")) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
555 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
556 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
557 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
558 ## Add "number" field for computing ponderate means if absent : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
559 if (any(cas_metric[metrics] == "w.mean" | cas_metric[metrics] == "w.mean.prop")) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
560 if (is.element("size.class", colnames(d_ata))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
561 if (is.null(unit_sp_sz)) stop("unit_sp_sz must be defined") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
562 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
563 d_ata <- merge(d_ata, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
564 unit_sp_sz[, c("species.code", "observation.unit", "size.class", nb_name)], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
565 by = c("species.code", "observation.unit", "size.class"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
566 suffixes = c("", ".y")) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
567 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
568 ## add tot abundance / species / observation unit : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
569 nb_tot <- tapply(unit_sp_sz[, nb_name], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
570 as.list(unit_sp_sz[, c("species.code", "observation.unit")]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
571 sum, na.rm = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
572 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
573 d_ata <- merge(d_ata, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
574 as.data.frame(as.table(nb_tot), responseName = "nombre.tot")) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
575 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
576 if (is.null(unit_sp)) stop("unit_sp must be defined") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
577 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
578 d_ata <- merge(d_ata, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
579 unit_sp[, c("species.code", "observation.unit", nb_name)], # [!!!] unit_sp_sz ? | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
580 by = c("species.code", "observation.unit"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
581 suffixes = c("", ".y")) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
582 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
583 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
584 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
585 ## Add biomass field of biomass proportion by size class : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
586 if (any(cas_metric[metrics] == "w.mean.prop.bio")) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
587 if (is.null(unit_sp_sz)) stop("unit_sp_sz doit être défini") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
588 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
589 d_ata <- merge(d_ata, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
590 unit_sp_sz[, c("species.code", "observation.unit", "size.class", "biomass")], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
591 by = c("species.code", "observation.unit", "size.class"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
592 suffixes = c("", ".y")) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
593 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
594 ## add tot biomass / species / observation unit : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
595 biom_tot <- tapply(unit_sp_sz$biomass, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
596 as.list(unit_sp_sz[, c("species.code", "observation.unit")]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
597 function(x) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
598 ifelse(all(is.na(x)), | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
599 NA, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
600 sum(x, na.rm = TRUE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
601 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
602 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
603 d_ata <- merge(d_ata, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
604 as.data.frame(as.table(biom_tot), responseName = "tot.biomass")) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
605 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
606 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
607 ## add colony field for ponderate means pondérées if absent : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
608 if (any(cas_metric[metrics] == "w.mean.colonies" & ! is.element("colonies", colnames(d_ata)))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
609 d_ata$colonies <- unit_sp[match(apply(d_ata[, c("species.code", "observation.unit")], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
610 1, paste, collapse = "*"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
611 apply(unit_sp[, c("species.code", "observation.unit")], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
612 1, paste, collapse = "*")), "colonies"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
613 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
614 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
615 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
616 ## Aggregation of metric depending on factors : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
617 reslong <- bettercbind(df_list = lapply(metrics, # sapply used to have names | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
618 agregation_f, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
619 d_ata = d_ata, factors = factors, cas_metric = cas_metric, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
620 nb_name = nb_name)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
621 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
622 ## Aggregation and add other factors : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
623 if (! (is.null(list_fact) || length(list_fact) == 0)) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
624 reslong <- cbind(reslong, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
625 sapply(d_ata[, list_fact, drop = FALSE], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
626 function(fact) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
627 tapply(fact, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
628 as.list(d_ata[, factors, drop = FALSE]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
629 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
630 if (length(x) > 1 && length(unique(x)) > 1) { # must be one modality | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
631 return(NULL) # otherwise it is NULL | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
632 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
633 unique(as.character(x)) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
634 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
635 }) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
636 })) | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
637 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
638 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
639 ## If some factors aren't at the right class : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
640 if (any(tmp <- sapply(reslong[, list_fact, drop = FALSE], class) != sapply(d_ata[, list_fact, drop = FALSE], class))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
641 for (i in which(tmp)) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
642 switch(sapply(d_ata[, list_fact, drop = FALSE], class)[i], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
643 "integer" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
644 reslong[, list_fact[i]] <- as.integer(as.character(reslong[, list_fact[i]])) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
645 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
646 "numeric" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
647 reslong[, list_fact[i]] <- as.numeric(as.character(reslong[, list_fact[i]])) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
648 }, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
649 reslong[, list_fact[i]] <- eval(call(paste("as", sapply(d_ata[, list_fact, drop = FALSE], class)[i], sep = "."), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
650 reslong[, list_fact[i]])) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
651 ) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
652 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
653 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
654 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
655 ## Initial order of factors levels : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
656 reslong <- as.data.frame(sapply(colnames(reslong), | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
657 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
658 if (is.factor(reslong[, x])) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
659 return(factor(reslong[, x], levels = levels(d_ata[, x]))) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
660 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
661 return(reslong[, x]) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
662 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
663 }, simplify = FALSE)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
664 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
665 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
666 ## Check of other aggregated factors supplémentaires. There must be no NULL elements : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
667 if (any(sapply(reslong[, list_fact], function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
668 any(is.null(unlist(x))) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
669 }))) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
670 warning(paste("One of the suppl. factors is probably a subset", | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
671 " of the observations grouping factor(s).", sep = "")) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
672 return(NULL) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
673 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
674 return(reslong) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
675 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
676 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
677 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
678 ######################################### end of the function agregations_generic_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
679 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
680 ######################################### start of the function drop_levels_f called y calc_biodiv_f in FucntExeCalcCommIndexesGalaxy.r and glm_community in FunctExeCalcGLMGalaxy.r | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
681 drop_levels_f <- function(df, which = NULL) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
682 ## Purpose: Suppress unused levels of factors | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
683 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
684 ## Arguments: df : a data.frame | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
685 ## which : included columns index (all by default) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
686 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
687 ## Author: Yves Reecht, Date: 10 août 2010, 13:29 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
688 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
689 if (class(df) != "data.frame") { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
690 stop("'df' must be a data.frame") | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
691 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
692 if (is.null(which)) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
693 x <- as.data.frame(sapply(df, function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
694 return(x[, drop = TRUE]) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
695 }, simplify = FALSE), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
696 stringsAsFactors = FALSE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
697 }else{ # Only some columns used | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
698 x <- df | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
699 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
700 x[, which] <- as.data.frame(sapply(df[, which, drop = FALSE], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
701 function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
702 return(x[, drop = TRUE]) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
703 }, simplify = FALSE), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
704 stringsAsFactors = FALSE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
705 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
706 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
707 return(x) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
708 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
709 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
710 ######################################### end of the function drop_levels_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
711 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
712 ######################################### start of the function subset_all_tables_f called by glm_community in FunctExeCalcGLMGalaxy.r | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
713 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
714 subset_all_tables_f <- function(metrique, tab_metrics, facteurs, selections, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
715 tab_unitobs, refesp, tab_metrique = "", nb_name = "number", obs_type = "", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
716 exclude = NULL, add = c("species.code", "observation.unit")) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
717 ## Purpose: Extract useful data only from chosen metrics and factors | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
718 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
719 ## Arguments: metrique : chosen metric | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
720 ## facteurs : all chosen factors | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
721 ## selections : corresponding modality selected | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
722 ## tab_metrique : metrics table name | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
723 ## exclude : factors levels to exclude | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
724 ## add : field to add to data table | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
725 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
726 ## Author: Yves Reecht, Date: 6 août 2010, 16:46 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
727 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
728 ## If no metrics table available : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
729 if (is.element(tab_metrique, c("", "TableOccurrences", "TablePresAbs"))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
730 tab_metrique <- "unit_sp" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
731 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
732 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
733 cas_tables <- c("unit_sp" = "unit_sp", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
734 "TablePresAbs" = "unit_sp", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
735 "unit_sp_sz" = "unit_sp_sz") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
736 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
737 ## Recuperation of metrics table : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
738 data_metric <- tab_metrics | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
739 unitobs <- tab_unitobs | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
740 refesp <- refesp | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
741 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
742 ## If no metrics available or already computed : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
743 if (is.element(metrique, c("", "occurrence.frequency"))) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
744 metrique <- "tmp" | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
745 data_metric$tmp <- 0 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
746 data_metric$tmp[data_metric[, nb_name] > 0] <- 1 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
747 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
748 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
749 if (!is.null(add)) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
750 metriques <- c(metrique, add[is.element(add, colnames(data_metric))]) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
751 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
752 metriques <- metrique | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
753 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
754 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
755 ## Subset depending on metrics table | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
756 switch(cas_tables[tab_metrique], | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
757 ## Observation table by unitobs and species : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
758 unit_sp = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
759 restmp <- cbind(data_metric[!is.na(data_metric[, metrique]), metriques, drop = FALSE], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
760 unitobs[match(data_metric$observation.unit[!is.na(data_metric[, metrique])], | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
761 unitobs$observation.unit), # ajout des colonnes sélectionnées d'unitobs | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
762 facteurs[is.element(facteurs, colnames(unitobs))], drop = FALSE], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
763 refesp[match(data_metric$species.code[!is.na(data_metric[, metrique])], | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
764 refesp$species.code), # ajout des colonnes sélectionnées d'especes | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
765 facteurs[is.element(facteurs, colnames(refesp))], drop = FALSE]) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
766 }, | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
767 ## Observation table by unitobs, species and size class : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
768 unit_sp_sz = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
769 restmp <- cbind(data_metric[!is.na(data_metric[, metrique]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
770 c(metriques, "size.class"), drop = FALSE], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
771 unitobs[match(data_metric$observation.unit[!is.na(data_metric[, metrique])], | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
772 unitobs$observation.unit), # ajout des colonnes sélectionnées d'unitobs | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
773 facteurs[is.element(facteurs, colnames(unitobs))], drop = FALSE], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
774 refesp[match(data_metric$species.code[!is.na(data_metric[, metrique])], | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
775 refesp$species.code), # ajout des colonnes sélectionnées d'especes | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
776 facteurs[is.element(facteurs, colnames(refesp))], drop = FALSE]) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
777 }, | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
778 ## Other cases : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
779 restmp <- cbind(data_metric[!is.na(data_metric[, metrique]), metriques, drop = FALSE], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
780 unitobs[match(data_metric$observation.unit[!is.na(data_metric[, metrique])], | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
781 unitobs$observation.unit), # ajout des colonnes sélectionnées d'unitobs. | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
782 facteurs[is.element(facteurs, colnames(unitobs))], drop = FALSE]) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
783 ) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
784 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
785 sel_col <- which(!is.na(selections)) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
786 if (!is.null(exclude)) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
787 sel_col <- sel_col[sel_col != exclude] | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
788 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
789 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
790 ## Particular case of size classes : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
791 if (is.element("size.class", colnames(restmp))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
792 if (length(grep("^[[:digit:]]*[-_][[:digit:]]*$", unique(as.character(restmp$size.class)), perl = TRUE)) == | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
793 length(unique(as.character(restmp$size.class)))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
794 restmp[, "size.class"] <- | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
795 factor(as.character(restmp$size.class), | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
796 levels = unique(as.character(restmp$size.class))[ | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
797 order(as.numeric(sub("^([[:digit:]]*)[-_][[:digit:]]*$", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
798 "\\1", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
799 unique(as.character(restmp$size.class)), | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
800 perl = TRUE)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
801 na.last = FALSE)]) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
802 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
803 restmp[, "size.class"] <- factor(restmp$size.class) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
804 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
805 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
806 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
807 ## Biomass and density conversion -> /100m² : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
808 if (any(is.element(colnames(restmp), c("biomass", "density", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
809 "biomass.max", "density.max", | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
810 "biomass.sd", "density.sd"))) && obs_type != "fishing") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
811 restmp[, is.element(colnames(restmp), | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
812 c("biomass", "density", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
813 "biomass.max", "density.max", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
814 "biomass.sd", "density.sd"))] <- 100 * | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
815 restmp[, is.element(colnames(restmp), | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
816 c("biomass", "density", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
817 "biomass.max", "density.max", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
818 "biomass.sd", "density.sd"))] | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
819 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
820 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
821 return(restmp) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
822 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
823 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
824 ######################################### end of the function subset_all_tables_f | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
825 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
826 ######################################### start of the function organise_fact called by modeleLineaireWP2.xxx.f in FunctExeCalcGLMxxGalaxy.r | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
827 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
828 organise_fact <- function(list_rand, list_fact) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
829 ## Purpose: organise response factors | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
830 ## ---------------------------------------------------------------------- | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
831 ## Arguments: list_rand : Analysis random factors list | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
832 ## list_fact : Analysis factors list | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
833 ## ---------------------------------------------------------------------- | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
834 ## Author: Coline ROYAUX 14 november 2020 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
835 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
836 if (list_rand[1] != "None") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
837 if (all(is.element(list_fact, list_rand)) || list_fact[1] == "None") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
838 resp_fact <- paste("(1|", paste(list_rand, collapse = ") + (1|"), ")") | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
839 list_f <- NULL | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
840 list_fact <- list_rand | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
841 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
842 list_f <- list_fact[!is.element(list_fact, list_rand)] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
843 resp_fact <- paste(paste(list_f, collapse = " + "), " + (1|", paste(list_rand, collapse = ") + (1|"), ")") | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
844 list_fact <- c(list_f, list_rand) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
845 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
846 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
847 list_f <- list_fact | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
848 resp_fact <- paste(list_fact, collapse = " + ") | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
849 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
850 return(list(resp_fact, list_f, list_fact)) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
851 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
852 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
853 ######################################### end of the function organise_fact | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
854 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
855 ######################################### start of the function organise_fact called by modeleLineaireWP2.xxx.f in FunctExeCalcGLMxxGalaxy.r | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
856 distrib_choice <- function(distrib = distrib, metrique = metrique, data = tmpd_ata) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
857 ## Purpose: choose the right distribution | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
858 ## ---------------------------------------------------------------------- | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
859 ## Arguments: data : data used for analysis | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
860 ## metrique : Chosen metric | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
861 ## distrib : distribution law selected by user | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
862 ## ---------------------------------------------------------------------- | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
863 ## Author: Coline ROYAUX 14 november 2020 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
864 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
865 if (distrib == "None") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
866 if (metrique == "presence_absence") { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
867 chose_distrib <- "binomial" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
868 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
869 switch(class(data[, metrique]), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
870 "integer" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
871 chose_distrib <- "poisson" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
872 }, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
873 "numeric" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
874 chose_distrib <- "gaussian" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
875 }, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
876 stop("Selected metric class doesn't fit, you should select an integer or a numeric variable")) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
877 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
878 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
879 chose_distrib <- distrib | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
880 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
881 return(chose_distrib) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
882 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
883 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
884 ######################################### end of the function organise_fact | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
885 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
886 ######################################### start of the function create_res_table called by modeleLineaireWP2.xxx.f in FunctExeCalcGLMxxGalaxy.r | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
887 create_res_table <- function(list_rand, list_fact, row, lev, distrib) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
888 ## Purpose: create results table | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
889 ## ---------------------------------------------------------------------- | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
890 ## Arguments: list_rand : Analysis random factors list | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
891 ## list_fact : Analysis factors list | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
892 ## row : rows of results table = species or separation factor | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
893 ## lev : Levels of analysis factors list | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
894 ## distrib : distribution law | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
895 ## ---------------------------------------------------------------------- | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
896 ## Author: Coline ROYAUX 04 october 2020 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
897 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
898 if (list_rand[1] != "None") { ## if random effects | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
899 tab_sum <- data.frame(analysis = row, Interest.var = NA, distribution = NA, AIC = NA, BIC = NA, logLik = NA, deviance = NA, df.resid = NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
900 colrand <- unlist(lapply(list_rand, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
901 FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
902 lapply(c("Std.Dev", "NbObservation", "NbLevels"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
903 FUN = function(y) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
904 paste(x, y, collapse = ":") | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
905 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
906 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
907 tab_sum[, colrand] <- NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
908 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
909 if (! is.null(lev)) { ## if fixed effects + random effects | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
910 colcoef <- unlist(lapply(c("(Intercept)", lev), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
911 FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
912 lapply(c("Estimate", "Std.Err", "Zvalue", "Pvalue", "IC_up", "IC_inf", "signif"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
913 FUN = function(y) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
914 paste(x, y, collapse = ":") | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
915 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
916 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
917 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
918 }else{ ## if no fixed effects | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
919 colcoef <- NULL | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
920 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
921 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
922 }else{ ## if no random effects | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
923 tab_sum <- data.frame(analysis = row, Interest.var = NA, distribution = NA, AIC = NA, Resid.deviance = NA, df.resid = NA, Null.deviance = NA, df.null = NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
924 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
925 switch(distrib, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
926 "gaussian" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
927 colcoef <- unlist(lapply(c("(Intercept)", lev), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
928 FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
929 lapply(c("Estimate", "Std.Err", "Tvalue", "Pvalue", "IC_up", "IC_inf", "signif"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
930 FUN = function(y) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
931 paste(x, y, collapse = ":") | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
932 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
933 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
934 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
935 }, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
936 "quasipoisson" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
937 colcoef <- unlist(lapply(c("(Intercept)", lev), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
938 FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
939 lapply(c("Estimate", "Std.Err", "Tvalue", "Pvalue", "IC_up", "IC_inf", "signif"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
940 FUN = function(y) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
941 paste(x, y, collapse = ":") | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
942 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
943 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
944 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
945 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
946 , { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
947 colcoef <- unlist(lapply(c("(Intercept)", lev), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
948 FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
949 lapply(c("Estimate", "Std.Err", "Zvalue", "Pvalue", "IC_up", "IC_inf", "signif"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
950 FUN = function(y) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
951 paste(x, y, collapse = ":") | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
952 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
953 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
954 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
955 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
956 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
957 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
958 tab_sum[, colcoef] <- NA | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
959 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
960 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
961 return(tab_sum) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
962 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
963 ######################################### end of the function create_res_table | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
964 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
965 ######################################### start of the function sorties_lm_f called by glm_community in FunctExeCalcGLMGalaxy.r | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
966 sorties_lm_f <- function(obj_lm, obj_lmy, tab_sum, #formule, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
967 metrique, fact_ana, cut, col_ana, list_fact, list_rand, lev = NULL, d_ata, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
968 log = FALSE, sufixe = NULL) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
969 ## Purpose: Form GLM and LM results | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
970 ## ---------------------------------------------------------------------- | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
971 ## Arguments: obj_lm : lm object | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
972 ## obj_lmy : lm object with year as continuous | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
973 ## tab_sum : output summary table | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
974 ## formule : LM formula | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
975 ## metrique : Chosen metric | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
976 ## fact_ana : separation factor | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
977 ## cut : level of separation factor | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
978 ## col_ana : colname for separation factor in output summary table | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
979 ## list_fact : Analysis factors list | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
980 ## list_rand : Analysis random factors list | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
981 ## levels : Levels of analysis factors list | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
982 ## d_ata : d_ata used for analysis | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
983 ## log : put log on metric ? (boolean) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
984 ## sufixe : sufix for file name | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
985 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
986 ## Author: Yves Reecht, Date: 25 août 2010, 16:19 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
987 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
988 tab_sum[, "Interest.var"] <- as.character(metrique) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
989 sum_lm <- summary(obj_lm) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
990 tab_sum[, "distribution"] <- as.character(sum_lm$family[1]) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
991 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
992 if (length(grep("^glmmTMB", obj_lm$call)) > 0) { #if random effects | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
993 tab_sum[tab_sum[, col_ana] == cut, "AIC"] <- sum_lm$AICtab[1] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
994 tab_sum[tab_sum[, col_ana] == cut, "BIC"] <- sum_lm$AICtab[2] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
995 tab_sum[tab_sum[, col_ana] == cut, "logLik"] <- sum_lm$AICtab[3] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
996 tab_sum[tab_sum[, col_ana] == cut, "deviance"] <- sum_lm$AICtab[4] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
997 tab_sum[tab_sum[, col_ana] == cut, "df.resid"] <- sum_lm$AICtab[5] | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
998 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
999 if (! is.null(lev)) { ## if fixed effects + random effects | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1000 tab_coef <- as.data.frame(sum_lm$coefficients$cond) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1001 tab_coef$signif <- lapply(tab_coef[, "Pr(>|z|)"], FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1002 if (!is.na(x) && x < 0.05) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1003 "yes" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1004 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1005 "no" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1006 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1007 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1008 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1009 tab_sum[tab_sum[, col_ana] == cut, grepl("Intercept.*Zvalue", colnames(tab_sum))] <- tab_coef[grepl("Intercept", rownames(tab_coef)), "z value"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1010 tab_sum[tab_sum[, col_ana] == cut, grepl("Intercept.*Pvalue", colnames(tab_sum))] <- tab_coef[grepl("Intercept", rownames(tab_coef)), "Pr(>|z|)"] | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1011 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1012 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "Zvalue", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1013 if (length(grep(x, rownames(tab_coef))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1014 tab_coef[grepl(x, rownames(tab_coef)), "z value"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1015 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1016 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1017 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1018 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1019 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "Pvalue", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1020 if (length(grep(x, rownames(tab_coef))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1021 tab_coef[grepl(x, rownames(tab_coef)), "Pr(>|z|)"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1022 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1023 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1024 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1025 })) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1026 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1027 if (any(obj_lmy != "")) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1028 sum_lmy <- summary(obj_lmy) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1029 tab_coefy <- as.data.frame(sum_lmy$coefficients$cond) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1030 tab_coefy$signif <- lapply(tab_coefy[, "Pr(>|z|)"], FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1031 if (!is.na(x) && x < 0.05) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1032 "yes" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1033 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1034 "no" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1035 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1036 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1037 tab_sum[tab_sum[, col_ana] == cut, "year Zvalue"] <- ifelse(length(tab_coefy["year", "z value"]) > 0, tab_coefy["year", "z value"], NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1038 tab_sum[tab_sum[, col_ana] == cut, "year Pvalue"] <- ifelse(length(tab_coefy["year", "Pr(>|z|)"]) > 0, tab_coefy["year", "Pr(>|z|)"], NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1039 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1040 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1041 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1042 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1043 switch(as.character(length(sum_lm$varcor$cond)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1044 "1" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1045 std_d <- c(sum_lm$varcor$cond[[1]]) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1046 }, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1047 "2" = { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1048 std_d <- c(sum_lm$varcor$cond[[1]], sum_lm$varcor$cond[[2]]) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1049 }, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1050 std_d <- NULL) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1051 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1052 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(list_rand, "Std.Dev", collapse = "|"), colnames(tab_sum))] <- std_d | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1053 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(list_rand, "NbObservation", collapse = "|"), colnames(tab_sum))] <- sum_lm$nobs | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1054 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(list_rand, "NbLevels", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(list_rand, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1055 nlevels(d_ata[, x]) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1056 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1057 | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1058 }else{ ## if fixed effects only | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1059 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1060 tab_sum[tab_sum[, col_ana] == cut, "AIC"] <- sum_lm$aic | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1061 tab_sum[tab_sum[, col_ana] == cut, "Resid.deviance"] <- sum_lm$deviance | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1062 tab_sum[tab_sum[, col_ana] == cut, "df.resid"] <- sum_lm$df.residual | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1063 tab_sum[tab_sum[, col_ana] == cut, "Null.deviance"] <- sum_lm$null.deviance | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1064 tab_sum[tab_sum[, col_ana] == cut, "df.null"] <- sum_lm$df.null | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1065 tab_coef <- as.data.frame(sum_lm$coefficients) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1066 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1067 if (any(obj_lmy != "")) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1068 sum_lmy <- summary(obj_lmy) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1069 tab_coefy <- as.data.frame(sum_lmy$coefficients) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1070 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1071 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1072 if (sum_lm$family[1] == "gaussian" || sum_lm$family[1] == "quasipoisson") { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1073 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1074 tab_coef$signif <- lapply(tab_coef[, "Pr(>|t|)"], FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1075 if (!is.na(x) && x < 0.05) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1076 "yes" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1077 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1078 "no" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1079 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1080 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1081 tab_sum[tab_sum[, col_ana] == cut, grepl("Intercept.*Tvalue", colnames(tab_sum))] <- tab_coef[grepl("Intercept", rownames(tab_coef)), "t value"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1082 tab_sum[tab_sum[, col_ana] == cut, grepl("Intercept.*Pvalue", colnames(tab_sum))] <- tab_coef[grepl("Intercept", rownames(tab_coef)), "Pr(>|t|)"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1083 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1084 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "Tvalue", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1085 if (length(grep(x, rownames(tab_coef))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1086 tab_coef[grepl(x, rownames(tab_coef)), "t value"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1087 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1088 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1089 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1090 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1091 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1092 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "Pvalue", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1093 if (length(grep(x, rownames(tab_coef))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1094 tab_coef[grepl(x, rownames(tab_coef)), "Pr(>|t|)"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1095 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1096 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1097 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1098 })) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1099 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1100 if (any(obj_lmy != "")) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1101 tab_coefy$signif <- lapply(tab_coefy[, "Pr(>|t|)"], FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1102 if (!is.na(x) && x < 0.05) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1103 "yes" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1104 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1105 "no" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1106 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1107 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1108 tab_sum[tab_sum[, col_ana] == cut, "year Tvalue"] <- ifelse(length(tab_coefy["year", "t value"]) > 0, tab_coefy["year", "t value"], NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1109 tab_sum[tab_sum[, col_ana] == cut, "year Pvalue"] <- ifelse(length(tab_coefy["year", "Pr(>|z|)"]) > 0, tab_coefy["year", "Pr(>|t|)"], NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1110 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1111 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1112 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1113 tab_coef$signif <- lapply(tab_coef[, "Pr(>|z|)"], FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1114 if (!is.na(x) && x < 0.05) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1115 "yes" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1116 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1117 "no" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1118 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1119 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1120 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1121 tab_sum[tab_sum[, col_ana] == cut, grepl("Intercept.*Zvalue", colnames(tab_sum))] <- tab_coef[grepl("Intercept", rownames(tab_coef)), "z value"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1122 tab_sum[tab_sum[, col_ana] == cut, grepl("Intercept.*Pvalue", colnames(tab_sum))] <- tab_coef[grepl("Intercept", rownames(tab_coef)), "Pr(>|z|)"] | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1123 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1124 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "Zvalue", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1125 if (length(grep(x, rownames(tab_coef))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1126 tab_coef[grepl(x, rownames(tab_coef)), "z value"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1127 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1128 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1129 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1130 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1131 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "Pvalue", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1132 if (length(grep(x, rownames(tab_coef))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1133 tab_coef[grepl(x, rownames(tab_coef)), "Pr(>|z|)"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1134 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1135 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1136 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1137 })) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1138 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1139 if (any(obj_lmy != "")) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1140 tab_coefy$signif <- lapply(tab_coefy[, "Pr(>|z|)"], FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1141 if (!is.na(x) && x < 0.05) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1142 "yes" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1143 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1144 "no" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1145 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1146 }) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1147 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1148 tab_sum[tab_sum[, col_ana] == cut, "year Zvalue"] <- ifelse(length(tab_coefy["year", "z value"]) > 0, tab_coefy["year", "z value"], NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1149 tab_sum[tab_sum[, col_ana] == cut, "year Pvalue"] <- ifelse(length(tab_coefy["year", "Pr(>|z|)"]) > 0, tab_coefy["year", "Pr(>|z|)"], NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1150 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1151 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1152 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1153 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1154 if (! is.null(lev)) { ## if fixed effects | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1155 tab_sum[tab_sum[, col_ana] == cut, grepl("Intercept.*Estimate", colnames(tab_sum))] <- tab_coef[grepl("Intercept", rownames(tab_coef)), "Estimate"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1156 tab_sum[tab_sum[, col_ana] == cut, grepl("Intercept.*Std.Err", colnames(tab_sum))] <- tab_coef[grepl("Intercept", rownames(tab_coef)), "Std. Error"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1157 tab_sum[tab_sum[, col_ana] == cut, grepl("Intercept.*signif", colnames(tab_sum))] <- tab_coef[grepl("Intercept", rownames(tab_coef)), "signif"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1158 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1159 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "Estimate", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1160 if (length(grep(x, rownames(tab_coef))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1161 tab_coef[grepl(x, rownames(tab_coef)), "Estimate"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1162 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1163 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1164 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1165 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1166 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "Std.Err", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1167 if (length(grep(x, rownames(tab_coef))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1168 tab_coef[grepl(x, rownames(tab_coef)), "Std. Error"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1169 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1170 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1171 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1172 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1173 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "signif", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1174 if (length(grep(x, rownames(tab_coef))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1175 tab_coef[grepl(x, rownames(tab_coef)), "signif"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1176 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1177 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1178 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1179 })) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1180 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1181 if (any(obj_lmy != "")) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1182 tab_sum[tab_sum[, col_ana] == cut, "year Estimate"] <- ifelse(length(tab_coefy["year", "Estimate"]) > 0, tab_coefy["year", "Estimate"], NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1183 tab_sum[tab_sum[, col_ana] == cut, "year Std.Err"] <- ifelse(length(tab_coefy["year", "Std. Error"]) > 0, tab_coefy["year", "Std. Error"], NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1184 tab_sum[tab_sum[, col_ana] == cut, "year signif"] <- ifelse(length(tab_coefy["year", "signif"]) > 0, tab_coefy["year", "signif"], NA) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1185 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1186 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1187 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1188 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1189 ic <- tryCatch(as.data.frame(confint(obj_lm)), error = function(e) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1190 }) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1191 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1192 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "IC_up", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1193 if (length(grep(x, rownames(ic))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1194 ic[grepl(x, rownames(ic)), "97.5 %"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1195 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1196 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1197 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1198 })) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1199 tab_sum[tab_sum[, col_ana] == cut, grepl(paste(lev, "IC_inf", collapse = "|"), colnames(tab_sum))] <- unlist(lapply(lev, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1200 if (length(grep(x, rownames(ic))) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1201 ic[grepl(x, rownames(ic)), "2.5 %"] | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1202 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1203 NA | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1204 } | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1205 })) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1206 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1207 return(tab_sum) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1208 | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1209 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1210 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1211 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1212 ######################################### end of the function sorties_lm_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1213 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1214 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1215 ######################################### start of the function note_glm_f called by glm_species and glm_community | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1216 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1217 note_glm_f <- function(data, obj_lm, metric, list_fact, details = FALSE) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1218 ## Purpose: Note your GLM analysis | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1219 ## ---------------------------------------------------------------------- | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1220 ## Arguments: data : d_ataframe used for analysis | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1221 ## obj_lm : GLM assessed | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1222 ## metric : selected metric | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1223 ## list_fact : Analysis factors list | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1224 ## details : detailed output ? | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1225 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1226 ## Author: Coline ROYAUX, 26 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1227 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1228 rate <- 0 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1229 detres <- list(complete_plan = NA, balanced_plan = NA, NA_proportion_OK = NA, no_residual_dispersion = NA, uniform_residuals = NA, outliers_proportion_OK = NA, no_zero_inflation = NA, observation_factor_ratio_OK = NA, enough_levels_random_effect = NA, rate = NA) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1230 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1231 #### d_ata criterions #### | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1232 | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1233 ## Plan | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1234 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1235 plan <- as.data.frame(table(data[, list_fact])) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1236 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1237 if (nrow(plan[plan$Freq == 0, ]) < nrow(plan) * 0.1) { # +0.5 if less than 10% of possible factor's level combinations aren't represented in the sampling scheme | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1238 rate <- rate + 0.5 | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1239 detres$complete_plan <- TRUE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1240 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1241 if (summary(as.factor(plan$Freq))[1] > nrow(plan) * 0.9) { # +0.5 if the frequency of the most represented frequency of possible factor's levels combinations is superior to 90% of the total number of possible factor's levels combinations | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1242 rate <- rate + 0.5 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1243 detres$balanced_plan <- TRUE | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1244 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1245 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1246 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1247 detres$complete_plan <- FALSE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1248 detres$balanced_plan <- FALSE | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1249 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1250 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1251 if (nrow(data) - nrow(na.omit(data)) < nrow(data) * 0.1) { # +1 if less than 10% of the lines in the dataframe bares a NA | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1252 rate <- rate + 1 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1253 detres["NA_proportion_OK"] <- TRUE | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1254 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1255 detres["NA_proportion_OK"] <- FALSE | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1256 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1257 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1258 #### Model criterions #### | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1259 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1260 if (length(grep("quasi", obj_lm$family)) == 0) { #DHARMa doesn't work with quasi distributions | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1261 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1262 residuals <- DHARMa::simulateResiduals(obj_lm) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1263 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1264 capture.output(test_res <- DHARMa::testResiduals(residuals)) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1265 test_zero <- DHARMa::testZeroInflation(residuals) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1266 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1267 ## dispersion of residuals | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1268 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1269 if (test_res$dispersion$p.value > 0.05) { # +1.5 if dispersion tests not significative | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1270 rate <- rate + 1.5 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1271 detres$no_residual_dispersion <- TRUE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1272 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1273 detres$no_residual_dispersion <- FALSE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1274 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1275 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1276 ## uniformity of residuals | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1277 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1278 if (test_res$uniformity$p.value > 0.05) { # +1 if uniformity tests not significative | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1279 rate <- rate + 1 | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1280 detres$uniform_residuals <- TRUE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1281 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1282 detres$uniform_residuals <- FALSE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1283 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1284 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1285 ## residuals outliers | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1286 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1287 if (test_res$outliers$p.value > 0.05) { # +0.5 if outliers tests not significative | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1288 rate <- rate + 0.5 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1289 detres["outliers_proportion_OK"] <- TRUE | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1290 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1291 detres["outliers_proportion_OK"] <- FALSE | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1292 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1293 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1294 ## Zero inflation test | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1295 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1296 if (test_zero$p.value > 0.05) { # +1 if zero inflation tests not significative | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1297 rate <- rate + 1 | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1298 detres$no_zero_inflation <- TRUE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1299 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1300 detres$no_zero_inflation <- FALSE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1301 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1302 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1303 ## Factors/observations ratio | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1304 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1305 if (length(list_fact) / nrow(na.omit(data)) < 0.1) { # +1 if quantity of factors is less than 10% of the quantity of observations | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1306 rate <- rate + 1 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1307 detres["observation_factor_ratio_OK"] <- TRUE | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1308 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1309 detres["observation_factor_ratio_OK"] <- FALSE | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1310 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1311 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1312 ## less than 10 factors' level on random effect | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1313 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1314 if (length(grep("^glmmTMB", obj_lm$call)) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1315 nlev_rand <- c() | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1316 for (fact in names(summary(obj_lm)$varcor$cond)) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1317 nlev_rand <- c(nlev_rand, length(unlist(unique(data[, fact])))) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1318 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1319 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1320 if (all(nlev_rand > 10)) { # +1 if more than 10 levels in one random effect | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1321 rate <- rate + 1 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1322 detres$enough_levels_random_effect <- TRUE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1323 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1324 detres$enough_levels_random_effect <- FALSE | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1325 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1326 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1327 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1328 detres$rate <- rate | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1329 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1330 if (details) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1331 return(detres) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1332 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1333 return(rate) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1334 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1335 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1336 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1337 return(NA) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1338 cat("Models with quasi distributions can't be rated for now") | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1339 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1340 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1341 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1342 ######################################### end of the function note_glm_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1343 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1344 ######################################### start of the function note_glms_f called by glm_species and glm_community | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1345 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1346 note_glms_f <- function(tab_rate, expr_lm, obj_lm, file_out = FALSE) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1347 ## Purpose: Note your GLM analysis | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1348 ## ---------------------------------------------------------------------- | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1349 ## Arguments: tab_rate : rates table from note_glm_f | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1350 ## expr_lm : GLM expression assessed | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1351 ## obj_lm : GLM object | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1352 ## file_out : Output as file ? else global rate only | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1353 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1354 ## Author: Coline ROYAUX, 26 june 2020 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1355 namefile <- "RatingGLM.txt" | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1356 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1357 if (length(grep("quasi", obj_lm$family)) == 0) { #DHARMa doesn't work with quasi distributions | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1358 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1359 rate_m <- median(na.omit(tab_rate[, "rate"])) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1360 sum <- summary(obj_lm) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1361 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1362 if (length(grep("^glmmTMB", obj_lm$call)) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1363 if (median(na.omit(tab_rate[, "rate"])) >= 6) { # if 50% has a rate superior or equal to 6 +1 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1364 rate_m <- rate_m + 1 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1365 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1366 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1367 if (quantile(na.omit(tab_rate[, "rate"]), probs = 0.9) >= 6) { # if 90% has a rate superior or equal to 6 +1 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1368 rate_m <- rate_m + 1 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1369 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1370 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1371 if (median(na.omit(tab_rate[, "rate"])) >= 5) { # if 50% has a rate superior or equal to 5 +1 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1372 rate_m <- rate_m + 1 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1373 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1374 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1375 if (quantile(na.omit(tab_rate[, "rate"]), probs = 0.9) >= 5) { # if 90% has a rate superior or equal to 5 +1 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1376 rate_m <- rate_m + 1 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1377 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1378 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1379 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1380 if (file_out) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1381 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1382 cat("###########################################################################", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1383 "\n########################### Analysis evaluation ###########################", | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1384 "\n###########################################################################", file = namefile, fill = 1, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1385 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1386 ## Informations on model : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1387 cat("\n\n######################################### \nFitted model:", file = namefile, fill = 1, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1388 cat("\t", deparse(expr_lm), "\n\n", file = namefile, sep = "", append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1389 cat("Family: ", sum$family[[1]], | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1390 file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1391 cat("\n\nNumber of analysis: ", nrow(tab_rate), file = namefile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1392 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1393 ## Global rate : | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1394 cat("\n\n######################################### \nGlobal rate for all analysis:", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1395 "\n\n", rate_m, "out of 10", file = namefile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1396 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1397 ## details on every GLM : | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1398 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1399 cat("\n\n######################################### \nDetails on every analysis:\n\n", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1400 cat("Analysis\tC1\tC2\tC3\tC4\tC5\tC6\tC7\tC8\tC9\tFinal rate", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1401 apply(tab_rate, 1, FUN = function(x) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1402 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1403 if (!is.na(x["complete_plan"]) && x["complete_plan"] == TRUE) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1404 cat("\n", x[1], "\tyes", file = namefile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1405 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1406 cat("\n", x[1], "\tno", file = namefile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1407 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1408 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1409 for (i in c("balanced_plan", "NA_proportion_OK", "no_residual_dispersion", "uniform_residuals", "outliers_proportion_OK", "no_zero_inflation", "observation_factor_ratio_OK", "enough_levels_random_effect")) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1410 if (!is.na(x[i]) && x[i] == TRUE) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1411 cat("\tyes", file = namefile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1412 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1413 cat("\tno", file = namefile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1414 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1415 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1416 | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1417 cat("\t", x["rate"], "/ 8", file = namefile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1418 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1419 | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1420 }) | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1421 cat("\n\nC1: Complete plan?\nC2: Balanced plan?\nC3: Few NA?\nC4: Regular dispersion?\nC5: Uniform residuals?\nC6: Regular outliers proportion?\nC7: No zero-inflation?\nC8: Good observation/factor ratio?\nC9: Enough levels on random effect?", file = namefile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1422 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1423 ## Red flags - advice : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1424 cat("\n\n######################################### \nRed flags - advice:\n\n", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1425 if (all(na.omit(tab_rate["NA_proportion_OK"]) == FALSE)) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1426 cat("\n", "\t- More than 10% of lines of your dataset contains NAs", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1427 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1428 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1429 if (length(grep("FALSE", tab_rate["no_residual_dispersion"])) / length(na.omit(tab_rate["no_residual_dispersion"])) > 0.5) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1430 cat("\n", "\t- More than 50% of your analyses are over- or under- dispersed : Try with another distribution family", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1431 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1432 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1433 if (length(grep("FALSE", tab_rate["uniform_residuals"])) / length(na.omit(tab_rate["uniform_residuals"])) > 0.5) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1434 cat("\n", "\t- More than 50% of your analyses haven't an uniform distribution of residuals : Try with another distribution family", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1435 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1436 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1437 if (length(grep("FALSE", tab_rate["outliers_proportion_OK"])) / length(na.omit(tab_rate["outliers_proportion_OK"])) > 0.5) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1438 cat("\n", "\t- More than 50% of your analyses have too much outliers : Try with another distribution family or try to select or filter your data", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1439 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1440 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1441 if (length(grep("FALSE", tab_rate["no_zero_inflation"])) / length(na.omit(tab_rate["no_zero_inflation"])) > 0.5) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1442 cat("\n", "\t- More than 50% of your analyses have zero inflation : Try to select or filter your data", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1443 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1444 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1445 if (length(grep("FALSE", tab_rate["observation_factor_ratio_OK"])) / length(na.omit(tab_rate["observation_factor_ratio_OK"])) > 0.5) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1446 cat("\n", "\t- More than 50% of your analyses have not enough observations for the amount of factors : Try to use less factors in your analysis or try to use another separation factor", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1447 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1448 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1449 if (any(tab_rate["enough_levels_random_effect"] == FALSE, na.rm = TRUE) && length(grep("^glmmTMB", obj_lm$call)) > 0) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1450 cat("\n", "\t- Random effect hasn't enough levels to be robust : If it has less than ten levels remove the random effect", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1451 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1452 }else{ | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1453 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1454 return(rate_m) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1455 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1456 } | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1457 }else{ | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1458 cat("Models with quasi distributions can't be rated for now", file = namefile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1459 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1460 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1461 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1462 ######################################### end of the function note_glm_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1463 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1464 ######################################### start of the function info_stats_f called by glm_species and glm_community | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1465 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1466 info_stats_f <- function(filename, d_ata, agreg_level = c("species", "unitobs"), type = c("graph", "stat"), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1467 metrique, fact_graph, fact_graph_sel, list_fact, list_fact_sel) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1468 ## Purpose: informations and simple statistics | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1469 ## ---------------------------------------------------------------------- | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1470 ## Arguments: filename : name of file | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1471 ## d_ata : input data | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1472 ## agreg_level : aggregation level | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1473 ## type : type of function calling | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1474 ## metrique : selected metric | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1475 ## fact_graph : selection factor | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1476 ## fact_graph_sel : list of factors levels selected for this factor | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1477 ## list_fact : list of grouping factors | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1478 ## list_fact_sel : list of factors levels selected for these factors | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1479 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1480 ## Author: Yves Reecht, Date: 10 sept. 2012, 15:26 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1481 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1482 ## Open file : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1483 f_ile <- file(description = filename, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1484 open = "w", encoding = "latin1") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1485 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1486 ## if error : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1487 on.exit(if (exists("filename") && | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1488 tryCatch(isOpen(f_ile), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1489 error = function(e)return(FALSE))) close(f_ile)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1490 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1491 ## Metrics and factors infos : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1492 print_selection_info_f(metrique = metrique, #fact_graph = fact_graph, fact_graph_sel = fact_graph_sel, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1493 list_fact = list_fact, #list_fact_sel = list_fact_sel, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1494 f_ile = f_ile, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1495 agreg_level = agreg_level, type = type) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1496 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1497 ## statistics : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1498 if (class(d_ata) == "list") { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1499 cat("\n###################################################", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1500 "\nStatistics per level of splitting factor:\n", | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1501 sep = "", file = f_ile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1502 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1503 invisible(sapply(seq_len(length(d_ata)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1504 function(i) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1505 print_stats_f(d_ata = d_ata[[i]], metrique = metrique, list_fact = list_fact, f_ile = f_ile, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1506 headline = fact_graph_sel[i]) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1507 })) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1508 }else{ | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1509 print_stats_f(d_ata = d_ata, metrique = metrique, list_fact = list_fact, f_ile = f_ile, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1510 headline = NULL) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1511 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1512 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1513 ## Close file : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1514 close(f_ile) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1515 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1516 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1517 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1518 ######################################### end of the function info_stats_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1519 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1520 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1521 ######################################### start of the function print_selection_info_f called by info_stats_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1522 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1523 print_selection_info_f <- function(metrique, list_fact, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1524 f_ile, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1525 agreg_level = c("species", "unitobs"), type = c("graph", "stat")) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1526 ## Purpose: Write data informations | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1527 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1528 ## Arguments: metrique : chosen metric | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1529 ## list_fact : factor's list | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1530 ## f_ile : Results file name | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1531 ## agreg_level : aggregation level | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1532 ## type : function type | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1533 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1534 ## Author: Yves Reecht, Date: 11 sept. 2012, 10:41 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1535 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1536 cat("\n##################################################\n", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1537 "Metrics and factors (and possible units/selections):\n", | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1538 sep = "", file = f_ile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1539 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1540 ## metric info : | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1541 cat("\n Metrics:", metrique, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1542 "\n", file = f_ile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1543 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1544 ## Clustering factors : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1545 if (is.element(agreg_level, c("spCL_unitobs", "spCL_espece", "spSpecies", "spEspece", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1546 "spUnitobs", "spUnitobs(CL)"))) { | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1547 type <- "spatialGraph" | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1548 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1549 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1550 cat(switch(type, | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1551 "graph" = "\nGrouping factor(s): \n * ", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1552 "stat" = "\nAnalyses factor(s): \n * ", | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1553 "spatialGraph" = "\nSpatial aggregation factor(s): \n * "), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1554 paste(list_fact, collaspe = "\n * "), "\n", file = f_ile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1555 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1556 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1557 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1558 ######################################### end of the function print_selection_info_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1559 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1560 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1561 ######################################### start of the function print_stats_f called by info_stats_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1562 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1563 print_stats_f <- function(d_ata, metrique, list_fact, f_ile, headline = NULL) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1564 ## Purpose: Write general statistics table | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1565 ## ---------------------------------------------------------------------- | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1566 ## Arguments: d_ata : Analysis data | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1567 ## metrique : metric's name | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1568 ## list_fact : Factor's list | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1569 ## f_ile : Simple statistics file name | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1570 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1571 ## Author: Yves Reecht, Date: 11 sept. 2012, 10:09 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1572 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1573 ## Header : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1574 if (! is.null(headline)) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1575 cat("\n", rep("#", nchar(headline) + 3), "\n", | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1576 "## ", headline, "\n", | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1577 sep = "", file = f_ile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1578 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1579 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1580 cat("\n########################\nBase statistics:\n\n", file = f_ile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1581 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1582 capture.output(print(summary_fr(d_ata[, metrique])), file = f_ile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1583 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1584 if (! is.null(list_fact)) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1585 cat("\n#########################################", | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1586 "\nStatistics per combination of factor levels:\n\n", file = f_ile, sep = "", append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1587 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1588 ## Compute summary for each existing factor's cross : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1589 res <- with(d_ata, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1590 tapply(eval(parse(text = metrique)), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1591 INDEX = do.call(paste, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1592 c(lapply(list_fact, | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1593 function(y)eval(parse(text = y))), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1594 sep = ".")), | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1595 FUN = summary_fr)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1596 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1597 ## results in table | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1598 capture.output(print(do.call(rbind, res)), | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1599 file = f_ile, append = TRUE) | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1600 } | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1601 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1602 ## empty line : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1603 cat("\n", file = f_ile, append = TRUE) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1604 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1605 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1606 ######################################### end of the function print_stats_f | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1607 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1608 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1609 ######################################### start of the function summary_fr called by print_stats_f | 
| 
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1610 summary_fr <- function(object, digits = max(3, getOption("digits") - 3), ...) { | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1611 ## Purpose: Adding SD and N to summary | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1612 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1613 ## Arguments: object : Object to summarise | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1614 ## ---------------------------------------------------------------------- | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1615 ## Author: Yves Reecht, Date: 13 sept. 2012, 15:47 modified by Coline ROYAUX 04 june 2020 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1616 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1617 if (! is.numeric(object)) stop("Programming error") | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1618 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1619 ## Compute summary : | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1620 res <- c(summary(object = object, digits, ...), "sd" = signif(sd(x = object), digits = digits), "N" = length(object)) | 
| 
0
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1621 | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1622 return(res) | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1623 } | 
| 
 
2a82d3af9577
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 07f1028cc764f920b1e6419c151f04ab4e3600fa"
 
ecology 
parents:  
diff
changeset
 | 
1624 | 
| 
4
 
1f19263c44f9
"planemo upload for repository https://github.com/ColineRoyaux/PAMPA-Galaxy commit 3df1978827a91be30e815dee2ed83a92862d1b1c"
 
ecology 
parents: 
0 
diff
changeset
 | 
1625 ######################################### start of the function summary_fr | 
