-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow specific pseudocount for lfc calculation
- Loading branch information
Showing
3 changed files
with
25 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import numpy as np | ||
|
||
|
||
def _read_count_normalize(X): | ||
def _read_count_normalize(X, pseudocount: int = 1): | ||
"""Read depth normalization by sample. Assumes samples are columns and guides are rows.""" | ||
|
||
return (X / np.nansum(X, axis=0)) * 1e6 | ||
return (X / np.nansum(X+pseudocount, axis=0)) * 1e6 | ||
|
||
|
||
def _log_transform_read_count(X): | ||
def _log_transform_read_count(X, pseudocount: int = 1): | ||
"""""" | ||
return np.log2(X + 1) | ||
return np.log2(X + pseudocount) | ||
|
||
|
||
def _log_normalize_read_count(X): | ||
def _log_normalize_read_count(X, pseudocount:int = 1): | ||
"""Following the protocol written clearly, here: | ||
https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0170445#sec002 | ||
(see Methods). | ||
""" | ||
|
||
X_read_norm = _read_count_normalize(X) | ||
X_read_norm = _read_count_normalize(X, pseudocount) | ||
X_log_read_norm = _log_transform_read_count(X_read_norm) | ||
|
||
return X_log_read_norm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters