Repository navigation
If an obs column name is 0 or 1, they are not displayed by pl.render_shapes method #327
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingpriority: lowshapes 🫧Anything related to ShapesAnything related to Shapes
Description
Hi,
I think this is a very specific issue. I cannot provide data to replicate. So obs has a column containing a continuous data and I want to visualize it. If the column name is "0" or "1", it shows a blank plot while other integers like "2", "3" or others work fine.
An example code to visualize a column.
sdata.pl.render_images("queried_cytassist").pl.render_shapes(
f"{sample_id}_square_00{bin_size}um", color="1",cmap=new_cmap,method="matplotlib",scale=0.8
).pl.show(coordinate_systems="global", title="cluster 1",legend_fontsize=8,figsize=(5,5),dpi=200)
My computer is Mac M1.
aiobotocore 2.5.4
aiohappyeyeballs 2.3.7
aiohttp 3.10.4
aioitertools 0.11.0
aiosignal 1.3.1
anndata 0.10.8
appnope 0.1.4
array_api_compat 1.8
asciitree 0.3.3
asttokens 2.4.1
attrs 24.2.0
botocore 1.31.17
certifi 2024.7.4
charset-normalizer 3.3.2
click 8.1.7
cloudpickle 3.0.0
colorcet 3.1.0
comm 0.2.2
contourpy 1.2.1
csbdeep 0.8.0
cycler 0.12.1
dask 2024.8.1
dask-expr 1.1.11
dask-image 2024.5.3
datashader 0.16.3
debugpy 1.8.5
decorator 5.1.1
distributed 2024.8.1
docrep 0.3.2
et-xmlfile 1.1.0
exceptiongroup 1.2.2
executing 2.0.1
fasteners 0.19
fcsparser 0.2.8
fonttools 4.53.1
frozenlist 1.4.1
fsspec 2023.6.0
geopandas 1.0.1
h5py 3.11.0
idna 3.7
igraph 0.11.6
imagecodecs 2024.6.1
imageio 2.35.1
importlib_metadata 8.2.0
inflect 7.3.1
iniconfig 2.0.0
ipykernel 6.29.5
ipython 8.26.0
jedi 0.19.1
Jinja2 3.1.4
jmespath 1.0.1
joblib 1.4.2
jupyter_client 8.6.2
jupyter_core 5.7.2
kiwisolver 1.4.5
lamin_utils 0.13.2
lazy_loader 0.4
legacy-api-wrap 1.4
leidenalg 0.10.2
llvmlite 0.43.0
locket 1.0.0
markdown-it-py 3.0.0
MarkupSafe 2.1.5
matplotlib 3.9.2
matplotlib-inline 0.1.7
matplotlib-scalebar 0.8.1
mdurl 0.1.2
more-itertools 10.4.0
msgpack 1.0.8
multidict 6.0.5
multipledispatch 1.0.0
multiscale_spatial_image 1.0.1
natsort 8.4.0
nest_asyncio 1.6.0
networkx 3.3
numba 0.60.0
numcodecs 0.13.0
numpy 1.26.4
ome-zarr 0.9.0
omnipath 1.0.8
openpyxl 3.1.5
packaging 24.1
pandas 2.2.2
param 2.1.1
parso 0.8.4
partd 1.4.2
patsy 0.5.6
pexpect 4.9.0
pickleshare 0.7.5
pillow 10.4.0
PIMS 0.7
pip 24.2
platformdirs 4.2.2
pluggy 1.5.0
pooch 1.8.2
prompt_toolkit 3.0.47
psutil 6.0.0
ptyprocess 0.7.0
pure_eval 0.2.3
pyarrow 17.0.0
pyct 0.5.0
Pygments 2.18.0
pynndescent 0.5.13
pyogrio 0.9.0
pyparsing 3.1.2
pyproj 3.6.1
pytest 8.3.2
python-dateutil 2.9.0
pytz 2024.1
PyYAML 6.0.2
pyzmq 26.1.0
readfcs 1.1.8
regex 2024.7.24
requests 2.32.3
rich 13.7.1
s3fs 2023.6.0
scanpy 1.10.2
scikit-image 0.24.0
scikit-learn 1.5.1
scipy 1.14.0
seaborn 0.13.2
session_info 1.0.0
setuptools 72.1.0
shapely 2.0.5
six 1.16.0
slicerator 1.1.0
sortedcontainers 2.4.0
spatial_image 1.1.0
spatialdata 0.2.2
spatialdata-io 0.1.4
spatialdata-plot 0.2.4
squidpy 1.6.0
stack-data 0.6.2
stardist 0.9.1
statsmodels 0.14.2
stdlib-list 0.10.0
tblib 3.0.0
texttable 1.7.0
threadpoolctl 3.5.0
tifffile 2024.8.10
toolz 0.12.1
tornado 6.4.1
tqdm 4.66.5
traitlets 5.14.3
typeguard 4.3.0
typing_extensions 4.12.2
tzdata 2024.1
umap-learn 0.5.6
urllib3 1.26.19
validators 0.33.0
wcwidth 0.2.13
wheel 0.44.0
wrapt 1.16.0
xarray 2024.7.0
xarray-dataclasses 1.8.0
xarray-datatree 0.0.14
xarray-schema 0.0.3
xarray-spatial 0.4.0
yarl 1.9.4
zarr 2.18.2
zict 3.0.0
zipp 3.20.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpriority: lowshapes 🫧Anything related to ShapesAnything related to Shapes
Activity
timtreis commentedon Aug 26, 2024
I assume this boils down to "0" and "1" sometimes being evaluated as booleans. I'll try to include a fix in my next PR, should be tiny. But in the meantime, you can probably avoid this by just not using 0/1.
timtreis commentedon Aug 26, 2024
Hey @sinanugur,
I tried reproducing the bug by manually creating columns called "0" and "1" and they behave identical to let's say "2".
Buuuuut I'm on #323 locally right now, so it might be that this PR accidentally also fixes the underlying issue you reported. Could you try installing from this branch and report if the issue persists?
sinanugur commentedon Aug 27, 2024
Hi @timtreis,
I got the same result.
spatialdata object table looks like this:
My environment:
timtreis commentedon Aug 27, 2024
Which datatypes do your "0" or "1" columns have? And did you try to just rename the columns? Without a MRE I'll have to guess but it'd be good to pinpoint whether it's the column-name that's the issue or it's content. You could f.e. rename the columns to "xyz0" and "xyz1". If the issue is gone, it's the actual column name - if it persists, it's their content
sinanugur commentedon Aug 27, 2024
Hi, It is continuous data.
Yes I tried renaming and created another column named x0 from "1" and it worked. That is why I am sure it must be related to column names. It is only for 0 and 1.
Cheers,
Sinan
timtreis commentedon Aug 27, 2024
Was able to reproduce, will fix now. For some reason, matplotlib thinks "0" and "1" are colors:
This feels like unintended behaviour, so I opened an issue over at
matplotlib: matplotlib/matplotlib#28759tacaswell commentedon Aug 27, 2024
https://matplotlib.org/stable/users/explain/colors/colors.html#color-formats
float values in [0, 1] as strings are short-hand for shades of gray.
timtreis commentedon Aug 27, 2024
Thank you for your super quick clarification @tacaswell !
timtreis commentedon Aug 27, 2024
@sinanugur we'll derivate from
matplotlibhere and block those. Will address this in the linked PR