diff plot-trend.R @ 0:b416a363a2d5 draft default tip

planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/regionalgam commit ffe42225fff8992501b743ebe2c78e50fddc4a4e
author ecology
date Thu, 20 Jun 2019 04:03:31 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plot-trend.R	Thu Jun 20 04:03:31 2019 -0400
@@ -0,0 +1,23 @@
+#!/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")
+invisible(dev.off())
+
+d<-data.frame(year,col.index)
+colnames(d)<-c("year","collated index")
+write.table(d,"s_trend.tsv",sep="	",row.names=FALSE)
+
+cat("Show trend line on abundance plot")