Skip to content

Commit

Permalink
Merge pull request #78 from ArcInstitute/dev
Browse files Browse the repository at this point in the history
fix a bug in `filterLowCounts`
  • Loading branch information
abearab authored Jul 15, 2024
2 parents 4eb855c + 31b4063 commit 77c097a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion screenpro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
from .ngs import GuideCounter
from .assays import PooledScreens, GImaps

__version__ = "0.4.4"
__version__ = "0.4.5"
__author__ = "Abe Arab"
__email__ = '[email protected]' # "[email protected]"
2 changes: 1 addition & 1 deletion screenpro/assays.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _calculateGrowthFactor(self, untreated, treated, db_rate_col):

return out

def filterLowCounts(self, filter_type='sum', minimum_reads=50):
def filterLowCounts(self, filter_type='all', minimum_reads=50):
"""
Filter low counts in adata.X
"""
Expand Down
8 changes: 3 additions & 5 deletions screenpro/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def findLowCounts(adata, filter_type, minimum_reads, verbose=True):
Parameters:
adata (AnnData): AnnData object containing the counts to be filtered.
filter_type (str): specify the filter type. Possible values are: 'either', 'all', or 'sum'.
filter_type (str): specify the filter type. Possible values are: 'all', or 'sum'.
minimum_reads (int): minimum number of reads.
verbose (bool): print the number of removed variables. Default is True.
Expand All @@ -18,14 +18,12 @@ def findLowCounts(adata, filter_type, minimum_reads, verbose=True):
"""
count_bin = adata.X >= minimum_reads

if filter_type == 'either':
out = adata[:, ~(~count_bin.all(axis=0))].copy()
elif filter_type == 'all':
if filter_type == 'all':
out = adata[:, count_bin.all(axis=0)].copy()
elif filter_type == 'sum':
out = adata[:, adata.to_df().sum(axis=0) >= minimum_reads].copy()
else:
raise ValueError(f'filter_type "{filter_type}" not recognized. Use "either", "all", or "sum".')
raise ValueError(f'filter_type "{filter_type}" not recognized. Use "all", or "sum".')

if verbose:
n_removed = adata.shape[1] - out.shape[1]
Expand Down

0 comments on commit 77c097a

Please sign in to comment.