Example #1
0
 def makeSmoothed(self, window_len = 121, sd = 20):
     self.smoothed_vals = smooth(self.vals, window_len, window = "gaussian", sd = sd,
                        mode = "same", norm = True) 
     self.smoothed_lower = smooth(self.lower_bound, window_len, window = "gaussian", sd = sd,
                        mode = "same", norm = True)
     self.smoothed_upper = smooth(self.upper_bound, window_len, window = "gaussian", sd = sd,
                        mode = "same", norm = True)
Example #2
0
 def smooth_track(self, window_len, window="flat", sd=None, mode="valid", norm=True):
     """ smoothing of track"""
     self.smoothed = True
     self.vals = smooth(self.vals, window_len, window=window, sd=sd, mode=mode, norm=norm)
     if mode == "valid":
         self.start = self.start + window_len / 2
         self.end = self.end - window_len / 2
Example #3
0
 def smooth_track(self,  window_len, window='flat', sd = None,
                  mode = 'valid', norm = True):
     """ smoothing of track"""
     self.smoothed=True
     self.vals = smooth(self.vals, window_len, window = window, sd = sd,
                        mode = mode, norm = norm)
     if mode == 'valid':
         self.start = self.start + window_len/2
         self.end = self.end - window_len/2
Example #4
0
 def getLocalbias(self, windowlen = 55, window = "flat"):
     """Make bias a reflection of score in a given window"""
     if self.log:
         ebias = np.exp(self.vals)
     else:
         ebias = self.vals
     smoothed = smooth(ebias,windowlen, window, norm = False)
     flank = windowlen/2
     if self.log:
         self.vals = np.log(ebias[flank:-flank]/(smoothed-ebias[flank:-flank]))
     else:
         self.vals = ebias[flank:-flank]/(smoothed-ebias[flank:-flank])
     self.start = self.start + flank
     self.end = self.end - flank
Example #5
0
 def calculateCoverageSmooth(self,mat,lower,upper,window_len,sd):
     """Compute coverage of fragment centers using gaussia window"""
     offset=self.start-mat.start-(window_len/2)
     if offset<0:
         raise Exception("Insufficient flanking region on \
                 mat to calculate coverage with desired window")
     lower=lower-mat.lower
     upper=upper-mat.lower
     if offset!=0:
         collapsed = np.sum(mat.mat[lower:upper,offset:-offset],axis=0)
     else:
         collapsed = np.sum(mat.mat[lower:upper,],axis=0)
     self.vals = smooth(collapsed, window_len, sd= sd, window="gaussian",
                         mode='valid',norm=False)
Example #6
0
 def getLocalbias(self, windowlen = 55, window = "flat"):
     """Make bias a reflection of score in a given window"""
     if self.log:
         ebias = np.exp(self.vals)
     else:
         ebias = self.vals
     smoothed = smooth(ebias,windowlen, window, norm = False)
     flank = windowlen/2
     if self.log:
         self.vals = np.log(ebias[flank:-flank]/(smoothed-ebias[flank:-flank]))
     else:
         self.vals = ebias[flank:-flank]/(smoothed-ebias[flank:-flank])
     self.start = self.start + flank
     self.end = self.end - flank
Example #7
0
 def calculateCoverageSmooth(self, mat, lower, upper, window_len, sd):
     """Compute coverage of fragment centers using gaussia window"""
     offset = self.start - mat.start - (window_len / 2)
     if offset < 0:
         raise Exception(
             "Insufficient flanking region on \
                 mat to calculate coverage with desired window"
         )
     lower = lower - mat.lower
     upper = upper - mat.lower
     if offset != 0:
         collapsed = np.sum(mat.mat[lower:upper, offset:-offset], axis=0)
     else:
         collapsed = np.sum(mat.mat[lower:upper,], axis=0)
     self.vals = smooth(collapsed, window_len, sd=sd, window="gaussian", mode="valid", norm=False)