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'
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
Lines 612-617 in sc.py where the error is thrown
Throws a
KeyError: 'index'