seurat-disk icon indicating copy to clipboard operation
seurat-disk copied to clipboard

Error: Cannot find feature names dataset at row_attrs/Gene

Open dm8000 opened this issue 3 years ago • 6 comments

Hello

I saved an AnnData object as a loom file in python with

adata.write_loom('~/path/object.loom')

Then I tried to convert it to a Seurat object in r with SeuratDisk

object.loom <- connect(filename = "object.loom", mode = "r+", skip.validate = TRUE)
object.seu <- as.Seurat(object.loom)

The last line, however, returns this error:

Error: Cannot find feature names dataset at row_attrs/Gene

The adata file seems to be fine with the row attributes. Anything I am missing?

dm8000 avatar Oct 04 '21 21:10 dm8000

Hi ,I met the same problem. Did you know how to solve it?

Best.

GouQiao avatar Dec 20 '21 01:12 GouQiao

In case you still need this.

pbmc <- as.Seurat(ldat, features = "gene_names",cells = "cell_names")

should work

yaolutian avatar Apr 02 '22 06:04 yaolutian

Hi ,I met the same problem. pbmc <- as.Seurat(ldat, features = "gene_names",cells = "cell_names") This can't work in my case. How to set features and cell.

FanZhang9 avatar May 05 '22 08:05 FanZhang9

Hi ,I met the same problem. pbmc <- as.Seurat(ldat, features = "gene_names",cells = "cell_names") This can't work in my case. How to set features and cell.

I figure out the problem. my directory path contain Chinese letters.

FanZhang9 avatar May 05 '22 11:05 FanZhang9

@FanZhang9 @dm8000 @GouQiao With my friend’s help,I konw reason of this problem. For example, I have anndata object "output" in python: AnnData object with n_obs × n_vars = 3705 × 33538 obs: 'n_counts', 'n_genes', 'organ', 'Sort_id', 'age', 'method', 'sex', 'Sample', 'anno_lvl_2_final_clean', 'celltype_annotation', 'Sample.lanes', 'AnnatomicalPart' var: 'GeneID', 'GeneName', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'scvi_model_var', 'gene_names' uns: 'leiden', 'scvi', 'umap', 'log1p', 'anno_lvl_2_final_clean_colors' obsm: 'X_scvi', 'X_umap' obsp: 'scvi_connectivities', 'scvi_distances'

Specify row_attrs/Gene and col_attrs/CellID in python before write_loom: ouput.obs_names.name = "CellID" # col_attrs/CellID ouput.var['gene_names'] = ouput.var['Gene ']# row_attrs/Gene ouput.write_loom("./ouput.loom")

The reason is that anndata may be due to version issues, the metadata name is different from that specified in the R package, and the correct metadata information cannot be obtained. It needs to be modified before generating the loom file in python: ouput.loom <- Connect(filename = "./ouput.loom", mode = "r") ouput.seurat <- as.Seurat(ouput.loom, features = "Gene",cells = "CellID")

shufanzhang avatar May 18 '23 11:05 shufanzhang

I got the same error when reading in loom file exported by zUMIs. As mentioned above, adding features = "gene_names",cells = "cell_names" seems to make it work.

> packageVersion("SeuratDisk")
[1] ‘0.0.0.9020’
> packageVersion("SeuratObject")
[1] ‘4.1.3’
> packageVersion("Seurat")
[1] ‘4.3.0.1’

royfrancis avatar Aug 05 '23 19:08 royfrancis