Next changeset 1:b8fa05dbcff4 (2018-08-03) |
Commit message:
Uploaded |
added:
ab_index.R ab_index_en.xml autocorr-res_acf.R autocorr-res_acf_en.xml dennis_gam_initial_functions.R flight_curve.R flight_curve_en.xml glmmpql.R glmmpql_en.xml gls-adjusted.R gls-adjusted_en.xml gls.R gls_en.xml plot_trend.R plot_trend_en.xml |
b |
diff -r 000000000000 -r 5b126f770671 ab_index.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ab_index.R Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,17 @@ +#!/usr/bin/env Rscript +#library("getopt") +#library(devtools) +#library(RegionalGAM) + +args = commandArgs(trailingOnly=TRUE) +source(args[1]) + + +tryCatch({input = read.table(args[2], header=TRUE,sep=" ")},finally={input = read.table(args[2], header=TRUE,sep=",")}) +pheno = read.table(args[3], header=TRUE,sep=" ") + +if("TREND" %in% colnames(input)){ + input <- input[input$TREND==1,c("SPECIES","SITE","YEAR","MONTH","DAY","COUNT")] +} +data.index <- abundance_index(input, pheno) +write.table(data.index, file="data.index", row.names=FALSE, sep=" ") |
b |
diff -r 000000000000 -r 5b126f770671 ab_index_en.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ab_index_en.xml Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,39 @@ +<tool id="ab_index" name="Abundance index" version="0.1"> + <description>computation across species, sites and years</description> + <requirements> + <requirement type="package" version="3.4">r</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + Rscript '$__tool_directory__/ab_index.R' '$__tool_directory__/dennis_gam_initial_functions.R' '$input1' '$input2' '$output' ]]> + </command> + <inputs> + <param format="tabular,csv" name="input1" type="data" label="Count file" help="The file must contain the SPECIES, SITE, YEAR, MONTH, DAY and COUNT columns. CSV file separator ',' or tab."/> + <param format="tabular" name="input2" type="data" label="Flight curve output"/> + </inputs> + <outputs> + <data format="tabular" name="output" from_work_dir="data.index" /> + </outputs> + <tests> + <test> <!-- FAILED --> + <param name="input1" value="gatekeeper_CM"/> + <param name="input2" value="flight_curve_result.tabular"/> + <output name="output" value="data_index.tabular"/> + </test> + </tests> + <help><![CDATA[ + +.. class:: infomark + +========================== +Compute abundance index +========================== + +This tool is an implementation of the abundance_index function from `RegionalGAM package: https://github.com/RetoSchmucki/regionalGAM/ + +This function compute the Abundance Index across sites and years from your dataset and the regional flight curve. + + ]]></help> + <citations> + <citation type="doi">10.1111/1365-2664.12561</citation> + </citations> +</tool> |
b |
diff -r 000000000000 -r 5b126f770671 autocorr-res_acf.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autocorr-res_acf.R Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,10 @@ +#!/usr/bin/env Rscript +library(nlme) +library(MASS) + +args = commandArgs(trailingOnly=TRUE) +load(args[1]) + +png('output-acf.png') +graph<-acf(residuals(mod,type="normalized")) +invisible(dev.off()) |
b |
diff -r 000000000000 -r 5b126f770671 autocorr-res_acf_en.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autocorr-res_acf_en.xml Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,39 @@ +<tool id="autocor-acf" name="Autocorrelation test" version="0.1"> + <description>check for temporal autocorrelation in the residuals</description> + <requirements> + <requirement type="package" version="3.1_131">r-nlme</requirement> + <requirement type="package" version="7.3_48">r-mass</requirement> + <requirement type="package" version="0.9.10">xorg-libxrender</requirement> + <requirement type="package" version="1.1.2">xorg-libsm</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + Rscript '$__tool_directory__/autocorr-res_acf.R' '$input1' '$output' ]]> + </command> + <inputs> + <param format="rdata" name="input1" type="data" label="gls model" help="Rdata file"/> + </inputs> + <outputs> + <data format="png" name="output" from_work_dir="output-acf.png" /> + </outputs> + <tests> + <test> + <param name="input1" value="mod1"/> + <param output="output" value="res.png"/> + </test> + </tests> + + <help><![CDATA[ + +.. class:: infomark + +========================== +Model residuals autocorrelation check +========================== + +This tool is an implementation of the autocorr-res_acf function from `RegionalGAM package: https://github.com/RetoSchmucki/regionalGAM/ +This function uses a simple linear model and explore for temporal autocorrelation that we will account in the final model. + ]]></help> + <citations> + <citation type="doi">10.1111/1365-2664.12561</citation> +</citations> +</tool> |
b |
diff -r 000000000000 -r 5b126f770671 dennis_gam_initial_functions.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dennis_gam_initial_functions.R Fri Aug 03 08:28:22 2018 -0400 |
[ |
b'@@ -0,0 +1,638 @@\n+### R-Script Adapted from script provided by the CEH, UK BY: Reto Schmucki [ reto.schmucki@mail.mcgill.ca]\n+### DATE: 14 July 2014 function to run two stage model in DENNIS et al. 2013\n+\n+\n+.onAttach <- function(libname, pkgname) {\n+ packageStartupMessage(" The regionalGAM package that is no longer maintained, \\n use the new rbms package instead. \\n\n+ devtools::install_github(\\"RetoSchmucki/rbms\\", force=TRUE)")\n+}\n+\n+\n+#\' year_day_func Function\n+#\' This function generate the full sequence of days, months and include the observation to that file.\n+#\' @param sp_data A data.frame with your observation.\n+#\' @keywords year days\n+#\' @export\n+#\' @author Reto Schmucki\n+#\' @examples\n+#\' year_day_func()\n+\n+\n+# FUNCTIONS\n+\n+year_day_func = function(sp_data) {\n+\n+ year <- unique(sp_data$YEAR)\n+\n+ origin.d <- paste(year, "01-01", sep = "-")\n+ if ((year%%4 == 0) & ((year%%100 != 0) | (year%%400 == 0))) {\n+ nday <- 366\n+ } else {\n+ nday <- 365\n+ }\n+\n+ date.serie <- as.POSIXlt(seq(as.Date(origin.d), length = nday, by = "day"), format = "%Y-%m-%d")\n+\n+ dayno <- as.numeric(julian(date.serie, origin = as.Date(origin.d)) + 1)\n+ month <- as.numeric(strftime(date.serie, format = "%m"))\n+ week <- as.numeric(strftime(date.serie, format = "%W"))\n+ week_day <- as.numeric(strftime(date.serie, format = "%u"))\n+ day <- as.numeric(strftime(date.serie, format = "%d"))\n+\n+ site_list <- sp_data[!duplicated(sp_data$SITE), c("SITE")]\n+\n+ all_day_site <- data.frame(SPECIES = sp_data$SPECIES[1], SITE = rep(site_list, rep(nday, length(site_list))),\n+ YEAR = sp_data$YEAR[1], MONTH = month, WEEK = week, DAY = day, DAY_WEEK = week_day, DAYNO = dayno,\n+ COUNT = NA)\n+\n+ count_index <- match(paste(sp_data$SITE, sp_data$DAYNO, sep = "_"), paste(all_day_site$SITE, all_day_site$DAYNO,\n+ sep = "_"))\n+ all_day_site$COUNT[count_index] <- sp_data$COUNT\n+ site_count_length <- aggregate(sp_data$COUNT, by = list(sp_data$SITE), function(x) list(1:length(x)))\n+ names(site_count_length$x) <- as.character(site_count_length$Group.1)\n+ site_countno <- utils::stack(site_count_length$x)\n+ all_day_site$COUNTNO <- NA\n+ all_day_site$COUNTNO[count_index] <- site_countno$values # add count number to ease extraction of single count\n+\n+ # Add zero to close observation season two weeks before and after the first and last\n+ first_obs <- min(all_day_site$DAYNO[!is.na(all_day_site$COUNT)])\n+ last_obs <- max(all_day_site$DAYNO[!is.na(all_day_site$COUNT)])\n+\n+ closing_season <- c((first_obs - 11):(first_obs - 7), (last_obs + 7):(last_obs + 11))\n+\n+ # If closing season is before day 1 or day 365, simply set the first and last 5 days to 0\n+ if (min(closing_season) < 1)\n+ closing_season[1:5] <- c(1:5)\n+ if (max(closing_season) > nday)\n+ closing_season[6:10] <- c((nday - 4):nday)\n+\n+ all_day_site$COUNT[all_day_site$DAYNO %in% closing_season] <- 0\n+ all_day_site$ANCHOR <- 0\n+ all_day_site$ANCHOR[all_day_site$DAYNO %in% closing_season] <- 1\n+\n+ all_day_site <- all_day_site[order(all_day_site$SITE, all_day_site$DAYNO), ]\n+\n+ return(all_day_site)\n+}\n+\n+\n+#\' trap_area Function\n+#\'\n+#\' This function compute the area under the curve using the trapezoid method.\n+#\' @param x A vector or a two columns matrix.\n+#\' @param y A vector, Default is NULL\n+#\' @keywords trapezoid\n+#\' @export\n+#\' @examples\n+#\' trap_area()\n+\n+\n+trap_area = function(x, y = NULL) {\n+ # If y is null and x has multiple columns then set y to x[,2] and x to x[,1]\n+ if (is.null(y)) {\n+ if (length(dim(x)) == 2) {\n+ y = x[, 2]\n+ x = x[, 1]\n+ } else {\n+ stop("ERROR: need to either specifiy both x and y or supply a two column data.frame/matrix to x")\n+ }\n+ }\n+\n+ # Check x and y are same length\n+ if (length(x) != length(y)) {\n+ stop("ERROR: x and y need to be the same length")\n+ }\n+\n+ # Need to exclude any'..b'u_index) <- c("SITE", "SPECIES", "YEAR", "regional_gam", "prop_pheno_sampled")\n+\n+ cumu_index <- cumu_index[order(cumu_index$SITE), ]\n+\n+ # bind if exist else create\n+ if ("cumullated_indices" %in% ls()) {\n+ cumullated_indices <- rbind(cumullated_indices, cumu_index)\n+ } else {\n+ cumullated_indices <- cumu_index\n+ }\n+\n+} # end of year loop\n+\n+} else {\n+\n+ y <- unique(dataset$YEAR)\n+ year_pheno <- flight_pheno[flight_pheno$year == y, ]\n+\n+ dataset_y <- dataset[dataset$YEAR == y, ]\n+\n+ sp_data_site <- year_day_func(dataset_y)\n+ sp_data_site$trimDAYNO <- sp_data_site$DAYNO - min(sp_data_site$DAYNO) + 1\n+\n+ sp_data_site <- merge(sp_data_site, year_pheno[, c("DAYNO", "nm")],\n+ by = c("DAYNO"), all.x = TRUE, sort = FALSE)\n+\n+ # compute proportion of the flight curve sampled due to missing visits\n+ pro_missing_count <- data.frame(SITE = sp_data_site$SITE, WEEK = sp_data_site$WEEK,\n+ NM = sp_data_site$nm, COUNT = sp_data_site$COUNT, ANCHOR = sp_data_site$ANCHOR)\n+ pro_missing_count$site_week <- paste(pro_missing_count$SITE, pro_missing_count$WEEK,\n+ sep = "_")\n+ siteweeknocount <- aggregate(pro_missing_count$COUNT, by = list(pro_missing_count$site_week),\n+ function(x) sum(!is.na(x)) == 0)\n+ pro_missing_count <- pro_missing_count[pro_missing_count$site_week %in%\n+ siteweeknocount$Group.1[siteweeknocount$x == TRUE], ]\n+ pro_count_agg <- aggregate(pro_missing_count$NM, by = list(pro_missing_count$SITE),\n+ function(x) 1 - sum(x, na.rm = T))\n+ names(pro_count_agg) <- c("SITE", "PROP_PHENO_SAMPLED")\n+\n+ # remove samples outside the monitoring window\n+ sp_data_site$COUNT[sp_data_site$nm==0] <- NA\n+\n+ # Compute the regional GAM index\n+ if(length(unique(sp_data_site$SITE))>1){\n+ glm_obj_site <- glm(COUNT ~ factor(SITE) + offset(log(nm)) - 1, data = sp_data_site,\n+ family = quasipoisson(link = "log"), control = list(maxit = 100))\n+ } else {\n+ glm_obj_site <- glm(COUNT ~ offset(log(nm)) - 1, data = sp_data_site,\n+ family = quasipoisson(link = "log"), control = list(maxit = 100))\n+ }\n+\n+ sp_data_site[, "FITTED"] <- predict.glm(glm_obj_site, newdata = sp_data_site,\n+ type = "response")\n+ sp_data_site[, "COUNT_IMPUTED"] <- sp_data_site$COUNT\n+ sp_data_site[is.na(sp_data_site$COUNT), "COUNT_IMPUTED"] <- sp_data_site$FITTED[is.na(sp_data_site$COUNT)]\n+\n+ # add fitted value for missing mid-week data\n+ sp_data_site <- sp_data_site[!paste(sp_data_site$DAY_WEEK, sp_data_site$COUNT) %in%\n+ c("1 NA", "2 NA", "3 NA", "5 NA", "6 NA", "7 NA"), ]\n+\n+ # remove all added mid-week values for weeks with real count\n+ # (observation)\n+ sp_data_site$site_week <- paste(sp_data_site$SITE, sp_data_site$WEEK,\n+ sep = "_")\n+ siteweekcount <- aggregate(sp_data_site$COUNT, by = list(sp_data_site$site_week),\n+ function(x) sum(!is.na(x)) > 0)\n+ sp_data_site <- sp_data_site[!(is.na(sp_data_site$COUNT) & (sp_data_site$site_week %in%\n+ siteweekcount$Group.1[siteweekcount$x == TRUE])), names(sp_data_site) !=\n+ "site_week"]\n+\n+ # Compute the regional gam index\n+ print(paste("Compute index for",sp_data_site$SPECIES[1],"at year", y,"for",length(unique(sp_data_site$SITE)),"sites:",Sys.time()))\n+ regional_gam_index <- trap_index(sp_data_site, data_col = "COUNT_IMPUTED",\n+ time_col = "DAYNO", by_col = c("SPECIES", "SITE", "YEAR"))\n+\n+ cumu_index <- merge(regional_gam_index, pro_count_agg, by = c("SITE"),\n+ all.x = TRUE, sort = FALSE)\n+ names(cumu_index) <- c("SITE", "SPECIES", "YEAR", "regional_gam", "prop_pheno_sampled")\n+\n+ cumu_index <- cumu_index[order(cumu_index$SITE), ]\n+\n+ # bind if exist else create\n+ if ("cumullated_indices" %in% ls()) {\n+ cumullated_indices <- rbind(cumullated_indices, cumu_index)\n+ } else {\n+ cumullated_indices <- cumu_index\n+ }\n+\n+}\n+\n+return(cumullated_indices)\n+\n+}\n' |
b |
diff -r 000000000000 -r 5b126f770671 flight_curve.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flight_curve.R Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,12 @@ +#!/usr/bin/env Rscript +#library('getopt') +#library(devtools) + +args = commandArgs(trailingOnly=TRUE) +source(args[1]) #TODO replace by library(regionalGAM) if available as official package from bioconda + +tryCatch({input = read.table(args[2], header=TRUE,sep=" ")},finally={input = read.table(args[2], header=TRUE,sep=",")}) +dataset1 <- input[,c("SPECIES","SITE","YEAR","MONTH","DAY","COUNT")] +pheno <- flight_curve(dataset1) + +write.table(pheno, file="pheno", row.names=FALSE, sep=" ") |
b |
diff -r 000000000000 -r 5b126f770671 flight_curve_en.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flight_curve_en.xml Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,36 @@ +<tool id="flight-curve" name="Flight curve"> +<description>compute the regional expected pattern of abundance</description> + <requirements> + <requirement type="package" version="3.4">r</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + Rscript '$__tool_directory__/flight_curve.R' '$__tool_directory__/dennis_gam_initial_functions.R' '$input' '$output' ]]> + </command> + <inputs> + <param format="tabular,csv" name="input" type="data" label="Count file" help="The file must contain the SPECIES, SITE, YEAR, MONTH, DAY and COUNT columns. CSV file separator ',' or tab."/> + </inputs> + <outputs> + <data format="tabular" name="output" from_work_dir="pheno" /> + </outputs> + <tests> + <test> <!--FAILED--> + <param name="input" value="gatekeeper_CM"/> + <output name="output" value="flight_curve_result.tabular"/> + </test> + </tests> + <help><![CDATA[ + +.. class:: infomark + +========================== +Regional phenology +========================== + +This tool is an implementation of the flight_curve function `RegionalGAM package: https://github.com/RetoSchmucki/regionalGAM/ +This function computes the annual phenology on a specific region. + + ]]></help> + <citations> + <citation type="doi">10.1111/1365-2664.12561</citation> + </citations> +</tool> |
b |
diff -r 000000000000 -r 5b126f770671 glmmpql.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glmmpql.R Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,18 @@ +#!/usr/bin/env Rscript +library(nlme) +library(MASS) + +args = commandArgs(trailingOnly=TRUE) +input = read.table(args[1], header=TRUE,sep=" ") #input=data.index =ab_index-output + +glmm.mod_fullyear <- glmmPQL(regional_gam~ as.factor(YEAR)-1,data=input,family=quasipoisson,random=~1|SITE, correlation = corAR1(form = ~ YEAR | SITE),verbose = FALSE) + +col.index <- as.numeric(glmm.mod_fullyear$coefficients$fixed) +year <- unique(input$YEAR) + +write.table(col.index, file="output-glmmpql", row.names=FALSE, sep=" ") +#write.table(col.index, file="output-glmmpql", row.names=FALSE) + +png('output-plot.png') +plot(year,col.index,type='o', xlab="year",ylab="collated index") +invisible(dev.off()) |
b |
diff -r 000000000000 -r 5b126f770671 glmmpql_en.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glmmpql_en.xml Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,40 @@ +<tool id="glmmpql" name="Expected temporal trend" version="0.1"> + <description>of species abundance</description> + <requirements> + <requirement type="package" version="3.1_131">r-nlme</requirement> + <requirement type="package" version="7.3_48">r-mass</requirement> + <requirement type="package" version="0.9.10">xorg-libxrender</requirement> + <requirement type="package" version="1.2.2">xorg-libsm</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + Rscript '$__tool_directory__/glmmpql.R' '$input1' '$output' '$output2' ]]> + </command> + <inputs> + <param format="tabular" name="input1" type="data" label="Tabular file generated by the ab_index tool"/> + </inputs> + <outputs> + <data format="png" name="output" from_work_dir="output-plot.png" /> + <data format="tabular" name="output2" from_work_dir="output-glmmpql" /> + </outputs> + <tests> + <test> + <param name="input1" value="data_index.tabular"/> + <param name="output" value="glmmpql-plot.png"/> + <output name="output2" value="glmmpql.tabular"/> + </test> + </tests> + <help><![CDATA[ + +.. class:: infomark + +========================== +Temporal trends of species abundance +========================== + +This tool is an implementation of the glmmpql function from `RegionalGAM package: https://github.com/RetoSchmucki/regionalGAM/ +This function computes a collated index for each year and estimates the temporal trend. + ]]></help> + <citations> + <citation type="doi">10.1111/1365-2664.12561</citation> + </citations> +</tool> |
b |
diff -r 000000000000 -r 5b126f770671 gls-adjusted.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gls-adjusted.R Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,16 @@ +#!/usr/bin/env Rscript +library(nlme) +library(MASS) + +args = commandArgs(trailingOnly=TRUE) +input1 = read.table(args[1], header=TRUE) #input1=col.index =glmmpql-output +input2 = read.table(args[2], header=TRUE,sep=" ") #input2=data.index =abundance_index-output + +input1<-as.matrix(input1) + +year <- unique(input2$YEAR) +mod <- gls(input1~year, correlation = corARMA(p=2)) +summary<-summary(mod) + +save(mod, file = "mod_adjusted.rda") +capture.output(summary, file="mod_adjusted-summary.txt") |
b |
diff -r 000000000000 -r 5b126f770671 gls-adjusted_en.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gls-adjusted_en.xml Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,41 @@ +<tool id="gls-adjusted" name="Linear regression ajusted" version="0.1"> + <description>for autocorrelation in the residuals</description> + <requirements> + <requirement type="package" version="3.1_131">r-nlme</requirement> + <requirement type="package" version="7.3_48">r-mass</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + Rscript '$__tool_directory__/gls-adjusted.R' '$input1' '$input2' '$output' '$output2' ]]> + </command> + <inputs> + <param format="tabular" name="input1" type="data" label="File generated by the glmmpql/Expected temporal trend tool"/> + <param format="tabular" name="input2" type="data" label="File generated by the ab_index tool"/> + </inputs> + <outputs> + <data format="txt" name="output" from_work_dir="mod_adjusted-summary.txt" /> + <data format="rdata" name="output2" from_work_dir="mod_adjusted.rda" /> + </outputs> + <tests> + <test> <!--FAILED--> + <param name="input1" value="glmmpql.tabular"/> + <param name="input2" value="data_index.tabular"/> + <output name="output" value="gls-adju_sum.txt"/> + <output name="output2" value="gls-adju_rda.rda"/> + </test> + </tests> + <help><![CDATA[ + +.. class:: infomark + +========================== +STOC eps for specialists groups +========================== + +This tool is an implementation of the gls_adjusted function from `RegionalGAM package: https://github.com/RetoSchmucki/regionalGAM/ +This function adjust the model to account for autocorrelation in the residuals. + + ]]></help> + <citations> + <citation type="doi">10.1111/1365-2664.12561</citation> + </citations> +</tool> |
b |
diff -r 000000000000 -r 5b126f770671 gls.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gls.R Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,16 @@ +#!/usr/bin/env Rscript +library(nlme) +library(MASS) + +args = commandArgs(trailingOnly=TRUE) +input1 = read.table(args[1], header=TRUE) #input1=col.index =glmmpql-output +input2 = read.table(args[2], header=TRUE,sep=" ") #input2=data.index =abundance_index-output + +input1<-as.matrix(input1) + +year <- unique(input2$YEAR) +mod <- gls(input1~year) +summary<-summary(mod) + +save(mod, file = "mod.rda") +capture.output(summary, file="mod-summary.txt") |
b |
diff -r 000000000000 -r 5b126f770671 gls_en.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gls_en.xml Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,41 @@ +<tool id="gls" name="Model temporal trend" version="0.1"> + <description>with a simple linear regression</description> + <requirements> + <requirement type="package" version="3.1_131">r-nlme</requirement> + <requirement type="package" version="7.3_48">r-mass</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + Rscript '$__tool_directory__/gls.R' '$input1' '$input2' '$output' '$output2' ]]> + </command> + <inputs> + <param name="input1" type="data" format="tabular" label="File generated by the glmmpql/Expected temporal trend tool"/> + <param name="input2" type="data" format="tabular" label="File generated by the outil ab_index tool"/> + </inputs> + <outputs> + <data format="txt" name="output" from_work_dir="mod-summary.txt" /> + <data format="rdata" name="output2" from_work_dir="mod.rda" /> + </outputs> + <tests> + <test> <!--FAILED for binary--> + <param name="input1" value="glmmpql.tabular"/> + <param name="input2" value="data_index.tabular"/> + <output name="output" value="gls_sum.txt"/> + <output name="output2" value="gls_rda.rda"/> + </test> + </tests> + <help><![CDATA[ + +.. class:: infomark + +========================== +Model temporal trend +========================== + +This tool is an implementation of the gls function from `RegionalGAM package: https://github.com/RetoSchmucki/regionalGAM/ +This function model temporal trend with a simple linear regression. + + ]]></help> + <citations> + <citation type="doi">10.1111/1365-2664.12561</citation> +</citations> +</tool> |
b |
diff -r 000000000000 -r 5b126f770671 plot_trend.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot_trend.R Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,17 @@ +#!/usr/bin/env Rscript +library(nlme) +library(MASS) + +args = commandArgs(trailingOnly=TRUE) +input = read.table(args[1], header=TRUE,sep=" ") #input=data.index =ab_index-output +load(args[2]) + +glmm.mod_fullyear <- glmmPQL(regional_gam~ as.factor(YEAR)-1,data=input,family=quasipoisson,random=~1|SITE, correlation = corAR1(form = ~ YEAR | SITE),verbose = FALSE) + +col.index <- as.numeric(glmm.mod_fullyear$coefficients$fixed) +year <- unique(input$YEAR) + +png('output-plot-trend.png') +plot(year,col.index, type='o',xlab="year",ylab="collated index") +abline(mod,lty=2,col="red") +dev.off() |
b |
diff -r 000000000000 -r 5b126f770671 plot_trend_en.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot_trend_en.xml Fri Aug 03 08:28:22 2018 -0400 |
[ |
@@ -0,0 +1,40 @@ +<tool id="plot_trend" name="Plot abundance" version="0.1"> + <description>with trend line</description> + <requirements> + <requirement type="package" version="3.1_131">r-nlme</requirement> + <requirement type="package" version="7.3_48">r-mass</requirement> + <requirement type="package" version="0.9.10">xorg-libxrender</requirement> + <requirement type="package" version="1.1.2">xorg-libsm</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + Rscript '$__tool_directory__/plot_trend.R' '$input1' '$input2' '$output' ]]> + </command> + <inputs> + <param format="tabular" name="input1" type="data" label="File generated by the ab_index tool"/> + <param format="rdata" name="input2" type="data" label="gls model" help="Rdata File"/> + </inputs> + <outputs> + <data format="png" name="output" from_work_dir="output-plot-trend.png" /> + </outputs> + <tests> + <test> + <param name="input1" value="data_index.tabular"/> + <param name="input2" value="gls-adju_rda.rda"/> + <output name="output" value="trend.png"/> + </test> + </tests> + <help><![CDATA[ + +.. class:: infomark + +========================== +Plot abundance trend +========================== + +This tool is an implementation of the plot_trend function from `RegionalGAM package: https://github.com/RetoSchmucki/regionalGAM/ +This function plot abundance and add a trend line. + ]]></help> + <citations> + <citation type="doi">10.1111/1365-2664.12561</citation> + </citations> +</tool> |