Slot to pull data from for DoHeatmap
1
0
Entering edit mode
6 months ago
bio_info ▴ 20

I am carrying out some scRNA-seq analysis in Seurat and I have made a pseudobulk of my data, transformed the count data using round() (as the count data was not all integer) and run FindMarkers using DESeq2 and sorted by log2_FC. Now I want to visualise the output in the form of a hierarchial heatmap.

My question is, which slot do I pull the data from the Seurat object? If I use scale.data then I loose a lot of genes which are not scaled, if I use slots counts or data then the heatmap just looks weird and nothing looks differentially expressed. Does anyone have a solution to this problem?

DESeq2 DoHeatmap Seurat Pseudobulk • 906 views
ADD COMMENT
1
Entering edit mode
6 months ago
bk11 ★ 3.0k

I would use data from Seurat object and perform a Hierarchical Clustering using Complexheatmap.

library(Seurat)
library(SeuratData)
library(dplyr)
library(ComplexHeatmap)


data=UpdateSeuratObject(pbmc3k.final)
all.markers=FindAllMarkers(object=data)

all.markers %>%
  group_by(cluster) %>%
  dplyr::filter(avg_log2FC > 1 & p_val_adj < 0.05) %>%
  slice_head(n = 10) %>%
  ungroup() -> top10
head(top10)

mat<- data[["RNA"]]@data[c(top10$gene), ] %>% as.matrix()
mat[1:5, 1:5]

## scale the rows
mat<- t(scale(t(mat)))
mat[1:5, 1:5]

cluster_anno<- data@meta.data$seurat_annotations
quantile(mat, c(0.1, 0.95))

Seurat::PurpleAndYellow()
## make the black color map to 0. the yellow map to highest and the purle map to the lowest
col_fun = circlize::colorRamp2(c(-1, 0, 2), c("#FF00FF", "black", "#FFFF00"))

Heatmap(mat, name = "Expression",  
        column_split = factor(cluster_anno),
        cluster_columns = TRUE,
        show_column_dend = FALSE,
        cluster_column_slices = TRUE,
        column_title_gp = gpar(fontsize = 8),
        column_gap = unit(0.5, "mm"),
        cluster_rows = TRUE,
        show_row_dend = FALSE,
        col = col_fun,
        row_names_gp = gpar(fontsize = 4),
        column_title_rot = 90,
        top_annotation = HeatmapAnnotation(foo = anno_block(gp = gpar(fill = scales::hue_pal()(9)))),
        show_column_names = FALSE,
        use_raster = TRUE,
        raster_quality = 4)

enter image description here

ADD COMMENT
0
Entering edit mode

Thanks for the help, much appreciated!

ADD REPLY
0
Entering edit mode

use the data slot, and as shown in the code, you then scale it by yourself.

ADD REPLY

Login before adding your answer.

Traffic: 1857 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6