Skip to content

Make obs and var optional, make obs_names and var_names required #76

Closed

Description

@rcannood

At the moment, we require that obs and var are passed to the InMemoryAnnData and HDF5AnnData, while other slots are optional.

However, looking at what happens when I create an empty AnnData in Python, it's actually the obs_names and the var_names that are required, and not obs and var -- I guess.

import anndata as ad
adata = ad.AnnData(shape=[10, 20])
adata.write_h5ad("empty.h5ad")
file <- rhdf5::H5Fopen("empty.h5ad")
rhdf5::h5ls(file)
  group   name       otype dclass dim
0     / layers   H5I_GROUP           
1     /    obs   H5I_GROUP           
2  /obs _index H5I_DATASET STRING  10
3     /   obsm   H5I_GROUP           
4     /   obsp   H5I_GROUP           
5     /    uns   H5I_GROUP           
6     /    var   H5I_GROUP           
7  /var _index H5I_DATASET STRING  20
8     /   varm   H5I_GROUP           
9     /   varp   H5I_GROUP

As such; I propose altering the code of InMemoryAnnData and HDF5AnnData require the obs_names and the var_names to be passed, not the obs and the var.

Activity

  1. added
    design
    on May 10, 2023
  2. lazappi commented on May 10, 2023

    @lazappi
    Collaborator

    I think this makes sense but is it much different to just doing obs = data.frame(row.names=obs_names).

    What does Python anndata put in obs_names/var_names when you just set the shape?

  3. rcannood commented on May 11, 2023

    @rcannood
    MemberAuthor

    I agree this is very practical, but given #73 we can't add the obs_names to the obs as rownames or to the X as rownames because the obs_names might be integers instead of characters.

  4. rcannood commented on May 11, 2023

    @rcannood
    MemberAuthor

    What does Python anndata put in obs_names/var_names when you just set the shape?

    This is what's shown in the original message, no?

  5. added a commit that references this issue on May 11, 2023
  6. lazappi commented on May 12, 2023

    @lazappi
    Collaborator

    What does Python anndata put in obs_names/var_names when you just set the shape?

    This is what's shown in the original message, no?

    Not entirely, but I could just check myself rather than asking you silly questions 😸

  7. rcannood commented on May 16, 2023

    @rcannood
    MemberAuthor

    :p

    Closed with #81

  8. added this to the 1.0.0 milestone on Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    design

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions