-
-
Save Dragonmasterx87/e254e034da0d4c8c31815563aa11c18e to your computer and use it in GitHub Desktop.
3D Plot for Seurat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
counts.seurat <- RunTSNE(counts.seurat, | |
reduction.use = "pca", | |
dims.use = 1:6, | |
dim.embed = 3) | |
DimPlot(object = counts.seurat, reduction.use = "tsne", dim.1 = 1, dim.2 = 3) | |
tSNE_1 <- counts.seurat@dr$tsne@cell.embeddings[,1] | |
tSNE_2 <- counts.seurat@dr$tsne@cell.embeddings[,2] | |
tSNE_3 <- counts.seurat@dr$tsne@cell.embeddings[,3] | |
TSNEPlot(counts.seurat) | |
color_scheme <- as.numeric(1:14)[counts.seurat@ident] | |
for(i in 1:1521){ | |
if(color_scheme[i] == 1){ | |
color_scheme[i] <- "#F8766D" | |
}else if(color_scheme[i] == 2){ | |
color_scheme[i] <- "#E38900" | |
}else if(color_scheme[i] == 3){ | |
color_scheme[i] <- "#C49A00" | |
}else if(color_scheme[i] == 4){ | |
color_scheme[i] <- "#99A800" | |
}else if(color_scheme[i] == 5){ | |
color_scheme[i] <- "#53B400" | |
}else if(color_scheme[i] == 6){ | |
color_scheme[i] <- "#00BC56" | |
}else if(color_scheme[i] == 7){ | |
color_scheme[i] <- "#00C094" | |
}else if(color_scheme[i] == 8){ | |
color_scheme[i] <- "#00BFC4" | |
}else if(color_scheme[i] == 9){ | |
color_scheme[i] <- "#00B6EB" | |
}else if(color_scheme[i] == 10){ | |
color_scheme[i] <- "#06A4FF" | |
}else if(color_scheme[i] == 11){ | |
color_scheme[i] <- "#A58AFF" | |
}else if(color_scheme[i] == 12){ | |
color_scheme[i] <- "#DF70F8" | |
}else if(color_scheme[i] == 13){ | |
color_scheme[i] <- "#FB61D7" | |
}else if(color_scheme[i] == 14){ | |
color_scheme[i] <- "#FF66A8" | |
}else{NULL} | |
} | |
library(rgl) | |
plot3d(x = tSNE_1, y = tSNE_2, z = tSNE_3, | |
col = color_scheme, | |
type = "s", size = 0.3, box = FALSE) | |
rgl::rglwidget("~/Desktop/tSNE_3dplot.html") #save as html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment