Previous changeset 0:5cde56683579 (2024-03-21) Next changeset 2:ace69a8ec1c3 (2024-10-16) |
Commit message:
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Ecoregionalization_workflow commit e03df85746a3b61a382a5ee7e3357a8bf42a5097 |
modified:
GeoNearestNeighbor.xml brt.R test-data/Summary_of_taxa_model.tsv test-data/cnidaria_filtered.tsv |
b |
diff -r 5cde56683579 -r 36637718c51d GeoNearestNeighbor.xml --- a/GeoNearestNeighbor.xml Thu Mar 21 14:05:01 2024 +0000 +++ b/GeoNearestNeighbor.xml Wed Sep 11 09:19:58 2024 +0000 |
b |
@@ -132,4 +132,9 @@ | ... | ... | ... | ... | ... | ... | ... | ... | +----------+-----------+------------------------+-----------+---------+------+--------------+-----+ ]]></help> + <citations> + <citation type="doi">10.32614/RJ-2018-009</citation> + <citation type="doi">10.32614/CRAN.package.dplyr</citation> + <citation type="doi">10.32614/CRAN.package.sf</citation> + </citations> </tool> |
b |
diff -r 5cde56683579 -r 36637718c51d brt.R --- a/brt.R Thu Mar 21 14:05:01 2024 +0000 +++ b/brt.R Wed Sep 11 09:19:58 2024 +0000 |
[ |
@@ -3,7 +3,7 @@ ### Clean environment rm(list = ls(all.names = TRUE)) -options(warn=-1) +options(warn=1) ### load packages @@ -43,7 +43,27 @@ #Load functions make.brt <- function(spe,data,pred.vars,env,nb_file){ - brt_step <- gbm.step(data= data, gbm.x = pred.vars, gbm.y = spe, family = "bernoulli", tree.complexity = 2, learning.rate = 0.0001,max.trees = 10000,plot.main = F) + cat(paste(" ", spe,":\n -> optimising BRT model ",sep="")) + lr <- 0.05 + no.trees <- 0 + while ( no.trees < 1000 & lr > 0.0005 ) { + cat(".") + try(brt_step <- gbm.step(data= data, gbm.x = pred.vars, gbm.y = spe, family = "bernoulli", tree.complexity = 2, learning.rate = lr,max.trees = 10000, plot.main = F)) + # if the gbm does not converge, the return object is null or of size 0 + if (!is.null(brt_step) ) { + if (object.size(brt_step) > 0 ) { + no.trees <- brt_step$gbm.call$best.trees + print(no.trees) + } + } else { + no.trees <- 0 + print(no.trees) + } + + # decrease the learning rate + lr <- lr / 2 + print(lr) + } #plot if (is.null(brt_step)==FALSE){ pdf(file = paste("BRT-",spe,".pdf")) @@ -94,27 +114,38 @@ #Write prediction in a file preds <- cbind(preds,spe) - write.table(preds, paste(nb_file,"_brts_pred_ceamarc.tsv",sep=""), quote=FALSE, dec=".", row.names=F, col.names=T,append = T,sep="\t") + write.table(preds, paste(nb_file,"_brts_pred_ceamarc.tsv",sep=""), quote=FALSE, dec=".", row.names=F, col.names=!file.exists(paste(nb_file,"_brts_pred_ceamarc.tsv",sep="")),append = T,sep="\t") } #### RUN BRT #### nb_file = 0 +# Creating the %!in% operator +`%!in%` <- Negate(`%in%`) + +# Data file browsing for (file in data_files[[1]]) { + + # Reading the file species_data <- read.table(file, dec = dec_species, sep = "\t", header = TRUE, na.strings = "NA", colClasses = "numeric") nb_file = nb_file + 1 - `%!in%` <- Negate(`%in%`) + + # List to store species to predict sp = list() + + # Selection of columns that are not in 'env' and that are not coordinates or stations for (n in names(species_data)) { - if (n %!in% names(env) && n != 'station'){ - sp = cbind(sp,n) + if (n %!in% names(env) && n != 'station' && n != 'decimalLatitude' && n != 'decimalLongitude' && n!='lat' && n!='long'){ + sp = c(sp,n) } - } + } + # Making predictions for each species for (spe in sp){ try(make.prediction.brt(make.brt(spe,species_data,pred.vars,env,nb_file))) } } +#Display of abiotic parameters cat("Here is the list of your abiotic parameters:\n") cat(paste(pred.vars, collapse = ", "), "\n") |
b |
diff -r 5cde56683579 -r 36637718c51d test-data/Summary_of_taxa_model.tsv --- a/test-data/Summary_of_taxa_model.tsv Thu Mar 21 14:05:01 2024 +0000 +++ b/test-data/Summary_of_taxa_model.tsv Wed Sep 11 09:19:58 2024 +0000 |
b |
@@ -1,5 +1,4 @@ Taxa Model Occurences -Acanthogorgiidae No 0 Actiniaria Yes 50 Ainigmaptilon_edisto No 2 Alcyonacea No 43 |
b |
diff -r 5cde56683579 -r 36637718c51d test-data/cnidaria_filtered.tsv --- a/test-data/cnidaria_filtered.tsv Thu Mar 21 14:05:01 2024 +0000 +++ b/test-data/cnidaria_filtered.tsv Wed Sep 11 09:19:58 2024 +0000 |
b |
b'@@ -1,64 +1,64 @@\n-station\tlat\tlong\tCarbo\tGrav\tMaxbearing\tMaxmagnit\tMeancurmag\tMeansal\tMeantheta\tMud\tProf\tRugosity\tSand\tSeaice_prod\tSili\tSlope\tStandcurmag\tStandsal\tStandtheta\tAcanthogorgiidae\tActiniaria\tAinigmaptilon_edisto\tAlcyonacea\tAnthozoa\tThouarella_variabilis\tThouarella_vulpicauda\n-1\t1\t-65,99\t142,33\t5,51\t12,59\t2,03\t0,16\t0,07\t34,6\t-1,47\t29,8\t-233\t1\t56,16\t0,11\t3,94\t0,05\t0,03\t0,03\t0,24\t0\t1\t0\t0\t1\t0\t0\n-2\t10\t-66,33\t141,3\t3,17\t5,31\t5,2\t0,18\t0,08\t34,61\t-1,35\t21,5\t-215\t1\t67,39\t0,17\t5,8\t0,24\t0,03\t0,02\t0,28\t0\t1\t0\t1\t1\t0\t0\n-3\t11\t-66,56\t141,29\t3,1\t3,28\t4,93\t0,2\t0,08\t34,65\t-1,73\t34,89\t-192\t1\t73,13\t0,87\t4,48\t0,71\t0,03\t0,04\t0,24\t0\t0\t0\t1\t1\t0\t0\n-4\t12\t-66,55\t140,82\t2,78\t3,08\t3,74\t0,34\t0,1\t34,59\t-1,19\t25,83\t-217\t1\t68,37\t2,62\t4,05\t2,57\t0,06\t0,02\t0,24\t0\t1\t0\t1\t1\t1\t0\n-5\t13\t-66,15\t140,65\t2,06\t7,62\t5,36\t0,21\t0,09\t34,56\t-1,04\t13,18\t-217\t1\t71,68\t0,07\t2,89\t0,37\t0,04\t0,02\t0,26\t0\t1\t0\t0\t1\t0\t0\n-6\t14\t-66,33\t140,67\t2,96\t3,12\t2,42\t0,16\t0,08\t34,54\t-1,02\t12,15\t-171\t1\t73,16\t0,78\t1,17\t0,08\t0,03\t0,01\t0,22\t0\t1\t0\t0\t1\t0\t0\n-7\t15\t-66,38\t139,8\t1,06\t1,65\t1,87\t0,14\t0,05\t34,64\t-1,53\t69,08\t-855\t1\t48,44\t1,43\t13,55\t2,94\t0,03\t0,01\t0,06\t0\t1\t0\t1\t1\t0\t0\n-8\t16\t-66,34\t139,99\t1,34\t2,78\t1,61\t0,15\t0,05\t34,6\t-1,12\t41,06\t-538\t1\t54,72\t1,23\t5,97\t3,7\t0,03\t0,00839\t0,08\t0\t1\t0\t0\t1\t0\t0\n-9\t17\t-66,17\t139,96\t1,71\t8,13\t4,39\t0,31\t0,12\t34,54\t-0,96\t17,16\t-151\t1\t61,42\t0,54\t1,99\t0,25\t0,05\t0,02\t0,3\t0\t1\t0\t1\t1\t1\t0\n-10\t18\t-66,16\t139,65\t1,49\t7,75\t2,24\t0,15\t0,06\t34,59\t-1,01\t32,71\t-432\t1\t51,4\t0,56\t3,35\t0,42\t0,03\t0,01\t0,26\t0\t1\t0\t1\t1\t0\t1\n-11\t19\t-66,15\t139,31\t1,18\t8,58\t5,7\t0,12\t0,04\t34,61\t-1,36\t47,4\t-674\t1\t46,41\t0,34\t9,92\t0,31\t0,02\t0,00722\t0,09\t0\t1\t0\t0\t1\t0\t0\n-12\t2\t-65,99\t141,32\t3,3\t14,21\t5,01\t0,16\t0,07\t34,6\t-1,26\t14,05\t-235\t1\t67,07\t-0,01\t2,09\t0,13\t0,03\t0,03\t0,32\t0\t1\t1\t1\t1\t0\t1\n-13\t20\t-66\t139,99\t1,95\t20,59\t4,98\t0,19\t0,09\t34,56\t-1,05\t13,25\t-192\t1\t63,46\t0,27\t1,92\t0,21\t0,03\t0,03\t0,26\t0\t1\t0\t0\t1\t0\t0\n-14\t21\t-66\t139,64\t2,26\t18,21\t2,85\t0,16\t0,07\t34,58\t-1,04\t44,81\t-277\t1\t57,14\t0,76\t5,88\t1,66\t0,03\t0,01\t0,26\t0\t1\t0\t0\t1\t0\t0\n-15\t22\t-66\t139,31\t1,39\t19,2\t4,87\t0,1\t0,04\t34,6\t-1,05\t37,84\t-476\t1\t49,4\t0,65\t7,09\t0,25\t0,02\t0,00884\t0,15\t0\t1\t0\t1\t1\t0\t0\n-16\t26\t-66,52\t140,02\t1,51\t1,47\t4,4\t0,12\t0,05\t34,6\t-1,11\t49,11\t-247\t1\t49,52\t2,38\t10,29\t3,16\t0,02\t0,00984\t0,16\t0\t1\t0\t0\t1\t0\t0\n-17\t27\t-66,02\t142,74\t2,61\t11,58\t5,42\t0,13\t0,05\t34,64\t-1,73\t25,07\t-440\t1\t46,97\t0,24\t2,19\t0,23\t0,02\t0,03\t0,17\t0\t1\t0\t1\t1\t0\t1\n-18\t28\t-65,99\t143,02\t2,15\t11,5\t5,37\t0,14\t0,05\t34,64\t-1,77\t39,29\t-467\t1\t38,66\t0,24\t2,07\t0,32\t0,02\t0,03\t0,12\t0\t1\t0\t1\t1\t0\t1\n-19\t29\t-66,02\t143,29\t1,77\t9,98\t5,41\t0,14\t0,05\t34,64\t-1,78\t62,2\t-470\t1\t38,73\t0,33\t4,81\t0,19\t0,02\t0,03\t0,1\t0\t1\t0\t1\t1\t0\t1\n-20\t3\t-65,99\t141,98\t5,27\t14,32\t5,31\t0,01\t0,06\t34,6\t-1,4\t22,84\t-245\t1\t61,04\t-0,00886\t3,93\t0,15\t0,03\t0,03\t0,25\t0\t1\t0\t0\t1\t0\t0\n-21\t30\t-66\t143,68\t2,06\t9,47\t5,42\t0,15\t0,06\t34,61\t-1,71\t54,73\t-429\t1\t41,27\t0,39\t1,03\t0,22\t0,03\t0,03\t0,19\t0\t1\t0\t0\t1\t0\t0\n-22\t31\t-66,55\t144,99\t1,05\t19,55\t5,28\t0,12\t0,03\t34,62\t-1,73\t35,57\t-437\t1\t39,47\t5,14\t1,77\t0,45\t0,02\t0,03\t0,16\t0\t0\t0\t1\t1\t0\t1\n-23\t34\t-66,33\t144,34\t1,26\t6,31\t4,92\t0,13\t0,04\t34,63\t-1,77\t44,96\t-455\t1\t40,49\t1,87\t2,96\t0,39\t0,02\t0,03\t0,12\t0\t1\t0\t1\t1\t0\t1\n-24\t35\t-66,33\t144,01\t1,2\t4,9\t2,11\t0,12\t0,04\t34,64\t-1,78\t49,09\t-511\t1\t39,41\t1,54\t4,15\t0,32\t0,02\t0,02\t0,1\t0\t1\t0\t1\t1\t0\t0\n-25\t36\t-66,32\t143,65\t1,12\t4,29\t2,16\t0,12\t0,04\t34,64\t-1,79\t53,85\t-565\t1\t38,83\t1,26\t8,68\t0,38\t0,02\t0,02\t0,13\t0\t1\t0\t1\t1\t0\t1\n-26\t37\t-66,55\t143,31\t1,34\t4,32\t2,02\t0,12\t0,04\t34,66\t-1,82\t78,15\t-820\t1\t47,92\t2,76\t13,57\t0,26\t0,02\t0,03\t0,11\t0\t1\t0\t0\t1\t0\t0\n-27\t38\t-66,33\t143,31\t0,82\t3,84\t2,2\t0,1\t0,04\t34,65\t-1,8\t84,13\t-703\t1\t41,01\t0,98\t16,47\t0,25\t0,02\t0,03\t0,12\t0\t1\t0\t1\t1\t1\t0\n-28\t39\t-66,56\t143,02\t1,67\t4,11\t1,5\t0,13\t0,05\t34,65\t-1,8\t47,63\t-862\t1\t56,71\t2,22\t7,3\t0,18\t0,02\t0,02\t0,1\t0\t1\t0\t0\t1\t0\t0\n-29\t40\t-66,65\t142,98\t1,94\t3,93\t5,42\t0,13\t0,04\t34,63\t-1,75\t41,4\t-598\t1\t58,72\t3,57\t5,71\t1,57\t0,02\t0,03\t0,12\t0\t0\t0\t1\t1\t0\t1\n-30\t41\t-66,76\t142,65\t2,67\t2,67\t0,14\t0,15\t0,04\t34,65\t-1,76\t38,32\t-598\t1\t62,33\t4,43\t6,01\t4,29\t0,02\t0,04\t0,16\t0\t0\t0\t1\t1\t0\t1\n-31\t42\t-66,87\t142,66\t2,92\t1,71\t5,49\t0,13\t0,04\t34,63\t-1,72\t47,93\t-391\t1\t62,77\t8,27\t6,89\t1,19\t0,02\t0,05\t0,2\t0\t0\t0\t1\t1'..b'1\t0\t0\n+40\t-66,65\t142,98\t1,94\t3,93\t5,42\t0,13\t0,04\t34,63\t-1,75\t41,4\t-598\t1\t58,72\t3,57\t5,71\t1,57\t0,02\t0,03\t0,12\t0\t0\t1\t1\t0\t1\n+41\t-66,76\t142,65\t2,67\t2,67\t0,14\t0,15\t0,04\t34,65\t-1,76\t38,32\t-598\t1\t62,33\t4,43\t6,01\t4,29\t0,02\t0,04\t0,16\t0\t0\t1\t1\t0\t1\n+42\t-66,87\t142,66\t2,92\t1,71\t5,49\t0,13\t0,04\t34,63\t-1,72\t47,93\t-391\t1\t62,77\t8,27\t6,89\t1,19\t0,02\t0,05\t0,2\t0\t0\t1\t1\t0\t1\n+43\t-66,74\t143,33\t2\t3,28\t4,67\t0,19\t0,06\t34,61\t-1,74\t62,82\t-332\t1\t54,92\t7,42\t9,35\t3,78\t0,03\t0,05\t0,16\t1\t0\t1\t1\t0\t0\n+45\t-66,75\t144\t2,19\t3,12\t5,5\t0,16\t0,04\t34,61\t-1,8\t42,36\t-661\t1\t43,64\t7,49\t5,95\t4,51\t0,03\t0,02\t0,07\t1\t0\t1\t1\t0\t1\n+46\t-66,87\t144,1\t2,59\t1,31\t5,89\t0,17\t0,05\t34,59\t-1,78\t38,87\t-561\t1\t43,42\t10,54\t4,09\t1,16\t0,03\t0,04\t0,14\t0\t0\t1\t1\t0\t1\n+48\t-66,93\t144,65\t1,59\t0,58\t5,75\t0,21\t0,06\t34,6\t-1,83\t73,19\t-407\t1\t40,23\t11,89\t10,52\t5,23\t0,03\t0,03\t0,09\t1\t0\t1\t1\t0\t0\n+5\t-66,32\t142,29\t3,03\t4,93\t5,05\t0,2\t0,1\t34,63\t-1,61\t39,53\t-216\t1\t61,67\t0,27\t2,63\t0,11\t0,04\t0,02\t0,17\t0\t0\t1\t1\t0\t1\n+50\t-66,75\t145,27\t1,02\t5,5\t5,49\t0,13\t0,04\t34,64\t-1,77\t52,4\t-596\t1\t39,8\t9,53\t4,66\t0,23\t0,02\t0,03\t0,1\t1\t0\t1\t1\t0\t1\n+51\t-66,74\t145,48\t0,95\t6,47\t5,5\t0,2\t0,05\t34,62\t-1,78\t49,32\t-535\t1\t40,91\t10,66\t3,37\t0,55\t0,03\t0,04\t0,11\t1\t0\t0\t1\t0\t0\n+52\t-66,55\t145,31\t1,04\t19,26\t5,26\t0,09\t0,03\t34,59\t-1,67\t36,48\t-409\t1\t42,62\t6,4\t1,12\t0,09\t0,01\t0,03\t0,22\t1\t0\t0\t1\t0\t0\n+53\t-66,33\t144,66\t1,24\t6,73\t5,36\t0,13\t0,04\t34,61\t-1,71\t62,77\t-420\t1\t42,45\t2,27\t3,99\t0,17\t0,02\t0,04\t0,18\t1\t0\t0\t1\t0\t0\n+54\t-65,91\t144,02\t3,17\t12,05\t5,16\t0,15\t0,06\t34,57\t-0,92\t31,38\t-375\t1\t46,27\t0,41\t2,1\t2,62\t0,02\t0,02\t0,4\t1\t1\t1\t1\t0\t1\n+55\t-66,33\t145,01\t1,12\t8,85\t5,25\t0,12\t0,04\t34,56\t-1,68\t40,75\t-387\t1\t44,3\t3,06\t2,2\t0,58\t0,02\t0,03\t0,26\t1\t0\t1\t1\t0\t1\n+56\t-66,56\t144,67\t1,3\t16,82\t2,34\t0,13\t0,04\t34,65\t-1,79\t45,94\t-582\t1\t39,22\t4,26\t3,93\t0,38\t0,02\t0,03\t0,1\t1\t0\t0\t1\t0\t0\n+57\t-66,74\t145\t1,18\t5,21\t2,42\t0,16\t0,05\t34,65\t-1,8\t53,42\t-646\t1\t38,62\t7,59\t7,28\t0,68\t0,03\t0,03\t0,09\t1\t0\t0\t1\t0\t0\n+58\t-66,75\t144,67\t1,28\t4,2\t2,34\t0,18\t0,05\t34,65\t-1,81\t79,28\t-837\t1\t34,69\t7,08\t12,46\t0,61\t0,03\t0,03\t0,08\t1\t0\t1\t1\t0\t1\n+6\t-66,32\t142,66\t1,83\t4,69\t1,69\t0,1\t0,08\t34,65\t-1,74\t18,2\t-384\t1\t58,78\t0,43\t2,05\t0,09\t0,03\t0,02\t0,15\t1\t0\t1\t1\t0\t0\n+60\t-66,56\t143,93\t1,51\t7,74\t2,05\t0,14\t0,05\t34,65\t-1,82\t47,04\t-799\t1\t38,88\t3,65\t7,36\t0,94\t0,03\t0,03\t0,09\t1\t0\t1\t1\t0\t0\n+61\t-66,33\t142,97\t1,15\t4,14\t5,31\t0,13\t0,05\t34,64\t-1,74\t52,04\t-644\t1\t49,19\t0,67\t9,1\t0,82\t0,02\t0,03\t0,16\t1\t0\t1\t1\t0\t0\n+62\t-66,15\t143,32\t1,06\t10,88\t2,17\t0,12\t0,04\t34,64\t-1,76\t59,46\t-545\t1\t37,97\t0,52\t5,25\t0,23\t0,02\t0,02\t0,14\t1\t0\t1\t1\t0\t0\n+63\t-65,85\t142,98\t3,71\t20,11\t5,24\t0,27\t0,11\t34,61\t-1,22\t24,73\t-423\t1\t41,04\t0,19\t1,03\t0,56\t0,05\t0,02\t0,44\t0\t0\t1\t1\t0\t1\n+65\t-65,81\t143\t3,89\t21,43\t5,23\t0,39\t0,13\t34,61\t-0,67\t25,78\t-777\t1\t41,24\t0,18\t1,56\t7,69\t0,06\t0,02\t0,33\t1\t0\t1\t1\t0\t1\n+66\t-65,75\t143,04\tNA\tNA\t4,48\tNA\tNA\tNA\tNA\tNA\tNA\tNA\tNA\tNA\tNA\tNA\tNA\tNA\tNA\t0\t0\t1\t1\t0\t0\n+7\t-66,55\t142,64\t2,12\t4,31\t1,77\t0,18\t0,07\t34,66\t-1,75\t15,34\t-255\t1\t65,49\t1,46\t1,38\t6,15\t0,03\t0,03\t0,18\t0\t0\t0\t0\t0\t0\n+70\t-66,42\t140,52\t2,3\t2,63\t5,35\t0,08\t0,03\t34,64\t-1,49\t20,33\t-1109\t1\t67,5\t1,56\t3,67\t5,9\t0,01\t0,01\t0,05\t1\t0\t0\t1\t0\t0\n+71\t-66,39\t140,48\t2,22\t2,24\t5,27\t0,06\t0,02\t34,62\t-1,36\t19,67\t-768\t1\t67,65\t1,36\t3,1\t7,04\t0,01\t0,01\t0,04\t1\t0\t1\t1\t0\t1\n+72\t-66,34\t140,48\t2,18\t2,6\t2,34\t0,09\t0,04\t34,58\t-1,14\t17,49\t-407\t1\t67,61\t1,01\t2,1\t2,74\t0,01\t0,01\t0,11\t1\t0\t1\t1\t0\t0\n+79\t-65,7\t140,56\t1,83\t25,43\t4,77\t0,34\t0,16\t34,6\t-0,94\t3,7\t-506\t1\t66,84\t0,09\t1,91\t5,63\t0,06\t0,02\t0,38\t1\t0\t1\t1\t0\t1\n+8\t-66,56\t142,33\t3,36\t3,2\t1,96\t0,16\t0,06\t34,68\t-1,85\t67,67\t-374\t1\t60,65\t1,04\t11,68\t1,03\t0,03\t0,03\t0,1\t1\t0\t1\t1\t0\t1\n+81\t-65,65\t140,44\t1,42\t28,49\t4,93\t0,3\t0,15\t34,62\t-0,81\t3,75\t-1193\t1\t66,73\t0,13\t1,29\t5,59\t0,05\t0,02\t0,32\t0\t0\t1\t1\t0\t0\n+84\t-65,45\t139,37\t0,98\t28,81\t1,16\t0,06\t0,03\t34,62\t-0,21\t17,56\t-395\tNA\t58,04\t0,28\t2,92\t0,29\t0,01\t0,01\t0,22\t0\t0\t1\t1\t0\t0\n+86\t-65,47\t139,35\t0,96\t28,78\t2,13\t0,00947\t0,03\t34,62\t-0,2\t18,67\t-398\tNA\t57,91\t0,27\t2,96\t0,26\t0,01\t0,01\t0,22\t1\t0\t1\t1\t0\t0\n+87\t-65,49\t139,33\t0,95\t28,75\t4,01\t0,05\t0,03\t34,62\t-0,19\t20,03\t-400\tNA\t57,77\t0,27\t3,02\t0,42\t0,01\t0,01\t0,21\t1\t0\t0\t1\t0\t0\n+9\t-66,55\t141,99\t3,19\t3,31\t5,38\t0,17\t0,05\t34,68\t-1,85\t40,51\t-357\t1\t65,13\t0,81\t6,85\t3,19\t0,03\t0,03\t0,1\t0\t0\t1\t1\t0\t1\n' |