Example #1
0
    def gene_significant_mutated(self, iFile, samplePositionList):
        total_length = 0
        total_num = 0
        dict1 = dict()
        inFile = open("hg19_max_coding_length")
        for line in inFile:
            line = line.rstrip()
            fields = line.split("\t")
            dict1[fields[0]] = int(fields[1])
        inFile.close()

        inFile = open(iFile)
        for line in inFile:
            line = line.rstrip()
            fields = line.split("\t")
            gn = sum([int(fields[x]) for x in samplePositionList])
            gl = dict1[fields[0]]
            if gn > 0:
                total_length += gl
                total_num += gn
        inFile.close()
        # print(total_length)
        # print(total_num)

        ps = PyStats()
        inFile = open(iFile)
        ouFile = open(iFile + ".fisher_test", "w")
        for line in inFile:
            line = line.rstrip()
            fields = line.split("\t")
            gs = sum([int(fields[x]) for x in samplePositionList])
            gl = dict1[fields[0]]
            f = ps.fisher_test([gs, gl, total_num, total_length])
            ouFile.write(str(f) + "\t" + line + "\n")
        inFile.close()
        ouFile.close()
        ps.fdr_adjust_file(iFile + ".fisher_test")
Example #2
0
    def gene_significant_mutated(self, iFile, samplePositionList):
        total_length = 0
        total_num = 0
        dict1 = dict()
        inFile = open('hg19_max_coding_length')
        for line in inFile:
            line = line.rstrip()
            fields = line.split('\t')
            dict1[fields[0]] = int(fields[1])
        inFile.close()

        inFile = open(iFile)
        for line in inFile:
            line = line.rstrip()
            fields = line.split('\t')
            gn = sum([int(fields[x]) for x in samplePositionList])
            gl = dict1[fields[0]]
            if gn > 0:
                total_length += gl
                total_num += gn
        inFile.close()
        #print(total_length)
        #print(total_num)

        ps = PyStats()
        inFile = open(iFile)
        ouFile = open(iFile + '.fisher_test', 'w')
        for line in inFile:
            line = line.rstrip()
            fields = line.split('\t')
            gs = sum([int(fields[x]) for x in samplePositionList])
            gl = dict1[fields[0]]
            f = ps.fisher_test([gs, gl, total_num, total_length])
            ouFile.write(str(f) + '\t' + line + '\n')
        inFile.close()
        ouFile.close()
        ps.fdr_adjust_file(iFile + '.fisher_test')
Example #3
0
 def gene_two_group_ranksum_test(self, iFile, aList, bList):
     ps = PyStats()
     ps.ranksum_test_file(iFile, aList, bList)
Example #4
0
 def gene_two_group_ranksum_test(self, iFile, aList, bList):
     ps = PyStats()
     ps.ranksum_test_file(iFile, aList, bList)