Exemple #1
0
 def positioning(self, wig, rd=None):
     '''
     Description:
         Calculate nucleosome (summit) positioning score and P value.
     
     Parameter:
         wig: a Wig class instance containing nucleosome occupancy data
         rd: the half size of the region flanking each summit used to calculate nucleosome fuzziness
     
     Value:
         None
     '''
     from rpy2.robjects import r, FloatVector
     from random import shuffle
     from functions import log10fuztest
     #ct=r('''function(x){return(chisq.test(x)$p.value)}''')
     #xx=numpy.array(range(rd*2))
     #ftest=r('''function(x,y){return(var.test(x,y)$p.value)}''')
     smt = self
     step = wig.step
     #rd=rd/step+1
     #tarray=numpy.array(0.0)
     #tarray.resize(rd*2,refcheck=0)
     for cr in smt.data:
         print cr
         ps = smt.data[cr]['p']
         s, ppos = numpy.array([0.0] * rd * 2), numpy.array([0.0] * rd * 2)
         lth = ps.size
         s.resize(lth, refcheck=0)
         ppos.resize(lth, refcheck=0)
         if wig.data.has_key(cr):  #add by kaifu on Jan 27, 2014
             w = wig.data[cr]
             i = 0
             while (i < lth):
                 temp = log10fuztest(pc=ps[i],
                                     pt=ps[i],
                                     cr=cr,
                                     cwig=wig,
                                     twig=None,
                                     rd=rd)
                 ppos[i], s[i] = temp
                 i += 1
         smt.data[cr]['s'] = s
         smt.data[cr]['ppos'] = ppos
Exemple #2
0
 def positioning(self,wig,rd=None):
     '''
     Description:
         Calculate nucleosome (summit) positioning score and P value.
     
     Parameter:
         wig: a Wig class instance containing nucleosome occupancy data
         rd: the half size of the region flanking each summit used to calculate nucleosome fuzziness
     
     Value:
         None
     '''
     from rpy2.robjects import r, FloatVector
     from random import shuffle
     from functions import log10fuztest
     #ct=r('''function(x){return(chisq.test(x)$p.value)}''')
     #xx=numpy.array(range(rd*2))
     #ftest=r('''function(x,y){return(var.test(x,y)$p.value)}''')
     smt=self
     step=wig.step
     #rd=rd/step+1
     #tarray=numpy.array(0.0)
     #tarray.resize(rd*2,refcheck=0)
     for cr in smt.data:
         print cr
         ps=smt.data[cr]['p']
         s,ppos=numpy.array([0.0]*rd*2),numpy.array([0.0]*rd*2)
         lth=ps.size
         s.resize(lth,refcheck=0)
         ppos.resize(lth,refcheck=0)
         if wig.data.has_key(cr):#add by kaifu on Jan 27, 2014
             w=wig.data[cr]
             i=0
             while(i<lth):
                 temp=log10fuztest(pc=ps[i],pt=ps[i],cr=cr,cwig=wig,twig=None,rd=rd)
                 ppos[i],s[i]=temp
                 i+=1
         smt.data[cr]['s']=s
         smt.data[cr]['ppos']=ppos