0
$\begingroup$

I am going to use principal components (PCs) comes from calcPCA function in URD program for clustering my cells in Seurat; So

seurat@dr$pca=URD_object@pca.load

> seurat <- FindClusters(
+     object = seurat, 
+     reduction.type = "pca", 
+     dims.use = 1:8, 
+     resolution = 1.0, 
+     print.output = 0, 
+     save.SNN = TRUE
+ )
Error in GetDimReduction(object = object, reduction.type = reduction.type,  : 
  cell.embeddings slot doesn't exist

There is seuratToURD function but there is not URD to seurat function I guess so I could use URD object for clustering in seurat How I can overcome this error please? I want to see when I am using PCA from URD what would be my clustering by SNN algorithm in seurat

Thanks a lot for any help

$\endgroup$
3
$\begingroup$

There is a way to do this, and even better--there is documentation for how to do it! No surprise coming from the Satija Lab. In the vignette they perform multidimensional scaling, but the idea is the same. cmdscale() returns the cell embeddings. SetDimReduction() is the Seurat function you are looking for. No manual editing using @ required.

The authors use add mds embeddings, but if you want to add your own pca embeddings swap out "mds" for "pca" and mds for URD_object@pca.load.

# Before running MDS, we first calculate a distance matrix between all pairs
# of cells.  Here we use a simple euclidean distance metric on all genes,
# using object@scale.data as input
d <- dist(x = t(x = pbmc@scale.data))
# Run the MDS procedure, k determines the number of dimensions
mds <- cmdscale(d = d, k = 2)
# cmdscale returns the cell embeddings, we first label the columns to ensure
# downstream consistency
colnames(x = mds) <- paste0("MDS", 1:2)
# We will now store this as a new dimensional reduction called 'mds'
pbmc <- SetDimReduction(object = pbmc, reduction.type = "mds", slot = "cell.embeddings", 
    new.data = mds)
pbmc <- SetDimReduction(object = pbmc, reduction.type = "mds", slot = "key", 
    new.data = "MDS")

See the dimensional reduction vignette for more.

$\endgroup$
  • $\begingroup$ Thank you, but I have already demential reduction matrix (PCs) by another program (URD) and I want to store that in Seurat object for clustering $\endgroup$ – Angel Oct 24 '18 at 15:13
  • $\begingroup$ In SetDimReduction() replace "mds" with "pca" and mds with URD_object@pca.load. $\endgroup$ – Kohl Kinning Oct 24 '18 at 15:17
  • 1
    $\begingroup$ Thank you > pbmc <- SetDimReduction(object = seuset, reduction.type = "pca", slot = "cell.embeddings", + new.data = URD@pca.scores) Show Traceback Rerun with Debug Error in (function (cl, name, valueClass) : ‘cell.embeddings’ is not a slot in class “data.frame” > $\endgroup$ – Angel Oct 24 '18 at 15:27
  • $\begingroup$ Try str(seuset) to ensure your Seurat object is whole. You might also RunPCA() within Seurat and return to cell.embeddings to ensure the format of your external embeddings is identical. I'd also recommend changing reduction.type="pca" to something like reduction.type="pca.external" just to ensure you aren't dealing with some protected fields in the S4 object. $\endgroup$ – Kohl Kinning Oct 26 '18 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.