Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in if (ncol(m)) { : argument is of length zero #113

Open
spatts14 opened this issue Mar 15, 2024 · 8 comments
Open

Error in if (ncol(m)) { : argument is of length zero #113

spatts14 opened this issue Mar 15, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@spatts14
Copy link

spatts14 commented Mar 15, 2024

Hi! I commented on an enhancement in issues as I originally thought it might be an issue of my spatial experiment, however I'm wondering if this is a separate issue.

I tried to convert the spe into a sce object, which worked. However, when I then tired to convert it into an anndata object, I got the error below. This also happened when I tired to go directly from spe --> anndata object. I also tried both writeH5AD and SCE2AnnData, and got the error function for all of them.

It doesn't seem like anything is wrong with me spe object as I can visualize a variety of outputs in R. Apologies in advance if this is a silly question - I am still very new to CS/DS/bioinformatics etc.

# Import data
spe <-readRDS( "path/spe_backup.rds")

# look at spe (SpatialExperiment)
class(spe) 
str(spe)

# Convert spe to sce
sce <- as(spe, "SingleCellExperiment")

# Convert Anndata object
writeH5AD(sce, file = out_path)

# Convert to Anndata object
adata <- SCE2AnnData(sce)

I got an error of the following trying both approaches

ℹ Using the 'counts' assay as the X matrix
Error in if (ncol(m)) { : argument is of length zero

I also tried looking in the source code of both functions to try to see where things were going wrong but I could not figure it out.

Thanks for your help!

@lazappi lazappi added the bug Something isn't working label Mar 18, 2024
@lazappi
Copy link
Member

lazappi commented Mar 18, 2024

Hi @spatts14

That does seem like something that should be checked. Can you confirm which dataset you are trying here? I wasn't able to work it out from the links you sent in #61. Even better would be if you could share the .rds file you have here if it isn't too big.

Could you also please check what is returned by counts(sce)? It's hard to say without access to the data but my guess is that is empty for some reason.

@spatts14
Copy link
Author

spatts14 commented Mar 18, 2024

Hi @lazappi,

I was trying a dataset in the group, but also tried the dataset that I had shared in #61.
I've checked both the dataset from our group as well as the Bodenmiller dataset. Both are non-empty.

I have also tried to add the .RDS files, but it says it does not support the file type. I am happy to send them via email or some other method that suits you best.

sce <- as(spe, "SingleCellExperiment")

@lazappi
Copy link
Member

lazappi commented Mar 19, 2024

If you could put them on some kind of file sharing system (Google Drive, OneDrive, Dropbox etc.) and put a link here that would be great.

Or if you could share the minimal code required to go from the raw Bodenmiller data to the object you are testing that would also be helpful (as long as it's not too complex).

@spatts14
Copy link
Author

@lazappi
Copy link
Member

lazappi commented Mar 20, 2024

I wasn't able to access it currently. I sent an access request but it might be easier to make it public if there is nothing confidential in the data.

@spatts14
Copy link
Author

Apologies, I thought it was public. Should be public now - please let me know if there is any issues.

@lazappi
Copy link
Member

lazappi commented Mar 21, 2024

Thanks for the data! That was super helpful for working out what the issue was.

I have tracked it down to the colPairs() function in the {SingleCellExperiment} package and have opened an issue there drisso/SingleCellExperiment#73. Depending on how they decide to handle it I may make changes to {zellkonverter}.

In the meantime you can avoid the error but doing something like:

mcols(colPairs(sce)[[1]])$value <- 1

NOTE: This will give you an obsp graph with all the edge weights set to 1 in the file .h5ad file.

@spatts14
Copy link
Author

Thanks so much! That worked for us!

Thank you for making the note about the change in edge weights being set to 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants