Skip to content

Allow flexible index column name in adata.var #12

@Rebecza

Description

@Rebecza

adata.var.index.name or adata.var_names.name can be other than None, as I noticed with a publicly available dataset.

SCEPIA expects this column to be called "index" (see code below where this throws an error) which would be the case with adata.var.index.name=None.

Solution could be to set adata.var.index.name to None within SCEPIA, if we change the index column name within SCEPIA, we should do the same for the adata.raw. Or change the code without the hardcoded "index".

Lines in sc.py where the index column name is taken from the adata object

    unique_factors = my_adata.raw.var_names[detected].str.upper()
    real = pd.DataFrame(
        real,
        index=unique_factors,
        columns=my_adata.uns["scepia"]["motif_activity"].index,
    )

Lines 612-617 in sc.py where the error is thrown

    tmp = (
        real.reset_index()
        .melt(id_vars="index", var_name="motif", value_name="correlation")
        .rename(columns={"index": "factor"})
        .set_index(["motif", "factor"])
    )

Throws a KeyError: 'index'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions