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

How to add loom assays to Seurat object: Error in UseMethod(generic = "as.sparse", object = x) : no applicable method for 'as.sparse' applied to an object of class "Assay"? #7276

Closed
denvercal1234GitHub opened this issue May 4, 2023 · 1 comment

Comments

@denvercal1234GitHub
Copy link

denvercal1234GitHub commented May 4, 2023

Hi there,

I had loom objects for different samples generated by velocyto, and a Seurat object that had been fully analysed (with SCTransform clustering and UMAP etc).

I was able to concatenate my loom objects into 1 object and converted it to Seurat object, but this object has not been in anyway processed (e.g., normalise etc that are typically done in scVelo pipeline).

How might I add the ambiguous, matrix, spliced, unspliced to my Seurat GEX cluster object? Do I do as below?

test[["ambiguous"]] <- CreateAssayObject(counts = concat_adata_Seurat@assays$ambiguous)
test[["matrix"]] <- CreateAssayObject(counts = concat_adata_Seurat@assays$matrix)
test[["spliced"]] <- CreateAssayObject(counts = concat_adata_Seurat@assays$splice)

Doing this gave me error however "Error in UseMethod(generic = "as.sparse", object = x) : no applicable method for 'as.sparse' applied to an object of class "Assay""

Thank you for your help!

My Seurat GEX cluster object:
Screenshot 2023-05-04 at 18 55 55

My loom-converted Seurat object:
Screenshot 2023-05-04 at 18 56 04

Posted zhanghao-njmu/SCP#130

@denvercal1234GitHub denvercal1234GitHub changed the title How to add loom assays to Seurat object? How to add loom assays to Seurat object: Error in UseMethod(generic = "as.sparse", object = x) : no applicable method for 'as.sparse' applied to an object of class "Assay"? May 4, 2023
@AustinHartman
Copy link
Contributor

It looks like you are providing full Assays to CreateAssayObject via the counts parameter. You should be able to edit your code to either of the following:

test[["ambiguous"]] <- concat_adata_Seurat@assays$ambiguous

test[["ambiguous"]] <- CreateAssayObject(counts = concat_adata_Seurat@assays$ambiguous@counts)

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

No branches or pull requests

2 participants