This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Doheatmap in seurat

enter image description here

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")
seurat doheatmap

2 answers

c1$Sample_name <- factor(c1$Sample_name, levels = c("WT", "CFAP", "NM", "BGH"))

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.
upvote_bookmark_accept

You need to order the sample names as follows and DoHeatmap.

c1$Sample_name <- factor(c1$Sample_name, levels = c("WT","CFAP","NM","BGH."))

p <- DoHeatmap(c1, features = gene_ordernames, group.by = "Sample_name")

Thank you very much

Log in to answer this question.