Skip to content

Commit

Permalink
Add getPolyAStandardizedSignal
Browse files Browse the repository at this point in the history
  • Loading branch information
JannesSP committed Mar 5, 2024
1 parent b84fd67 commit a693198
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions read5_ont/AbstractFileReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,32 @@ def getZNormSignal(self, readid : str, mode : str = 'median') -> np.ndarray:
'''
return (self.getpASignal(readid) - self.getShift(readid, mode)) / self.getScale(readid, mode)

def getPolyAStandardizedSignal(self, readid : str, polyAstart : int, polyAend : int) -> np.ndarray:
'''
Standardize the read signal of the provided read with the polyA.
This function uses the median and mad to standardize the read with the polyA signal.
After standardization the polyA signal will have a mean of 108.901413 and a stdev of 2.676522.
Parameter
---------
readid : str
polyAstart : int
included starting index of the polyA signal in the read
polyAend : int
excluded ending index of the polyA signal in the read
Returns
-------
standardizedSignal : np.ndarray
polyA standardized read signal
'''
stdPolyAMean = 108.901413
stdPolyAStdev = 2.676522
polyAsignal = self.getpASignal(readid)[polyAstart : polyAend]
polyAmedian = np.median(polyAsignal)
polyAmad = 1.4826 * np.median(np.abs(polyAsignal - polyAmedian))
return ((self.getpASignal(readid) - polyAmedian) / polyAmad) * stdPolyAStdev + stdPolyAMean

def getStartTimeInMinutes(self, readid) -> float:
'''
Parameter
Expand Down

0 comments on commit a693198

Please sign in to comment.