Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug in filterLowCounts #78

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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__ = 'abea@arcinstitute.org' # "abarbiology@gmail.com"
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
Loading