Skip to content

Commit

Permalink
Merge branch 'release/v1.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
pinin4fjords committed Sep 24, 2021
2 parents 1f18ae0 + bd84ec9 commit 05f3003
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion scanpy_scripts/cmd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ def _add_options(func):
return func
return _add_options

def _fix_booleans(df):
for var in df.columns:
if (df[var].dtype.kind == 'O' and
df[var].dtype.name == 'object' and
set(pd.Categorical(df[var])).issubset(set(['True', 'False', 'nan']))
):
d = {'False': True, 'False': False, 'nan': False}
df[var] = df[var].map(d).astype(bool)
return(df)

def _read_obj(input_obj, input_format='anndata', **kwargs):
if input_format == 'anndata':
Expand All @@ -81,8 +90,10 @@ def _read_obj(input_obj, input_format='anndata', **kwargs):
else:
raise NotImplementedError(
'Unsupported input format: {}'.format(input_format))
return adata
adata.var = _fix_booleans(adata.var)
adata.obs = _fix_booleans(adata.obs)

return adata

def _write_obj(
adata,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='scanpy-scripts',
version='1.1.1',
version='1.1.2',
author='nh3',
author_email='[email protected]',
description='Scripts for using scanpy from the command line',
Expand Down

0 comments on commit 05f3003

Please sign in to comment.