DingWB / PyComplexHeatmap

PyComplexHeatmap: A Python package to plot complex heatmap (clustermap)
https://dingwb.github.io/PyComplexHeatmap/
MIT License
297 stars 32 forks source link

Category type not supported? #87

Closed AaronNing closed 2 months ago

AaronNing commented 2 months ago

Describe the bug When a column is of type category, the annotation cannot be created

To Reproduce

df = pd.DataFrame(index=range(5))
df["ABC"] = ["A", "B", "B", "C", "C"]
pch.HeatmapAnnotation(df, plot=True)

This produces the annotation correctly.

df = pd.DataFrame(index=range(5))
df["ABC"] = ["A", "B", "B", "C", "C"]
df["ABC"] = df["ABC"].astype("category")
pch.HeatmapAnnotation(df, plot=True)

This yields TypeError: Can not assign cmap for column ABC, please specify cmap

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

print(pd.__version__)
print(mpl.__version__)
print(np.__version__)
print(pch.__version__)

1.5.3 3.7.1 1.22.4 1.7.6

DingWB commented 2 months ago

Hi @AaronNing ,

It has already been fixed, you can install the latest version from GitHub:

pip uninstall -y PyComplexHeatmap && pip install git+https://github.com/DingWB/PyComplexHeatmap

If you don't want to reinstall, you can simply specify cmap, for example: cmap='Set', and there will be no error.