immunogenomics/cna

d.obs_to_sample KeyError: "['id'] not in index"

france-hub opened this issue · 1 comments

Hello,

Thanks for your very nice package. I was able to use the R version of your package. However, I wanted to look at your tutorial in python (there are more visualization options and additional functions).

However after saving my seurat object in h5ad format and importing in python, when I tun this line of code

d.obs_to_sample(['group_id','batch'])

I got this error
KeyError: "['id'] not in index"

group_id and batch are in d.obs

How would you suggest to fix this error?

Thanks a lot
Francesco

Hi Francesco, I'm glad you're finding CNA useful! I think the section on our tutorial page that you need here is section 2.1.3. In short, the multianndata object type needs to know which of the columns of d.obs represents your sample id labels. It will assume the column is named 'id' unless a different name is specified during construction of the object. Hope this helps!