Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support for string type chromosome column in ManhattanPlot #772

Open
LawrenceLiu023 opened this issue Aug 28, 2024 · 1 comment

Comments

@LawrenceLiu023
Copy link

Description
Currently the chromosome column specified with dash_bio.ManhattanPlot(chrm='<The column of chromosome>') does not support non-numeric types.

To Reproduce
Python code:

import dash_bio
plotly_demo_manhattan_path: Path = Path("../dev/data/plotly_manhattan_data.csv")
plotly_demo_manhattan_data_df: pd.DataFrame = pd.read_csv(
    plotly_demo_manhattan_path, header=0, index_col=None, sep=","
)
plotly_demo_manhattan_data_df = plotly_demo_manhattan_data_df.assign(
    CHR=plotly_demo_manhattan_data_df["CHR"].astype(str)
)
manhattan_plot = dash_bio.ManhattanPlot(
    plotly_demo_manhattan_data_df,
    chrm="CHR",
)

The output:

File ~/micromamba/envs/temp/lib/python3.12/site-packages/dash_bio/component_factory/_manhattan.py:221, in _ManhattanPlot.__init__(self, x, chrm, bp, p, snp, gene, annotation, logp)
    [219] else:
    [220]     if not is_numeric_dtype(x[chrm].dtype):
--> [221]         raise TypeError("%s column should be numeric. Do you have "
    [222]                         "'X', 'Y', 'MT', etc? If so change to "
    [223]                         "numbers and try again." % chrm)
    [225] if bp not in x.columns.values:
    [226]     raise KeyError("Column %s not found in 'x' data.frame" % bp)

TypeError: CHR column should be numeric. Do you have 'X', 'Y', 'MT', etc? If so change to numbers and try again.

Expected behavior
If string type for chromosomes is supported, it would allow for the creation of Manhattan plots for a greater variety of chromosomes. Additionally, this feature would enable the plotting of data from more species.

Python version: 3.12.4

Python environment (all installed packages in your current environment):

Package                   Version
------------------------- ---------
annotated-types           0.7.0
asttokens                 2.4.1
attrs                     24.2.0
beautifulsoup4            4.12.3
biopython                 1.84
bioreport                 1.1.5
black                     24.8.0
blinker                   1.8.2
Brotli                    1.1.0
bs4                       0.0.2
certifi                   2024.7.4
cffi                      1.17.0
charset-normalizer        3.3.2
click                     8.1.7
CNVpytor                  1.3.1
colorama                  0.4.6
coloredlogs               15.0.1
colormath                 3.0.0
colour                    0.1.5
comm                      0.2.2
contourpy                 1.2.1
cycler                    0.12.1
dash                      2.17.1
dash-bio                  1.0.2
dash-core-components      2.0.0
dash-html-components      2.0.0
dash-table                5.0.0
debugpy                   1.8.5
decorator                 5.1.1
exceptiongroup            1.2.2
executing                 2.0.1
fastjsonschema            2.20.0
Flask                     3.0.3
fonttools                 4.53.1
GEOparse                  2.0.4
gnureadline               8.2.10
h2                        4.1.0
h5py                      3.11.0
hpack                     4.0.0
humanfriendly             10.0
humanize                  4.10.0
hyperframe                6.0.1
idna                      3.8
importlib_metadata        8.4.0
importlib_resources       6.4.3
ipykernel                 6.29.5
ipython                   8.26.0
ipywidgets                8.1.5
itsdangerous              2.2.0
jedi                      0.19.1
Jinja2                    3.1.4
joblib                    1.4.2
jsonschema                4.23.0
jsonschema-specifications 2023.12.1
jupyter_client            8.6.2
jupyter_core              5.7.2
jupyterlab_widgets        3.0.13
kaleido                   0.2.1
kiwisolver                1.4.5
Markdown                  3.6
markdown-it-py            3.0.0
MarkupSafe                2.1.5
matplotlib                3.9.2
matplotlib-inline         0.1.7
mdurl                     0.1.2
multiqc                   1.24.1
mypy-extensions           1.0.0
nbformat                  5.10.4
nest_asyncio              1.6.0
networkx                  3.3
numpy                     1.26.4
packaging                 24.1
pandas                    2.2.2
ParmEd                    4.2.2
parso                     0.8.4
pathspec                  0.12.1
patsy                     0.5.6
periodictable             1.5.2
pexpect                   4.9.0
pickleshare               0.7.5
pillow                    10.4.0
pip                       24.2
pip-search                0.0.12
pkgutil_resolve_name      1.3.10
platformdirs              4.2.2
plotly                    5.23.0
polars                    1.2.1
prompt_toolkit            3.0.47
psutil                    6.0.0
ptyprocess                0.7.0
pure_eval                 0.2.3
pyaml_env                 1.2.1
pyarrow                   17.0.0
pycparser                 2.22
pydantic                  2.8.2
pydantic_core             2.20.1
Pygments                  2.18.0
pyparsing                 3.1.4
pysam                     0.22.1
PySocks                   1.7.1
python-dateutil           2.9.0
pytz                      2024.1
PyYAML                    6.0.2
pyzmq                     26.1.1
referencing               0.35.1
requests                  2.32.3
retrying                  1.3.3
rich                      13.7.1
rich-click                1.8.3
rpds-py                   0.20.0
scikit-learn              1.5.1
scipy                     1.14.0
setuptools                72.1.0
six                       1.16.0
soupsieve                 2.6
spectra                   0.0.11
stack-data                0.6.2
statsmodels               0.14.2
tenacity                  9.0.0
threadpoolctl             3.5.0
tornado                   6.4.1
tqdm                      4.66.5
traitlets                 5.14.3
typeguard                 4.3.0
typing_extensions         4.12.2
tzdata                    2024.1
urllib3                   2.2.2
wcwidth                   0.2.13
Werkzeug                  3.0.4
wheel                     0.44.0
widgetsnbextension        4.0.13
XlsxWriter                3.2.0
zipp                      3.20.0
zstandard                 0.23.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@LawrenceLiu023 and others