Entering edit mode
13 months ago
odi
▴
10
Hi guys (sorry I cannot show the full heatmap as it is about to be in a paper),
I am trying to reorder this heatmap's identity where instead of BGH>CFAP>NM>WT we have WT>CFAP>NM>BGH.
How do I do that in doheatmap? Here is the code that gave me this order:
c1 <- subset(trac_all_cc, idents = "1")
c1 <- ScaleData(c1, features = NULL, assay = "SCT")
c1_df <- as.data.frame(c1@assays$SCT@scale.data) |> tibble::rownames_to_column() |> filter(rowname %in% top50$gene)
c1_df <- c1_df |> tibble::column_to_rownames() #genes back to rownames
d <- dist(c1_df, method = "euclidean")
hc <- hclust(d, method = "ward.D2")
gene_order <- hc$order
gene_ordernames <- rownames(c1_df)[gene_order]
p <- DoHeatmap(c1, features = gene_ordernames, group.by = "Sample_name")
thank you very much!
A small educational note: if an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one answer if they all work. If an answer was not really helpful or did not work, provide detailed feedback so others know not to use that answer.