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

Support access to raw slot #53

Closed
csoneson opened this issue Jun 1, 2021 · 6 comments
Closed

Support access to raw slot #53

csoneson opened this issue Jun 1, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@csoneson
Copy link

csoneson commented Jun 1, 2021

(As discussed briefly in the Bioc slack).
It would be cool if it was possible to include e.g. adata.raw.X as an assay in the SingleCellExperiment (e.g., when the X matrix in the retrieved AnnData object contains normalized values, but you still want that counts assay). It looks like the raw slot is not a valid AnnData object in itself, so it can't be provided directly to AnnData2SCE():

> class(res)
[1] "anndata._core.anndata.AnnData" "python.builtin.object"        

> AnnData2SCE(res$raw)
Error in py_get_attr_impl(x, name, silent) : 
  AttributeError: 'Raw' object has no attribute 'layers'

However, accessing the matrix directly works

> class(res$raw$X)
[1] "dgRMatrix"
attr(,"package")
[1] "Matrix"
@lazappi lazappi added the enhancement New feature or request label Jun 2, 2021
@lazappi
Copy link
Member

lazappi commented Jun 2, 2021

Any thoughts on where raw should go in the SingleCellExperiment? It doesn't necessarily have the same dimensions as X or layers so it can't always be stored as an assay. Maybe altExp is a better fit?

@csoneson
Copy link
Author

csoneson commented Jun 2, 2021

That would make sense to me - I think the idea of the two (altExp and raw) is also similar, right? An additional "object" of more or less the same type stuck inside the main object :)

@lazappi
Copy link
Member

lazappi commented Jun 2, 2021

👍🏻 Need to double check exactly what can be in raw but in theory I think that will work.

@LTLA
Copy link
Contributor

LTLA commented Jun 2, 2021

As long as it has the same number of columns, you can stick it in an altExp.

The other option would be to store it as a seed in a subsetted DelayedArray, so you can easily get the raw matrix via seed().

@lazappi
Copy link
Member

lazappi commented Oct 20, 2021

This should be working now in devel, you will just need to set raw = TRUE in readH5AD() or AnnData2SCE(). If you test it and run into any issues let us know.

@lazappi lazappi closed this as completed Oct 20, 2021
@csoneson
Copy link
Author

Thank you! I'll give it a try and let you know if I run into problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants