scverse / scverse/scanpy

filter_rank_genes_groups in version 1.6.0 takes an extremely long time to complete

Open
#1,449 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of scanpy.
  • (optional) I have confirmed this bug exists on the master branch of scanpy.

Hi, Thanks for the great software package. I've noticed a very noticeable speed decrease with filter_rank_genes_groups between versions 1.5.1 and 1.6.0 (see below for the run times i was getting). I was working on a data set with ~19k cells x ~22k genes and 12 leiden clusters.

with version 1.5.1:

import time
start_time = time.time()
sc.tl.rank_genes_groups(adata, groupby = 'leiden', method = 'wilcoxon')
print("--- %s seconds ---" % (time.time() - start_time))
# --- 50.23415994644165 seconds ---

start_time = time.time()
sc.tl.filter_rank_genes_groups(adata, min_fold_change=1)
print("--- %s seconds ---" % (time.time() - start_time))
# --- 1.5828611850738525 seconds ---

with version 1.6.0:

import time
start_time = time.time()
sc.tl.rank_genes_groups(adata, groupby = 'leiden', method = 'wilcoxon')
print("--- %s seconds ---" % (time.time() - start_time))
# --- 49.53031611442566 seconds ---

start_time = time.time()
sc.tl.filter_rank_genes_groups(adata, min_fold_change=1)
print("--- %s seconds ---" % (time.time() - start_time))
# --- 600.4000315666199 seconds ---

I also noticed that it was using up 98% of my CPU while running filter_rank_genes_groups.

Versions

scanpy==1.5.1 anndata==0.7.4 umap==0.4.6 numpy==1.19.1 scipy==1.5.2 pandas==1.0.5 scikit-learn==0.23.1 statsmodels==0.11.1 python-igraph==0.8.2 leidenalg==0.8.1

and

-----
anndata     0.7.4
scanpy      1.6.0
sinfo       0.3.1
-----
Bio                 1.77
PIL                 7.2.0
adjustText          NA
anndata             0.7.4
annoy               NA
backcall            0.2.0
bbknn               NA
brotli              NA
cachecontrol        0.12.6
cairo               1.19.1
certifi             2020.06.20
cffi                1.14.1
changeo             1.0.0
chardet             3.0.4
cycler              0.10.0
cython_runtime      NA
dandelion           0.0.15
dateutil            2.8.0
decorator           4.4.2
descartes           NA
distance            NA
get_version         2.1
h5py                2.10.0
hdmedians           NA
idna                2.10
igraph              0.8.2
importlib_metadata  1.7.0
ipykernel           5.3.3
ipython_genutils    0.2.0
jedi                0.17.2
jinja2              2.11.2
joblib              0.16.0
kiwisolver          1.2.0
legacy_api_wrap     1.2
leidenalg           0.8.1
llvmlite            0.33.0
markupsafe          1.1.1
matplotlib          3.3.0
mizani              0.7.1
mpl_toolkits        NA
msgpack             1.0.0
natsort             7.0.1
networkx            2.4
numba               0.50.1
numexpr             2.7.1
numpy               1.19.1
packaging           20.4
palettable          3.3.0
pandas              1.0.5
parso               0.7.1
patsy               0.5.1
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
plotnine            0.6.0
polyleven           NA
presto              0.6.1
prompt_toolkit      3.0.6
ptyprocess          0.6.0
pycparser           2.20
pygments            2.6.1
pyparsing           2.4.7
pytz                2019.2
requests            2.24.0
rpy2                3.3.5
scanpy              1.6.0
scipy               1.5.2
scrublet            NA
seaborn             0.10.1
setuptools_scm      NA
sinfo               0.3.1
six                 1.12.0
skbio               0.5.6
sklearn             0.23.1
socks               1.7.1
statsmodels         0.11.1
storemagic          NA
tables              3.6.1
texttable           1.6.2
tools               NA
tornado             6.0.4
tqdm                4.48.0
traitlets           4.3.3
tzlocal             NA
umap                0.4.6
urllib3             1.25.10
wcwidth             0.2.5
yaml                5.1.2
zipp                NA
zmq                 19.0.1
-----
IPython             7.17.0
jupyter_client      6.1.6
jupyter_core        4.6.3
-----
Python 3.7.6 | packaged by conda-forge | (default, Jun  1 2020, 18:57:50) [GCC 7.5.0]
Linux-4.4.0-189-generic-x86_64-with-debian-buster-sid
24 logical CPU cores, x86_64
-----
Session information updated at 2020-10-08 16:18

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the filter_rank_genes_groups entry point and compare its behavior between scanpy 1.5.1 and 1.6.0 using the reported dataset shape and min_fold_change=1 call. Benchmark both versions and verify that the filtering result is preserved while the severe runtime regression is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.