Closed agctu-zhang closed 1 year ago
My apologies! That snippet of code must have been accidentally deleted. We repeated the PHATE+Harmony analysis on other cell types here (https://github.com/mckellardw/scMuscle/blob/main/R_scripts/5S_subcompartment_analysis.R) though. The code you want can be found starting in line 335 (this is the code used for the final manuscript, sorry for the confusion!)
myo.seurat@reductions$harmony@cell.embeddings <-
myo.seurat@reductions$harmony@cell.embeddings[,myo.seurat@reductions$harmony@stdev %>% order(decreasing = T)]
# subset out cells that don't line up
remove.cells <- c(
"oprescu_D2_ACTTTCACATAGGAGC", "oprescu_D2_CCTGCATAGCCTGGAA", "oprescu_D2_CTTCTCTCACATGAAA",
"oprescu_D2_GCACGTGGTACTTCCC", "oprescu_D2_TCTCACGGTGGACCTC", "oprescu_D2_TGGTAGTAGTGAACAT",
"oprescu_D2_TTACGTTAGCGTGAGT"
)
myo.seurat <- subset(
myo.seurat,
cells = Cells(myo.seurat)[!Cells(myo.seurat)%in%remove.cells]
)
# select high stddev dimensions
# n.pcs <- npcs(myo.seurat, reduction = "harmony")
# n.pcs = 32
harmony.dims <- myo.seurat@reductions$harmony@stdev %>% order(decreasing = T)
harmony.dims <- harmony.dims[1:35]
# run PHATE
tmp.phate <- phate(
myo.seurat@reductions$harmony@cell.embeddings[,1:39], #cells x reduc dims
gamma=1,
n.jobs = 50
)
colnames(tmp.phate$embedding) <- paste0("phate_harmony_", 1:2)
tmp.phate$params$data <- NULL
tmp.phate$embedding[,1] <- tmp.phate$embedding[,1]*-1 #flip x-axis
myo.seurat[["phate_harmony"]] <- CreateDimReducObject(
embeddings = tmp.phate$embedding,
key = "phate_harmony_",
assay = 'RNA',
misc = tmp.phate$params
)
myo.seurat@reductions$phate_harmony@stdev <-
apply(myo.seurat@reductions$phate_harmony@cell.embeddings, 2, sd) #find std dev for phate vals
DimPlot(
myo.seurat,
cells=sample(colnames(myo.seurat)),
reduction='phate_harmony',
group.by = 'phate1.bins',
pt.size = 0.5,
# cols=unique(celltype.colors),
label=F
)
Thank you for your reply, it totally solved my problem!
Hello. I read your article and would like to learn how to get phate reduction using harmony data, however, I have some confusion while reading the source code. It is as follows:
Here, perform phate used expression matrix, not used harmony embeddings?
I see "pahte_harmony" appearing here for the first time, but I can't find how to add "phate_harmony", is from "temp.phate"?
I would be very grateful if you could answer my questions!