scverse / anndata

Annotated data.
http://anndata.readthedocs.io
BSD 3-Clause "New" or "Revised" License
577 stars 153 forks source link

read_loom: "Error: data must be 1-dimensional" #305

Open ts3139 opened 5 years ago

ts3139 commented 5 years ago

Hi all,

I am trying to convert a Seurat object to a loom file in order to do a more comprehensive analysis in Scanpy. However, I am running into several issues (yes, I have gone through all the previous posts with these issues and tried all the suggestions). I am using the latest Seurat and Scanpy, as well as latest versions of all dependencies. The following are my issues:

When using the as.loom function, I am able to successfully generate a loom file. When inputting into Scanpy, I first get the error "column index exceeds matrix dimensions".

Using suggestions from others, I removed the graphs slot in the original Seurat object and remade the loom file and ran it again. Only to get an error stating that "data must be 1-dimensional".

I have updated all my versions of every dependency, and honestly I am at wit's end trying to figure this out and get an analysis completed asap for my PI.

Any help and insight would be greatly appreciated. Thanks!

LuckyMD commented 5 years ago

Hi, Before posting an issue, it is good to check what issues have already been posted. This is being discussed in theislab/scanpy#598, and the same issue is also reported in theislab/scanpy#649. I would look there. I'm not sure this has been solved for everyone though, but there is a workaround there I think.

Another possibility to go between Seurat and Scanpy is to use anndata2ri and Seurat's convert() function to go from a Seurat object to a SingleCellExperiment object, and from there to AnnData via anndata2ri in a jupyter notebook with R magics.

ts3139 commented 5 years ago

Hi,

I did have a look at those threads and the issue was more or less unresolved. I am actually in the process of trying your suggestion right now. Will update in a bit if it works! Thanks!

fidelram commented 5 years ago

Can you open the Seurat saved loom file using loompy in python? That would allow you to check that you have a properly formatted .loom file.

PedroRaposo commented 5 years ago

Hi @fidelram, I have the same issue and I can successfully open the .loom file with loompy.

>>> import loompy
>>> mouse = loompy.connect("/home/AD/praposo/mouse_3.loom")
>>> mouse[: , :]
array([[1., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       ...,
       [0., 0., 0., ..., 2., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.]])

So it suggests the problem lies in scvelo, I guess. What do you think?

fidelram commented 5 years ago

Can you post this as an issue in AnnData ( https://github.com/theislab/anndata) documenting that you can open the loom file with loompy? That would be the right place to address this.

On Thu, May 23, 2019 at 12:16 PM PedroRaposo notifications@github.com wrote:

Hi @fidelram https://github.com/fidelram, I have the same issue and I can successfully open the .loom file with loompy.

import loompy mouse = loompy.connect("/home/AD/praposo/mouse_3.loom") mouse[: , :] array([[1., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 2., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]])

So it suggests the problem lies in scvelo, I guess. What do you think?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/theislab/scanpy/issues/652?email_source=notifications&email_token=ABF37VLPGQD3E3V22ZVU3ILPWZVIZA5CNFSM4HNP4AJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWBYLPI#issuecomment-495158717, or mute the thread https://github.com/notifications/unsubscribe-auth/ABF37VJKVSSGN5CM6AJSBG3PWZVIZANCNFSM4HNP4AJQ .

--

Fidel Ramirez

LuckyMD commented 5 years ago

Btw, I wrote a quick example for how to go between Seurat objects and AnnData in a jupyter notebook using anndata2ri. You can find it here

ts3139 commented 5 years ago

Hey guys,

So I finally got around to testing the code using anndata2ri posted by @LuckyMD and it works really well! The only issue is you can do your Seurat analysis in Jupyter notebook up until RunUMAP (Seurat). If you try to run the Seurat RunUMAP command in the Jupyter Notebook, it crashes (at least on my laptop). Other wise, works really well to convert to AnnData. Thanks!!!!

flying-sheep commented 5 years ago

Sounds like it runs out of memory, no?

I’m happy that my anndata2ri works for you!

JuHey commented 4 years ago

I am facing the same issue: I am trying to open a name.loom file using sc.read_loom("name.loom") and get the same error message as seen by @ts3139 ie, "data must be 1-dimensional". I looked into the python packages but could not find an obvious culprit. Here are the relevant packages that I inspected: scanpy==1.4.4.post1 anndata==0.7.1 umap==0.3.10 numpy==1.18.1 scipy==1.3.0 pandas==0.25.3 scikit-learn==0.22.1 statsmodels==0.10.2 loompy ==3.06. I can open the .loom file without issues when applying loompy.connect("name.loom"). It is also not specific to the said .loom file. Other .loom files fail too. This is also not the result from converting from Seurat to Scanpy; I simply like to read the loom file into adata. Any suggestions/ideas?

flying-sheep commented 4 years ago

You need to give us more to work with if you want us to be able to help.

Can you e.g. share the loom file? If not, can you subset it or otherwise create a loom file that you can share here but still can’t load using anndata.read_loom?

LuckyMD commented 4 years ago

the anndata2ri approach isn't working either?

flying-sheep commented 4 years ago

We want to fix this in any case, read_loom should read all loom files.