Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anndata.concat() merging of uns doesn't work for None values #711

Closed
alam-shahul opened this issue Feb 24, 2022 · 4 comments
Closed

anndata.concat() merging of uns doesn't work for None values #711

alam-shahul opened this issue Feb 24, 2022 · 4 comments

Comments

@alam-shahul
Copy link

I'm trying to use anndata.concat() to merge two AnnData objects with the following structure:

object_1 = {
...
uns: {
    "property": {
        "0": None
    }
}
...
}

object_2 = {
...
uns: {
    "property": {
        "1": None
    }
}
...
}

When I merge them using uns_merge="unique", the "property" key is missing from the merged AnnData object. However, when I replace the None value with a value like -1, it works fine. Is this the expected behavior, and if so why?

@ivirshup
Copy link
Member

Thanks for the bug report, and sorry about the time it took to respond.

I'm not able to reproduce with either 0.7.8 or 0.8.0. Are you still seeing this?

import anndata as ad
import numpy as np

a = ad.AnnData(np.ones((3, 3)), uns={"property": {"0": None}})
b = ad.AnnData(np.ones((3, 3)), uns={"property": {"1": None}})
ad.concat([a, b], uns_merge="unique").uns["property"]
# {'0': None, '1': None}
ad.__version__
# '0.7.8'

@alam-shahul
Copy link
Author

alam-shahul commented Mar 24, 2022

Okay, I guess I reported the bug slightly incorrectly. The result is correct after concatenating, but after I write to an HDF5 file with merged_datast.write(filepath) and then reload with reloaded_dataset = ad.read_h5ad(filepath), it does not contain the right keys. Is this expected?

import anndata as ad
import numpy as np
a = ad.AnnData(np.ones((3, 3)), uns={"property": {"0": None}})
b = ad.AnnData(np.ones((3, 3)), uns={"property": {"1": None}})


merged_dataset = ad.concat([a, b], uns_merge="unique")
merged_dataset.uns["property"]
# {'0': None, '1': None}

merged_dataset.write("issue.h5")

reloaded_dataset = ad.read_h5ad("issue.h5")
reloaded_dataset.uns["property"]
# {}

ad.__version__
# '0.8.0'

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@github-actions github-actions bot added the stale label Aug 17, 2023
@flying-sheep
Copy link
Member

flying-sheep commented Aug 21, 2023

duplicate of #673. Will be fixed in #999

@flying-sheep flying-sheep closed this as not planned Won't fix, can't repro, duplicate, stale Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants