Open frankligy opened 1 year ago
So, this is an issue related to anndata, not an issue with scTriangulate. It has been detailed in the post like that (https://stackoverflow.com/questions/70234014/valueerror-index-is-a-reserved-name-for-dataframe-columns).
I also encounter writing issue when using anndata, so I implemented a function called make_sure_adata_writable
(https://sctriangulate.readthedocs.io/en/latest/api.html#make-sure-adata-writable), this function takes care two thing, (a) make sure the var and obs index doesn't have name, (b) make sure there are no mixed-type column in both var and obs. But unfortunately, the issue raised here hasn't been considered by this function, and more importantly, we need to also consider the adata.raw as well, the raw also contains a copy of var. For now, please use the following code:
make_sure_adata_writable(adata,delete=False)
adata.var.rename(columns={'_index':'index'},inplace=True)
adata.raw.var.rename(columns={'_index':'index'},inplace=True) # if raw slot exists
But I will modify my make_sure_adata_writable
function as well in the next release.