Skip to content

Store obs_names and var_names as character? #73

Description

@rcannood

During the hackathon, I think it was mentioned that obs_names and var_names might not just be an array of strings, but other dtypes would also be supported. This would cause an issue w.r.t. interoperability in other languages -- at least in R, since standard data frames do not support non-string row names.

This has resulted in a somewhat clunky approach to storing obs_names and var_names in an anndataR::AnnData object, since we don't assume we can simply add the obs_names and var_names to any of the slots (X, var, obs, ...) since it will result in a conversion warning being thrown and thus loss of information.

We should figure out what the planned roadmap for this functionality is (probably related to scverse/anndata#777?), and whether there is a different way of resolving this in R because not being to add any dimnames to X and rownames to obs and var is quite cumbersome.

Activity

  1. mtmorgan commented on May 6, 2023

    @mtmorgan
    Contributor

    a strategy following https://anndata.readthedocs.io/en/latest/fileformat-prose.html#dataframe-specification-v0-2-0 might define obs_attrs() and including obs_attrs()[["_name"]] the column name of the index. obs would return a data.frame that included the named column. Is it actually a problem not having row names? This is the norm in the tidyverse world.

    Perhaps we would implement (on AbstractAnnData) a single-square-brack subset method ad[cidx, ridx] that created a subset / view based on the corresponding row / column index,.

  2. lazappi commented on May 8, 2023

    @lazappi
    Collaborator

    I think it should be possible to support most things by storing names separately. Indexing is maybe only an issue for the in-memory backend anyway, I don't think we want to try to implement indexing on the file-backed backends. Conversion to R objects might be more difficult because as soon as we put things into colnames/rownames they will coerced to characters.

    Maybe @ivirshup can give us an idea of how soon this might happen (and how much we need to worry about it now)?

  3. ivirshup commented on May 8, 2023

    @ivirshup
    Member

    It's not imminent. At soonest, my guess would be late this year. But I can ping maintainers of this library ahead of that.

  4. added
    design
    on Mar 6, 2025
  5. lazappi commented on Mar 6, 2025

    @lazappi
    Collaborator

    See also #172

  6. added
    question
    on Nov 20, 2025
  7. changed the title [-]obs_names and var_names as character/str or not[/-] [+]Store `obs_names` and `var_names` as character?[/+] on Nov 20, 2025
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

    designquestion

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions