Conversation
Since #356, the data types in `.obsm["airr"]` are guaranteed, so downstream code no longer needs to guard against string representations of `NaN`, `True` and `False`. Replace those checks with `pandas.isnull`/`notnull`, which is both faster and easier to read. The only remaining occurrences are in `scirpy.io`, where input data is sanitized before it is stored. To make that guarantee hold for arbitrary input, `AirrCell.add_chain` now also casts strings to the type declared in the AIRR rearrangement schema. Previously, building `AirrCell` objects from data that spelled out booleans or numbers as strings (e.g. `productive="True"`) produced an `.obsm["airr"]` array with union types that `pp.index_chains` could not process. Two follow-ups fell out of this: * `pl.vdj_usage` relied on `astype(str)` turning missing gene calls into the string `"nan"`, which no longer happens with pandas' nullable string dtypes. As a result the `none` segment was silently dropped from the plot. Missing values are now replaced with `"none"` explicitly. * Two test fixtures spelled a missing clonotype as the string `"NaN"` in `obs`. Those now use `None`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #736 +/- ##
==========================================
+ Coverage 78.20% 78.24% +0.04%
==========================================
Files 51 51
Lines 4620 4625 +5
==========================================
+ Hits 3613 3619 +6
+ Misses 1007 1006 -1
🚀 New features to boost your workflow:
|
|
Hi @grst, I reproduced the two The cause is that On Windows/Python 3.12, all six existing VDJ plotting cases pass with that change on both pandas versions. I also checked the fixture's per-gene counts and normalized weights for AnnData/MuData; the missing group contains six cells, with 15 cells total. |
Since #356, the data types in
.obsm["airr"]are guaranteed, so downstreamcode no longer needs to guard against string representations of
NaN,TrueandFalse. Replace those checks withpandas.isnull/notnull,which is both faster and easier to read. The only remaining occurrences are
in
scirpy.io, where input data is sanitized before it is stored.To make that guarantee hold for arbitrary input,
AirrCell.add_chainnowalso casts strings to the type declared in the AIRR rearrangement schema.
Previously, building
AirrCellobjects from data that spelled out booleansor numbers as strings (e.g.
productive="True") produced an.obsm["airr"]array with union types thatpp.index_chainscould notprocess.
Two follow-ups fell out of this:
pl.vdj_usagerelied onastype(str)turning missing gene calls intothe string
"nan", which no longer happens with pandas' nullable stringdtypes. As a result the
nonesegment was silently dropped from theplot. Missing values are now replaced with
"none"explicitly."NaN"inobs. Those now useNone.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Closes #380