Example #1
0
            lpromotorMeth, rpromotorMeth, relativePromotorMethDiff, promotorMethDiff, promotorPvalue = methPercentageDiff(
                methdata.getValuesInRange(genedata[ensembl].chr, promotorstart,
                                          promotorstop))
            lgenebodyMeth, rgenebodyMeth, relativeGeneBodyMethDiff, geneBodyMethDiff, geneBodyPvalue = methPercentageDiff(
                methdata.getValuesInRange(genedata[ensembl].chr,
                                          genedata[ensembl].start,
                                          genedata[ensembl].end))
            ltssMeth, rtssMeth, relativeTssMethDiff, tssMethDiff, tssPvalue = methPercentageDiff(
                methdata.getValuesInRange(
                    genedata[ensembl].chr,
                    genedata[ensembl].start - tsssize / 2,
                    genedata[ensembl].start + tsssize / 2))

            promotorClassification, promotorCpGRatio = classifyCpGContent(
                genome.getSequence(genedata[ensembl].chr, promotorstart,
                                   promotorstop).upper())
            geneBodyClassification, genebodyCpGRatio = classifyCpGContent(
                genome.getSequence(genedata[ensembl].chr,
                                   genedata[ensembl].start,
                                   genedata[ensembl].end).upper())
            tssClassification, tssCpGRatio = classifyCpGContent(
                genome.getSequence(genedata[ensembl].chr,
                                   genedata[ensembl].start - tsssize / 2,
                                   genedata[ensembl].start +
                                   tsssize / 2).upper())

            row = [ensembl, genedata[ensembl].name, "1" if incpg else "0"]

            if exprfile != None:
                row.extend([logFC, "1" if sig else "0"])
                            try:
                                chi2Tots[s][0].append(resultsDict[i][0])
                                chi2Tots[s][1].append(resultsDict[i][1])
                            except:
                                chi2Tots[s] = [[resultsDict[i][0]], [resultsDict[i][1]]]
                  
                for s in replicateTypes.split(","):
                    pooledMeths = chi2Tots[s]
                    chi2, p = methChiSquared(pooledMeths)
                    output.append(p)

                for s in replicateTypes.split(","):
                    for i in replicateTypes.split(","):
                        if s != i:
                            output.append(str(methGetP(pooledTotals[s], pooledTotals[i])))  
                            output.append(str(methPercentageDiff(pooledTotals[s], pooledTotals[i]))) 
                             
                for x in finalReplicateAnnotators:
                    firstRep = resultsDict[x]
                    for y in finalReplicateAnnotators:
                        if y != x:
                            secondRep = resultsDict[y]
                            output.append(str(methGetP(firstRep, secondRep)))  
                            output.append(str(methPercentageDiff(firstRep, secondRep)))  

                seq = genome.getSequence(chrm,start,stop).upper()
                classification, cpgs = classifyCpGContent(seq)
                output.append(cpgs)
                outputcsv.writerow(output)
        except sequence.genome.UnknownChromosomeException:
            continue