Question: Making a 3d tSNE Plot in Seurat for scRNA-seq
2
gravatar for asyndeton17
2.8 years ago by
asyndeton1740
asyndeton1740 wrote:

Hi,

Is there an easy way to make a 3D tSNE plot of the single cell clusters in Seurat?

Thanks

seurat rna-seq tsne scrna-seq • 6.5k views
ADD COMMENTlink modified 12 months ago by DrAcula40 • written 2.8 years ago by asyndeton1740

Is there a way to do so with another package?

ADD REPLYlink written 2.7 years ago by asyndeton1740
2
gravatar for garyhokawai
2.6 years ago by
garyhokawai30
garyhokawai30 wrote:

I tried solution from halo22, it didn't work. However, I somehow figured it out myself.

#3d tsne projection
yourseuratobject <- RunTSNE(object = yourseuratobject, dims.use = 1:n, do.fast = TRUE, dim.embed = 3)

tsne_1 <- yourseuratobject@dr$tsne@cell.embeddings[,1]

tsne_2 <- yourseuratobject@dr$tsne@cell.embeddings[,2]

tsne_3 <- yourseuratobject@dr$tsne@cell.embeddings[,3]

library(scatterplot3d)

scatterplot3d(x = tsne_1, y = tsne_2, z = tsne_3, color = as.numeric(1:n)[yourseuratobject@ident])

library(rgl) #interactive 3d plotting

plot3d(x = tsne_1, y = tsne_2, z = tsne_3, col = as.numeric(1:n)[yourseuratobject@ident], type="s",radius=0.3)

rgl::rglwidget() #save as html

PS: tsne coordinates are stored in yourseuratobject@dr$tsne@cell.embeddings cluster identity by SNN is store in yourseuratobject@ident

ref. https://github.com/jkrijthe/Rtsne/issues/12

Hope this would help!

Gary

ADD COMMENTlink modified 2.6 years ago by WouterDeCoster43k • written 2.6 years ago by garyhokawai30

I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

ADD REPLYlink written 2.6 years ago by WouterDeCoster43k
1
gravatar for halo22
2.7 years ago by
halo22140
Indianapolis, IN
halo22140 wrote:

You can use the R-package tsne to do this https://cran.r-project.org/web/packages/tsne/tsne.pdf

For your analysis you will have to figure out what input to provide to tSNE, ideally PC's obtained from seurat are the suggested input but you can also use your variable genes with scaled values.

ADD COMMENTlink written 2.7 years ago by halo22140
2

A bit late by now, but I think the R package Rtsne is preferable over tsne since it is faster being a wrapper over C++ code.

ADD REPLYlink written 2.6 years ago by dariober11k
0
gravatar for DrAcula
12 months ago by
DrAcula40
University of Miami
DrAcula40 wrote:

I know this is old now. But Ive written some code which will help you create a 3D expression plot using plotly out of a seurat v3.0.0 object. Dont forget to star and fork :)

Find the complete solution here: https://github.com/Dragonmasterx87/3D-Plotting-in-Seurat-3.0.0

Update: The code now supports UMAP 3D clustering as well :)

ADD COMMENTlink modified 7 months ago • written 12 months ago by DrAcula40
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1064 users visited in the last hour