scverse/Muon.jl

structured array I/O

Closed this issue · 0 comments

gtca commented

There might be a problem with reading categorical variables in .h5ad/.h5mu files:

MethodError: Cannot `convert` an object of type

Vector{NamedTuple{(Symbol("0"), Symbol("1"), Symbol("2"), Symbol("3"), Symbol("4"), Symbol("5"), Symbol("6"), Symbol("7"), Symbol("8"), Symbol("9"), Symbol("10"), Symbol("11"), Symbol("12"), Symbol("13")), NTuple{14, Float32}}} to an object of type

Union{AbstractString, Number, DataFrames.DataFrame, Dict, AbstractArray{<:AbstractString}, AbstractArray{<:Number}}

A quick fix would be e.g. to add a permissive type to the read_dict_of_mixed() function:

function read_dict_of_mixed(f::HDF5.Group; kwargs...)
    ret = Dict{
        String,
        Union{
            ...
            Dict,
            <:Any,
        },
  }()
...

But I expect more reasonable types can be used in the end.