Example: ./script.py <infile> 4,5,8,9,3,6,7,10 <outfile>""" exit(1) normalised_data = dict() f = open(fn) for row in f: l = row.strip().split('\t') if l[0] not in normalised_data: normalised_data[l[0]] = [map(float,l[1:])] else: normalised_data[l[0]] += [map(float,l[1:])] f.close() # averaging normalised_data2 = dict() for e in normalised_data: if len(normalised_data[e]) > 1: no = len(normalised_data[e]) # the number of probesets normalised_data2[e] = [sum([normalised_data[e][i][j] for i in xrange(no)])/no for j in xrange(8)] else: normalised_data2[e] = normalised_data[e][0] #g = open(ofn,'w') #for e in normalised_data2: # print >> g,"\t".join([e]+map(str,normalised_data2[e])) #g.close() test_results = statistical_test(normalised_data2,cascon,test_type="unpaired t-test") dict_to_file(test_results,ofn)
#!/home/paulk/software/bin/python from __future__ import division from sys import argv, exit, stderr from scipy import * from scipy import stats from key_functions import statistical_test, dict_to_file try: fn = argv[1] ofn = argv[2] except IndexError: print >> stderr, """\ Script to perform a statistical test on columns of data one row at a time. Performs an unpaired t-test by default. Modify to add tests. Usage:./script.py <infile> <outfile>""" exit(1) cascon = [4, 5, 8, 9, 3, 6, 7, 10] f = open(fn) normalised_data = dict() for row in f: l = row.strip().split("\t") normalised_data[l[0], l[1]] = map(float, l[2:]) f.close() test_results = statistical_test(normalised_data, cascon) dict_to_file(test_results, ofn)
#!/home/paulk/software/bin/python from __future__ import division from sys import argv, exit, stderr from scipy import * from scipy import stats from key_functions import statistical_test, dict_to_file try: fn = argv[1] ofn = argv[2] except IndexError: print >> stderr, """\ Script to perform a statistical test on columns of data one row at a time. Performs an unpaired t-test by default. Modify to add tests. Usage:./script.py <infile> <outfile>""" exit(1) cascon = [4, 5, 8, 9, 3, 6, 7, 10] f = open(fn) normalised_data = dict() for row in f: l = row.strip().split('\t') normalised_data[l[0], l[1]] = map(float, l[2:]) f.close() test_results = statistical_test(normalised_data, cascon) dict_to_file(test_results, ofn)
f = open(fn) for row in f: l = row.strip().split('\t') if l[0] not in normalised_data: normalised_data[l[0]] = [map(float, l[1:])] else: normalised_data[l[0]] += [map(float, l[1:])] f.close() # averaging normalised_data2 = dict() for e in normalised_data: if len(normalised_data[e]) > 1: no = len(normalised_data[e]) # the number of probesets normalised_data2[e] = [ sum([normalised_data[e][i][j] for i in xrange(no)]) / no for j in xrange(8) ] else: normalised_data2[e] = normalised_data[e][0] #g = open(ofn,'w') #for e in normalised_data2: # print >> g,"\t".join([e]+map(str,normalised_data2[e])) #g.close() test_results = statistical_test(normalised_data2, cascon, test_type="unpaired t-test") dict_to_file(test_results, ofn)