Open const-ae opened 1 month ago
Hi @const-ae
Thanks for the issue. It looks like you are using the R reader? I'm a bit rusty on how this works but I think you are probably right. Any chance you would be interested in submitting a PR with this change?
It looks like you are using the R reader?
Yes exactly.
Any chance you would be interested in submitting a PR with this change?
Sorry, I currently don't have the bandwidth as I am trying to wrap up some revisions before moving to London next week.
Hi,
I am currently trying to read an h5ad file that has a column called
"condition"
which is stored as a categorical (I think that means that it was saved with AnnData version < 0.7.0).Currently the implementation in
.read_dim_data
takes the integers, converts them to a factor, and overrides the levels:This code fails if one of the factor level is unused:
Created on 2024-08-19 with reprex v2.1.0
The problem is very easy to miss because R silently replaces the levels even though the length of the old and new levels are different.
One way to fix the implementation would be to write:
Created on 2024-08-19 with reprex v2.1.0