Repository navigation
Pass embed through to LISI scores in metrics() - #437
barlowa124 wants to merge 57 commits into
Conversation
* use codecov action for code coverage * use code coverage action for all pytest runs * upload tests in separate artefacts and upload merged coverage report * update actions versions * change coverage file name
* make louvain an optional dependency * use leiden for integration tests * clean up louvain calls * change optimal cluster paramter order in conftest
fix iso label silhouette
This reverts commit d9f116d.
Update isolated_labels.py
* Run iso label as discussed on friday * Update test_isolated_label.py * Update test_silhouette_metrics.py * Update test_isolated_label.py * Update test_isolated_label.py * Update test_isolated_label.py * Update isolated_labels.py * Update test_isolated_label.py * Update isolated_labels.py * remove whitespaces * move sil precompute to isolated_labels_asw * remove whitespaces * syntax * syntax 2 * fix silhouette precomp * code style * Update isolated_labels.py * add comment for aggregation step * adapt to requested changes * remove bracket * syntax * linting --------- Co-authored-by: Michaela Mueller <michaela.mueller@helmholtz-muenchen.de>
Co-authored-by: Michaela Mueller <51025211+mumichae@users.noreply.github.com>
* add clustering to documentation * clarify clustering metric input
* more readable PCA computation and info retrieval * update isort * explicit stacklevel for warnings * downgrade pandas
Fix bug when reading LISI outputs Co-authored-by: Michaela Mueller <51025211+mumichae@users.noreply.github.com>
* pin pandas 2 and adapt breaking code * update scanorama * set minimum python version to 3.8
* use renamed_arg instead of deprecated_arg_names * remove python 3.8 from github actions * use np.array instead of np.matrix when densifying * test up to python 3.11 * more verbose assertion * change scanvi score for testing * change scvi score for testing * remove integration from code coverage * less exact test for scvi and scanvi
* improve np.nansum and use njit for HBeta * use np.eye function for convert_to_one_hot and reduce redundant initialisation * use with loop for temporary files * Add importlib-metadata in setup.cfg * set minimum python version to 3.8 * python version inas strings * update Scanorama version * fix n_batch
* use codecov-action v4 * fix delete-artifact tag * use delete-artifact@v4
* update pre-commit hooks * fix flake8 C420
In some versions of scipy(e.g. 1.14), M.A might not be available. In such cases, you should use M.toarray() to convert the sparse matrix to a dense one. Co-authored-by: Michaela Müller <51025211+mumichae@users.noreply.github.com>
Ensure essential packages are not detached. Co-authored-by: Michaela Müller <51025211+mumichae@users.noreply.github.com>
* Skip labels before loop * Fix lint --------- Co-authored-by: Michaela Müller <51025211+mumichae@users.noreply.github.com>
* adjust margin and add random batch kbet score test * update python versions * update to 3.12 for metrics * set 3.11 as max python version (due to incompatibility with louvain) * update python version for readthedocs build * reduce number of kbet tests
…heislab#415) * Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@v3...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * update actions/upload-artifact to v4.1.7 * fix version to v4 * unique naming for pytest artifacts --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Michaela Müller <51025211+mumichae@users.noreply.github.com> Co-authored-by: Michaela Mueller <michaela.mueller@helmholtz-muenchen.de>
* add numpy linreg function and use in pcr * allow configuring linreg method for pcr methods * simplify numpy linreg function * add tests for different linreg implementations * set PCA recomputation to False by default * use multithreading for linear regression and add tdqm * add durations to test command * add durations flag to pytest command * add min duration flag * add comments for ThreadPoolExecutore run * allow to specify n_threads and linreg algorithm * add keywords to cell cycle scoring * add multiple threading in pcr test * use nanmean * test cell cycle score with numpy linreg * use more memory-efficient implementation of ThreadPool * fix cases where there are no residuals * allow to configure svd_solver * use multiple linear regression and remove multithreading approach * use pcr score from numpy exact OLS implementation * remove testing code * include old pcr implementation * Update scib/metrics/cell_cycle.py * change default to numpy
* refactor cell cycle gene handling * add new gene sets for C. elegans and zebrafish and re-parse Tirosh genes from beginning * add test datasets for C. elegans and zebrafish * separate function for cell cycle gene set retrieval * smart use of gene ID or gene name depending on data * add gene scoring test for zebrafish and c_elegans * simplify random gene selection for error reporting * use Literal for organism * add list of possible organism names to error message * use scanpy backup_url functionality * add assertions for gene score columns
* use sparse one-hot encoding for sklearn * add one-way ANOVA implementation fo numpy approach when single categorical covariate is provided * reformat code * use dictionary for different linreg implementations * update documentation * add test for sparse one-hot and benchmark for different linreg implementations * chore: update pre-commit and remove autopep * style: adjust formatting settings * test: update skip benchmark for CI tests * test: add test for continuous covariates * style: fix pytest ini syntax * add zarr as dependency * pin rpy2<3.5 * move optional dependencies to pyproject.toml * remove setup.cfg, move to pyproject.toml only (and separate .flake8) * set LD_LIBRARY_PATH for R for rpy2 tests * skip failing rpy2 tests * relax clustering assertions
* pass kwargs to harmony.harmonize * linting --------- Co-authored-by: Michaela Mueller <michaela.mueller@helmholtz-munich.de> Co-authored-by: Michaela Müller <51025211+mumichae@users.noreply.github.com>
* Use dense matrices in diffusion_nn * fix linting --------- Co-authored-by: Michaela Müller <51025211+mumichae@users.noreply.github.com> Co-authored-by: Michaela Mueller <michaela.mueller@helmholtz-munich.de>
…b#431) * created initial changelog * use release-please to replace bump2version
* Add pre-commits * Format metrics * Add morans_i metrics * Format preprocessing * Add check for hvg * Add moran's I to metrics functions * Add morans I test * Move TODO * Minor changes preprocessing * Fix parse error * Change computatation of dense matrix to .A * Add check for sparse matrix * Multiple chages Move helper functions outside, only consider scores > 0, refactor code, reduce default n_hvg * Add test for compare_pre, adjust expected scores * fix imports for passing morans_i test * fix linting error * fix: remove deprecated .A and better handling of sparse matrix for std calculation --------- Co-authored-by: Michal Klein <michal.klein@protonmail.com> Co-authored-by: Michaela Mueller <michaela.mueller@helmholtz-muenchen.de> Co-authored-by: Michaela Müller <51025211+mumichae@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix: update rpy2 version and anndata2ri syntax * update python and R versions to work with updated rpy2 and anndata2ri versions * include setuptools * fix: set latest R version to "release" * fix lowest tested R version to 4.4 * test: add R version specific rpy2 dependencies * fix: np.isin instead of np.in1d * refactor: wrap rpy2 activation * use igraph implementation for louvain * relax assertions for louvain and test only igraph implementation * add qc tests * add workflow for preprocessing tests * switch to smaller zebrafish datasets and fix tests
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
clisi_graph and ilisi_graph default to use_rep='X_emb', so metrics() computed LISI scores on X_emb regardless of the embed argument (default 'X_pca'). Fixes theislab#429.
|
Closing and reopening to retrigger CI. The earlier run was canceled while building the louvain wheel during dependency install, before any tests ran. |
|
CI note: every failing job breaks in shared test fixtures before reaching this change. Tests/conftest.py calls adata_ref.concatenate, which current anndata releases removed in favour of anndata.concat. Preprocessing tests hit the pandas.value_counts relocation, and the metrics job dies on a numpy TypeError in fixture setup. Main has not run CI since April, so this is repo-wide dependency drift and not something this PR introduced. Locally, metrics runs cleanly against current anndata and scanpy when embed is X_pca with both LISI flags enabled. The embed argument now reaches use_rep in clisi_graph and ilisi_graph, where it previously fell back to the X_emb default. |
4241c81 to
3dec002
Compare
Fixes #429.
metrics()acceptsembed(default"X_pca") and forwards it to everyrepresentation-dependent score except LISI:
clisi_graphandilisi_graphwere called withoutuse_repand always fell back totheir own
"X_emb"default. Whenembedis anything other than"X_emb", including the documented default, the kNN for LISI isrebuilt on a different representation than the caller asked for.
Nothing warned.
Both calls now pass
use_rep=embed, matching howembedis alreadyforwarded to
cluster_optimal_resolution,silhouette,pc_comparison,isolated_labels,kBETandcell_cyclein the same function.The regression test builds a small AnnData carrying
X_customand noX_emb, then callsmetrics(embed="X_custom", clisi_=True, ilisi_=True).Before the fix it fails looking for
X_emb. Afterwards both LISI scoresare finite.
blackreports both files clean.AI-assisted (Devin).