scverse / scverse/scanpy

rank_genes_groups_matrixplot does not plot logfoldchanges that are NaN as zero but a fixed >0 value.

Open
#2,368 0 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

  • [X ] I have checked that this issue has not already been reported.
  • [X ] 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.

Having NaN in my rank_gene_groups for some genes in some groups and plotting with rank_genes_groups_matrixplot does not set the NaN values =0
I only see two places in the code where nan gets set to 0 for matrix plots

./_matrixplot.py:148:                values_df = values_df.div(values_df.max(1), axis=0).fillna(0)
./_matrixplot.py:151:                values_df = (values_df / values_df.max(0)).fillna(0)

and that is when using standard_scale which doesn't seem to have an effect for logfoldchanges (naturally). I'm just not sure where or why my nan takes the color of values >0 in my matrix plot.

Versions

sc.__version__
'1.9.1'

[Paste the output of scanpy.logging.print_versions() leaving a blank line after the details tag]

-----
anndata     0.8.0
scanpy      1.9.1
-----
PIL                 9.1.0
asttokens           NA
backcall            0.2.0
beta_ufunc          NA
binom_ufunc         NA
certifi             2021.10.08
cffi                1.15.0
charset_normalizer  2.0.12
cycler              0.10.0
cython_runtime      NA
dateutil            2.8.2
debugpy             1.6.0
decorator           5.1.1
defusedxml          0.7.1
entrypoints         0.4
executing           0.8.3
gprofiler           1.0.0
h5py                3.6.0
hypergeom_ufunc     NA
idna                3.3
igraph              0.9.10
ipykernel           6.12.1
ipython_genutils    0.2.0
ipywidgets          7.7.0
jedi                0.18.1
joblib              1.1.0
jupyter_server      1.16.0
kiwisolver          1.4.2
leidenalg           0.8.9
llvmlite            0.38.0
matplotlib          3.6.2
matplotlib_inline   NA
mpl_toolkits        NA
natsort             8.1.0
nbinom_ufunc        NA
numba               0.55.1
numpy               1.21.4
packaging           21.3
pandas              1.5.1
parso               0.8.3
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
prompt_toolkit      3.0.29
psutil              5.9.0
ptyprocess          0.7.0
pure_eval           0.2.2
pydev_ipython       NA
pydevconsole        NA
pydevd              2.8.0
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.11.2
pyparsing           3.0.9
pytz                2022.1
requests            2.27.1
scipy               1.8.1
seaborn             0.12.1
session_info        1.0.0
setuptools          62.0.0
setuptools_scm      NA
six                 1.16.0
sklearn             1.0.2
socks               1.7.1
stack_data          0.2.0
statsmodels         0.13.2
texttable           1.6.4
threadpoolctl       3.1.0
tornado             6.1
traitlets           5.1.1
typing_extensions   NA
urllib3             1.26.9
wcwidth             0.2.5
zmq                 22.3.0
zoneinfo            NA
-----
IPython             8.2.0
jupyter_client      7.2.2
jupyter_core        4.9.2
jupyterlab          3.3.3
notebook            6.4.10
-----
Python 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:22:55) [GCC 10.3.0]
Linux-5.15.0-52-generic-x86_64-with-glibc2.31
-----
Session information updated at 2022-11-11 15:54

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 in _matrixplot.py, especially the values_df handling around lines 148 and 151, and trace how rank_genes_groups_matrixplot processes logfoldchanges when standard_scale is unused. Reproduce the reported case with NaN logfoldchanges and inspect how those values reach the color mapping. Done means NaN values are rendered as zero rather than taking a positive color, with existing scaling behavior preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.