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

Seurat V3 Workflow #23

Closed hgb1111 closed 5 years ago

hgb1111 commented 5 years ago

I ran the code you sent

AssayData(se.obj, slot = "counts") <- FilterData(AssayData(se.obj, slot = "counts"), min.samples.frac = 0.0025, min.nonzero.features = 200, trim = 0.0025)

and got the following error

Error in AssayData(se.obj, slot = "counts") : could not find function "AssayData"

I have loaded swne, Seurat, Matrix, ggplot2. what package isnt loaded?

yanwu2014 commented 5 years ago

Ah sorry it should be GetAssayData instead of AssayData. Let me know if that works!

hgb1111 commented 5 years ago

It still did not work :/

`

AssayData(se.obj, slot = "counts") <- FilterData(GetAssayData(se.obj, slot = "counts"), min.samples.frac = 0.0025, min.nonzero.features = 200, trim = 0.0025)

Error in AssayData(se.obj, slot = "counts") <- FilterData(GetAssayData(se.obj, :

could not find function "AssayData<-"

GetAssayData(se.obj, slot = "counts") <- FilterData(GetAssayData(se.obj, slot = "counts"), min.samples.frac = 0.0025, min.nonzero.features = 200, trim = 0.0025)

Error in GetAssayData(se.obj, slot = "counts") <- FilterData(GetAssayData(se.obj, :

could not find function "GetAssayData<-"`

yanwu2014 commented 5 years ago

Are you sure you have Seurat V3 installed? Also it should be:

SetAssayData(se.obj, slot = "counts") <- FilterData(GetAssayData(se.obj, slot = "counts"), min.samples.frac = 0.0025, min.nonzero.features = 200, trim = 0.0025)
hgb1111 commented 5 years ago
> SetAssayData(se.obj, slot = "counts") <- FilterData(GetAssayData(se.obj, slot = "counts"), min.samples.frac = 0.0025, min.nonzero.features = 200, trim = 0.0025)

#Error in SetAssayData(se.obj, slot = "counts") <- FilterData(GetAssayData(se.obj,  : 
  could not find function "SetAssayData<-"

> packageVersion("Seurat")
[1] ‘3.0.2’

I do not think you can use the AssayData() commands in the way you have described above.

hgb1111 commented 5 years ago

I have also tried running through the Gene Expression Quickstart with Seurat, but run into an error where the "RunSWNE" does not seem to be compatible with a seurat v3 object.

## Load object
load("/path/Ma_Vasc_6_res0.75.Robj")
obj <- Ma_Vasc_6_res0.75

## Extract clusters
clusters <- obj$seurat_clusters

## Select genes to embed
genes.embed <- c("Aplnr", "Apln", "Cryab", "Gata5", "Pi16")

## Run SWNE
swne.embedding <- RunSWNE(obj, k = 16, genes.embed = genes.embed)

Error in UseMethod("RunSWNE") : 
  no applicable method for 'RunSWNE' applied to an object of class "Seurat"

packageVersion("Seurat")
# ‘3.0.2’
packageVersion("swne")
# ‘0.2.21’
yanwu2014 commented 5 years ago

Ahh sorry you're right. For the filtering it should be something more like:

counts <- FilterData(GetAssayData(se.obj, slot = "counts"), min.samples.frac = 0.0025, min.nonzero.features = 200, trim = 0.0025)
se.obj <- SetAssayData(se.obj, slot = "counts", new.data = counts)
yanwu2014 commented 5 years ago

Oh so the latest version of swne should be 0.5.6. Can you try reinstalling it and see if RunSWNE works then?

hgb1111 commented 5 years ago

Certainly, is swne 0.5.6 only available for R version 3.6.1? I just tried installing on R 3.5.1 and R 3.5.3 and neither worked.

Thanks!

yanwu2014 commented 5 years ago

Ah sorry yeah I built it on R3.6 so I think >= R3.6.1 is necessary for installation

hgb1111 commented 5 years ago

I updated to R version 3.6.1 (2019-07-05) -- "Action of the Toes" but am unfortunately still encountering the same error :/

install.packages("swne")
Warning in install.packages :
  package ‘swne’ is not available (for R version 3.6.1)

This does not appear to be a problem with other packages (Seurat, ggplot2)

yanwu2014 commented 5 years ago

swne is not on CRAN so you can't use install.packages. You can install it with devtools using the instructions on this github page

hgb1111 commented 5 years ago

Ahh, that fixed the issue - my mistake for not seeing that earlier. I was able to work through swne with a seurat v3 object.

Thanks!

yanwu2014 commented 5 years ago

Great! Let me know if you have any other issues!