1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/a3ef80ad2535/ changeset: a3ef80ad2535 user: guru date: 2011-06-27 21:44:59 summary: Rounded the outputs of regression to 10 significant digits. affected #: 2 files (631 bytes) --- a/test-data/regr_out.tabular Mon Jun 27 11:20:04 2011 -0400 +++ b/test-data/regr_out.tabular Mon Jun 27 15:44:59 2011 -0400 @@ -1,10 +1,10 @@ Y-intercept -28.1169126094 -p-value (Y-intercept) 0.294263204753 -Slope (c1) 5.74713412453 -p-value (c1) 0.0017328770415 -Slope (c2) 0.904274537427 -p-value (c2) 0.114667546826 -R-squared 0.938805439971 -Adjusted R-squared 0.921321279962 -F-statistic {'dendf': 7.0, 'value': 53.694626422997381, 'numdf': 2.0} -Sigma 7.43450071131 +p-value (Y-intercept) 0.2942632048 +Slope (c1) 5.7471341245 +p-value (c1) 0.001732877 +Slope (c2) 0.9042745374 +p-value (c2) 0.1146675468 +R-squared 0.93881 +Adjusted R-squared 0.92132 +F-statistic {'dendf': 7.0, 'value': '53.69463', 'numdf': 2.0} +Sigma 7.4345007113 --- a/tools/regVariation/linear_regression.py Mon Jun 27 11:20:04 2011 -0400 +++ b/tools/regVariation/linear_regression.py Mon Jun 27 15:44:59 2011 -0400 @@ -68,7 +68,6 @@ coeffs=linear_model.as_py()['coefficients'] yintercept= coeffs['(Intercept)'] -print >>fout, "Y-intercept\t%s" %(yintercept) summary = r.summary(linear_model) co = summary.get('coefficients', 'NA') @@ -76,15 +75,23 @@ if len(co) != len(x_vals)+1: stop_err("Stopped performing linear regression on the input data, since one of the predictor columns contains only non-numeric or invalid values.") """ -print >>fout, "p-value (Y-intercept)\t%s" %(co[0][3]) + +try: + yintercept = r.round(float(yintercept), digits=10) + pvaly = r.round(float(co[0][3]), digits=10) +except: + pass + +print >>fout, "Y-intercept\t%s" %(yintercept) +print >>fout, "p-value (Y-intercept)\t%s" %(pvaly) if len(x_vals) == 1: #Simple linear regression case with 1 predictor variable try: - slope = coeffs['x'] + slope = r.round(float(coeffs['x']), digits=10) except: slope = 'NA' try: - pval = co[1][3] + pval = r.round(float(co[1][3]), digits=10) except: pval = 'NA' print >>fout, "Slope (c%d)\t%s" %(x_cols[0]+1,slope) @@ -92,18 +99,36 @@ else: #Multiple regression case with >1 predictors ind=1 while ind < len(coeffs.keys()): - print >>fout, "Slope (c%d)\t%s" %(x_cols[ind-1]+1,coeffs['x'+str(ind)]) try: - pval = co[ind][3] + slope = r.round(float(coeffs['x'+str(ind)]), digits=10) + except: + slope = 'NA' + print >>fout, "Slope (c%d)\t%s" %(x_cols[ind-1]+1,slope) + try: + pval = r.round(float(co[ind][3]), digits=10) except: pval = 'NA' print >>fout, "p-value (c%d)\t%s" %(x_cols[ind-1]+1,pval) ind+=1 -print >>fout, "R-squared\t%s" %(summary.get('r.squared','NA')) -print >>fout, "Adjusted R-squared\t%s" %(summary.get('adj.r.squared','NA')) -print >>fout, "F-statistic\t%s" %(summary.get('fstatistic','NA')) -print >>fout, "Sigma\t%s" %(summary.get('sigma','NA')) +rsq = summary.get('r.squared','NA') +adjrsq = summary.get('adj.r.squared','NA') +fstat = summary.get('fstatistic','NA') +sigma = summary.get('sigma','NA') + +try: + rsq = r.round(float(rsq), digits=5) + adjrsq = r.round(float(adjrsq), digits=5) + fval = r.round(fstat['value'], digits=5) + fstat['value'] = str(fval) + sigma = r.round(float(sigma), digits=10) +except: + pass + +print >>fout, "R-squared\t%s" %(rsq) +print >>fout, "Adjusted R-squared\t%s" %(adjrsq) +print >>fout, "F-statistic\t%s" %(fstat) +print >>fout, "Sigma\t%s" %(sigma) r.pdf( outfile2, 8, 8 ) if len(x_vals) == 1: #Simple linear regression case with 1 predictor variable Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.