Skip to content

Commit c72e214

Browse files
committed
fix value_type_bug
1 parent 5e8715d commit c72e214

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ ignore =
5555
B902
5656
B023
5757
D401
58+
B028
5859
exclude = .git,__pycache__,build,docs/_build,dist,ALLCools/sandbox,
5960
per-file-ignores =
6061
tests/*: D

ALLCools/mcds/cool_ds.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,11 @@ def matrix(
369369
if samples is not None:
370370
sel_dict[self.sample_dim] = samples
371371
if value_type is not None:
372-
_da_name = f"{da_name}_value_type"
373-
if _da_name not in self.data_vars:
374-
_da_name = "value_type"
375-
sel_dict[_da_name] = value_type
372+
if da_name not in self.data_vars:
373+
value_type_dim_name = "value_type"
374+
else:
375+
value_type_dim_name = f"{da_name}_value_type"
376+
sel_dict[value_type_dim_name] = value_type
376377
if len(sel_dict) > 0:
377378
sample_da = self.sel(sel_dict)[da_name]
378379
else:

ALLCools/mcds/mcds.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,6 @@ def calculate_hvf_svr(
662662
self, mc_type=None, var_dim=None, obs_dim=None, n_top_feature=5000, da_name=None, da_suffix="frac", plot=True
663663
):
664664
"""Calculate the highly variable features (hvf) with the Support Vector Regression model."""
665-
import plotly.graph_objects as go
666665
from sklearn.svm import SVR
667666

668667
obs_dim = self._verify_dim(obs_dim, mode="obs")
@@ -736,6 +735,13 @@ def calculate_hvf_svr(
736735
f"({(selected_feature_index.size / judge.size * 100):.1f}%)"
737736
)
738737

738+
if plot:
739+
try:
740+
import plotly.graph_objects as go
741+
except ImportError:
742+
print("Please install plotly to enable plotting.")
743+
plot = False
744+
739745
if plot:
740746
if hvf_df.shape[0] > 5000:
741747
plot_data = hvf_df.sample(5000)

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ analysis = [
4444
"leidenalg",
4545
"networkx",
4646
"opentsne",
47-
"plotly",
4847
"pynndescent",
4948
"scanpy",
5049
"scikit-learn",

0 commit comments

Comments
 (0)