Skip to content

Commit

Permalink
bug fixes in cell filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Obermayer committed Sep 20, 2021
1 parent 1677836 commit 96a3667
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
History
=======

------
v0.8.6
------

- bug fixes for cell filtering

------
v0.8.5
------
Expand Down
5 changes: 3 additions & 2 deletions requirements/notesting.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Base requirements

# botocore and pyOpenSSL to avoid incompatibility errors
botocore
botocore==1.20.106
pyOpenSSL

# Dash and friends.
Expand Down Expand Up @@ -38,8 +38,9 @@ requests
htmllistparse
# TODO: we need an fs[._]irods
# Access to files through iRODS.
python-irodsclient
python-irodsclient >= 1.0.0

# Documentation
sphinx
sphinx-rtd-theme
docutils < 0.17
10 changes: 8 additions & 2 deletions scelvis/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import dash_html_components as html
from dash.dependencies import Input, Output, State
import pandas as pd
import numpy as np
from logzero import logger
from werkzeug.utils import secure_filename

Expand Down Expand Up @@ -606,6 +607,7 @@ def update_filter_cells_controls(
+ hidden_rangeslider
)

attribute = None
if ctx.triggered and "meta" in ctx.triggered[0]["prop_id"]:
token = "meta"
attribute = meta_attribute
Expand Down Expand Up @@ -661,8 +663,12 @@ def update_filter_cells_controls(
+ hidden_rangeslider
)
else:
range_min = values.dropna().min()
range_max = values.dropna().max()
if np.any(np.isnan(values)):
range_min = values.dropna().min()
range_max = values.dropna().max()
else:
range_min = values.min()
range_max = values.max()
if attribute in filters:
val_min = filters[attribute][0]
val_max = filters[attribute][1]
Expand Down
10 changes: 3 additions & 7 deletions scelvis/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,11 @@ def _load_expression(self, coords, annotation, markers):
"cannot find expression data at %s or %s" % (expression_tsv, expression_mtx)
)
logger.info("Combining data")
ad = sc.AnnData(
X=X,
obs=annotation.loc[cells],
var=pd.DataFrame([], index=genes),
)
coords_types = set([re.sub('[-_][0-9]*$','',c).upper() for c in coords.columns])
ad = sc.AnnData(X=X, obs=annotation.loc[cells], var=pd.DataFrame([], index=genes))
coords_types = set([re.sub("[-_][0-9]*$", "", c).upper() for c in coords.columns])
for ct in coords_types:
ct_cols = [c for c in coords.columns if ct in c.upper()]
ad.obsm['X_'+ct] = coords.loc[cells, ct_cols].values
ad.obsm["X_" + ct] = coords.loc[cells, ct_cols].values
for col in markers.columns:
ad.uns["marker_" + col] = markers[col].values

Expand Down
11 changes: 7 additions & 4 deletions scelvis/ui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,13 @@ def auto_tick(data_range, max_tick=10, tf_inside=False):
tick_size_nmlz = list_tick_size_nmlz[i - 1]
break
tick_size = tick_size_nmlz * scale # tick sizse for the original data
ticks = (
np.unique(np.arange(data_range[0] / tick_size, data_range[1] / tick_size).round())
* tick_size
) # list of ticks
if tick_size > 0:
ticks = (
np.unique(np.arange(data_range[0] / tick_size, data_range[1] / tick_size).round())
* tick_size
) # list of ticks
else:
ticks = data_range[0].round()

if tf_inside: # if only allow ticks within the given range
ticks = ticks[(ticks >= data_range[0]) * (ticks <= data_range[1])]
Expand Down

0 comments on commit 96a3667

Please sign in to comment.