Skip to content

Instantly share code, notes, and snippets.

@jebard
Last active January 4, 2024 16:14
Show Gist options
  • Save jebard/cea2d161879203ca6e2aa05f32a031bf to your computer and use it in GitHub Desktop.
Save jebard/cea2d161879203ca6e2aa05f32a031bf to your computer and use it in GitHub Desktop.
Seurat to Phate to Seurat
### 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