diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 96d95547..2f663d72 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: - id: autopep8 args: [-i] - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/asottile/yesqa diff --git a/VERSION.txt b/VERSION.txt index 781dcb07..65087b4f 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -1.1.3 +1.1.4 diff --git a/docs/source/api.rst b/docs/source/api.rst index 17e1eca1..60c9efa2 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -183,6 +183,7 @@ Some parts of metrics can be used individually, these are listed below. .. autosummary:: :toctree: api/ + cluster_optimal_resolution lisi_graph pcr pc_regression diff --git a/scib/_package_tools.py b/scib/_package_tools.py index 05e4509d..2744e951 100644 --- a/scib/_package_tools.py +++ b/scib/_package_tools.py @@ -16,6 +16,7 @@ def wrapper(*args, **kwargs): f"Mixed case function naming is deprecated for '{name}'. " f"Please use '{func.__name__}' instead.", DeprecationWarning, + stacklevel=2, ) return func(*args, **kwargs) diff --git a/scib/integration.py b/scib/integration.py index a2f8b237..b7afe37e 100644 --- a/scib/integration.py +++ b/scib/integration.py @@ -418,7 +418,7 @@ def combat(adata, batch): return adata_int -def desc(adata, batch, res=0.8, ncores=None, tmp_dir=None, use_gpu=False): +def desc(adata, batch, res=0.8, ncores=None, tmp_dir=None, use_gpu=False, gpu_id=None): """DESC wrapper function Based on `desc package `_ version 2.0.3. @@ -457,6 +457,7 @@ def desc(adata, batch, res=0.8, ncores=None, tmp_dir=None, use_gpu=False): save_dir=tmp_dir, do_tsne=False, use_GPU=use_gpu, + GPU_id=gpu_id, num_Cores=ncores, use_ae_weights=False, do_umap=False, diff --git a/scib/metrics/clustering.py b/scib/metrics/clustering.py index bcb63366..61685370 100644 --- a/scib/metrics/clustering.py +++ b/scib/metrics/clustering.py @@ -40,7 +40,7 @@ def cluster_optimal_resolution( Will be overwritten if exists and ``force=True`` :param cluster_function: a clustering function that takes an anndata.Anndata object. Default: Leiden clustering :param metric: function that computes the cost to be optimised over. Must take as - arguments ``(adata, group1, group2, **kwargs)`` and returns a number for maximising + arguments ``(adata, label_key, cluster_key, **metric_kwargs)`` and returns a number for maximising Default is :func:`~scib.metrics.nmi()` :param resolutions: list of resolutions to be optimised over. If ``resolutions=None``, default resolutions of 10 values ranging between 0.1 and 2 will be used diff --git a/scib/metrics/lisi.py b/scib/metrics/lisi.py index 79166db1..748001d4 100644 --- a/scib/metrics/lisi.py +++ b/scib/metrics/lisi.py @@ -172,7 +172,7 @@ def clisi_graph( """ if batch_key is not None: - warnings.warn("'batch_key' is deprecated and will be ignore") + warnings.warn("'batch_key' is deprecated and will be ignore", stacklevel=1) check_adata(adata) check_batch(label_key, adata.obs) @@ -304,7 +304,6 @@ def lisi_graph_py( print("LISI score estimation") if n_cores > 1: - if verbose: print(f"{n_cores} processes started.") pool = mp.Pool(processes=n_cores) @@ -448,10 +447,13 @@ def compute_simpson_index_graph( return lists # read distances and indices with nan value handling - indices = pd.read_table(index_file, index_col=0, header=None, sep=",") + header = ["index"] + list(range(1, n_neighbors + 1)) + indices = pd.read_table(index_file, index_col=0, header=None, sep=",", names=header) indices = indices.T - distances = pd.read_table(distance_file, index_col=0, header=None, sep=",") + distances = pd.read_table( + distance_file, index_col=0, header=None, sep=",", names=header + ) distances = distances.T # get cell ids diff --git a/scib/metrics/pcr.py b/scib/metrics/pcr.py index 42a0264d..a61277ea 100644 --- a/scib/metrics/pcr.py +++ b/scib/metrics/pcr.py @@ -194,7 +194,7 @@ def pc_regression( if verbose: print("compute PCA") - pca = sc.tl.pca( + X_pca, _, _, pca_var = sc.tl.pca( matrix, n_comps=n_comps, use_highly_variable=False, @@ -202,9 +202,6 @@ def pc_regression( svd_solver=svd_solver, copy=True, ) - X_pca = pca[0].copy() - pca_var = pca[3].copy() - del pca else: X_pca = matrix n_comps = matrix.shape[1] diff --git a/setup.cfg b/setup.cfg index 77e68a3f..dc521b52 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.1.3 +current_version = 1.1.4 commit = True tag = True @@ -46,7 +46,7 @@ packages = python_requires = >=3.7 install_requires = numpy - pandas + pandas<2 seaborn matplotlib numba