yanwu2014 / swne

Similarity Weighted Nonnegative Embedding (SWNE), a method for visualizing high dimensional datasets
BSD 3-Clause "New" or "Revised" License
103 stars 20 forks source link

Error in as(object@graphs$RNA_snn, "dgCMatrix") #25

Closed trueth1206 closed 5 years ago

trueth1206 commented 5 years ago

Thank you for creating this package. I tried to run it using a Seurat objet.

library(Seurat) library(swne) obj <- readRDS(file = "obj.rds") clusters <- obj$seurat_clusters genes.embed <- c("ENSMUSG00000031766", "ENSMUSG00000041644", "ENSMUSG00000001025", "ENSMUSG00000030963", "ENSMUSG00000032060", "ENSMUSG00000026726", "ENSMUSG00000027202", "ENSMUSG00000062209", "ENSMUSG00000054640", "ENSMUSG00000027070", "ENSMUSG00000041959", "ENSMUSG00000060803", "ENSMUSG00000097830") swne.embedding <- RunSWNE(obj, k = 16, genes.embed = genes.embed)

Then I've got the following error: Error in as(object@graphs$RNA_snn, "dgCMatrix") : no method or default for coercing “NULL” to “dgCMatrix”

Is there anyway to solve this issue? Thank you very much!

yanwu2014 commented 5 years ago

Hi, can you check if your Seurat object was generated with Seurat V3?

Also, make sure that the SNN was actually built with FindNeighbors. Something like:

obj <- FindNeighbors(obj, dims = 1:20)

Let me know if that works!

trueth1206 commented 5 years ago

Hi, Thank you for you replay. Yes I am using Seurat V3. The issue occurred while I used a V3 object generated by integrating 4 samples (after FindIntegrationAnchors, IntegrateData, RunUMAP, FindNeighbors and FindClusters). If I use a V3 object generated by analyzing one sample, the swne run smoothly and showed good picture.
Is there any way to apply swne on a Seurat object with integrated samples? Thank you very much.

yanwu2014 commented 5 years ago

Ah so RunSWNE doesn't work on integrated Seurat objects yet, hopefully I'll have that functionality up soon.

For now, try using this walkthrough: https://yanwu2014.github.io/swne/Examples/multiple_pancreas_alignment_swne.html

trueth1206 commented 5 years ago

Hi, it works well with the workflow you provided. Thank you very much for your help.