Last active
January 4, 2024 16:14
-
-
Save jebard/cea2d161879203ca6e2aa05f32a031bf to your computer and use it in GitHub Desktop.
Seurat to Phate to Seurat
This file contains hidden or 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
### handles the Seurat to phate conversio | |
### first, grab the input required for phate (here we are using the normalized data stored in Seurat | |
seurat_data <- as.data.frame(seurat.object@assays$RNA@data) | |
## reshape for input into PHATE | |
phate_data_input <- t(seurat_data) | |
## run phate -- this is a default run, feel free to tune params | |
phate_output <- phate(phate_data_input) | |
## quick sanity check of the phate embeddings | |
ggplot(phate_output, aes(x=PHATE1, y=PHATE2)) + | |
geom_point() | |
## stash the embeddings back into the seurat object as a dimension reduction object | |
seurat.object[["PHATE"]] <- CreateDimReducObject(embeddings = phate_output$embedding, key = "PHATE_", assay = DefaultAssay(seurat.object)) | |
## plot using seurat's default tools | |
DimPlot(seurat.object , reduction = "PHATE") + ggtitle(label = "PHATE") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment