Skip to content

Commit

Permalink
Fix #454 (#465)
Browse files Browse the repository at this point in the history
* Fix #454

* Update changelog
  • Loading branch information
grst authored Nov 10, 2023
1 parent 1a75fdc commit 3120a9d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning][].
### Fixes

- Fix that `define_clonotype_clusters` could not retreive `within_group` columns from MuData ([#459](https://github.com/scverse/scirpy/pull/459))
- Fix that AIRR Rearrangment fields of integer types could not be written when their value was None ([#465](https://github.com/scverse/scirpy/pull/465))

## v0.13.1

Expand Down
6 changes: 3 additions & 3 deletions src/scirpy/io/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ def write_airr(adata: DataHandler.TYPE, filename: Union[str, Path], **kwargs) ->
for tmp_cell in airr_cells:
for chain in tmp_cell.to_airr_records():
# workaround for AIRR library writing out int field as floats (if it happens to be a float)
for f in chain:
if RearrangementSchema.type(f) == "integer":
chain[f] = int(chain[f])
for field, value in chain.items():
if RearrangementSchema.type(field) == "integer" and value is not None:
chain[field] = int(value)
writer.write(chain)
writer.close()

Expand Down
9 changes: 9 additions & 0 deletions src/scirpy/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ def test_airr_roundtrip_conversion(anndata_from_10x_sample, tmp_path):
pdt.assert_frame_equal(anndata.obs, anndata2.obs, check_dtype=False, check_categorical=False)


def test_write_airr_none_field_issue_454(tmp_path):
cell = AirrCell("cell1")
chain = cell.empty_chain_dict()
chain["d_sequence_end"] = None
cell.add_chain(chain)
adata = from_airr_cells([cell])
write_airr(adata, tmp_path / "test.airr.tsv")


@pytest.mark.extra
@pytest.mark.parametrize(
"anndata_from_10x_sample",
Expand Down

0 comments on commit 3120a9d

Please sign in to comment.