Commit 591fa527 authored by panos's avatar panos Committed by Jérome Perrin

first version of output analysis included

parent 21c2ff80
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 16 Nov 2013
@author: Panos
'''
from rpy2.robjects.packages import importr
from rpy2 import robjects
MASS= importr('MASS')
class Intervals:
def ConfidIntervals(self,data,p):
data=robjects.FloatVector(data)
alpha=1-p
rsqrt=robjects.r['sqrt']
rsd=robjects.r['sd']
rmean=robjects.r['mean']
t=len(data)
n=rsqrt(t)
b=rsd(data)
rqt=robjects.r['qt']
q=rqt((1-(alpha/2)),t-1)
m=rmean(data)
me=q[0]*(b[0]/n[0])
lo=m[0]-me
up=m[0]+me
l=[lo,up]
return l
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 16 Dec 2013
@author: Panos
'''
from rpy2 import robjects
class Graphs:
def Plots(self,data, fileName="plotChart.jpg"):
data=robjects.FloatVector(data)
rplot=robjects.r['plot']
rdev=robjects.r['dev.off']
rjpeg=robjects.r['jpeg']
output=rjpeg(fileName)
rplot(data, type="o", col="blue")
rdev
return output
def ScatterPlot(self,data1,data2, fileName="scatterplot.jpg"):
data1=robjects.FloatVector(data1)
data2=robjects.FloatVector(data2)
rplot=robjects.r['plot']
rdev=robjects.r['dev.off']
rjpeg=robjects.r['jpeg']
output=rjpeg(fileName)
rplot(data1,data2, type="o", col="red")
rdev
return output
def Pie(self, data1, fileName="pieChart.jpg"):
data1=robjects.FloatVector(data1)
rpaste=robjects.r['paste']
rround=robjects.r['round']
rsum=robjects.r['sum']
rpie=robjects.r['pie']
rdev=robjects.r['dev.off']
colors=robjects.StrVector(["white","grey70","grey90","grey50","grey60","black"])
s=rsum(data1)
d_labels=[0]*(len(data1))
i=0
while i<len(data1):
d_labels[i]=((rround((data1[i]/s[0])*100,1)))
i+=1
d_labels=rpaste(d_labels,"%",sep="")
rjpeg=robjects.r['jpeg']
export=rjpeg(fileName)
rpie(data1,main="Data",col=colors,labels=d_labels,cex=0.8)
rdev
return export
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 14 Nov 2013
@author: Panos
'''
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
MASS= importr('MASS')
class BasicStatisticalMeasures:
def length(self, data):
data=robjects.FloatVector(data)
rlength = robjects.r['length']
return rlength(data)
def summary(self, data):
data=robjects.FloatVector(data)
rsummary = robjects.r['summary']
return rsummary(data)
def quantile(self,data):
data=robjects.FloatVector(data)
rquantile = robjects.r['quantile']
return rquantile(data)
def frequency(self,data):
data=robjects.FloatVector(data)
rtable= robjects.r['table']
return rtable(data)
def mean (self, data):
data=robjects.FloatVector(data)
rmean = robjects.r['mean']
return rmean(data)
def var (self, data):
data=robjects.FloatVector(data)
rvar = robjects.r['var']
return rvar(data)
def sd (self, data):
data=robjects.FloatVector(data)
rsd = robjects.r['sd']
return rsd(data)
def range (self, data):
data=robjects.FloatVector(data)
rrange = robjects.r['range']
return rrange(data)
def IQR (self, data):
data=robjects.FloatVector(data)
rIQR = robjects.r['IQR']
return rIQR(data)
def all(self, data):
data=robjects.FloatVector(data)
print 'The length of the data set is:', self.length(data)[0]
print 'The summary is:', self.summary(data)
print 'The quartiles and percentiles of the data set are:', self.quantile(data)
print 'The frequency of the datapoints are:', self.frequency(data)
print 'The mean value is:', self.mean(data)[0]
print 'The standard deviation is:', self.sd(data)[0]
print 'The variance is:', self.var(data)[0]
print 'The range is:', self.range(data)[0]
print 'The Interquartile Range is:', self.IQR(data)[0]
\ No newline at end of file
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment