Single cell analysis #7 데이터 시각화 (heatmap)

#6번의 과정을 통해 clustering generation을 완료한 이후, top-down gene 유전자를 분석하고 시각화하는 코드는 아래와 같음.


# combine된 데이터가 있다는 가정하에 다음 분석 수행

table(seurat_combined$orig.ident)


seurat_combined$sample <- ifelse(seurat_combined$orig.ident == "ht04", "ht04", "other")


# sample 컬럼 확인

table(seurat_combined$sample)


Idents(seurat_combined) <- "sample"


# 데이터 레이어 결합

seurat_combined <- JoinLayers(seurat_combined)


markers_ht04 <- FindMarkers(seurat_combined, ident.1 = "ht04", ident.2 = "other")


top_markers_ht04 <- markers_ht04 %>%

filter(p_val_adj < 0.05) %>%

top_n(10, avg_log2FC)


#내가 원하는 유전자 expression 관찰

FeaturePlot(seurat_combined, features = c("CDKN1A", "CDKN1B", "PMAIP1", "BBC3"), reduction = "umap", split.by = "orig.ident", ncol=2)


# 상위 20개 유전자 선택

top_genes <- rownames(markers_ht04[order(markers_ht04$avg_log2FC, decreasing = TRUE), ])[1:100]


# 하위 20개 유전자 선택

bottom_genes <- rownames(markers_ht04[order(markers_ht04$avg_log2FC, decreasing = FALSE), ])[1:100]


# 상위 및 하위 유전자 결합

selected_genes <- c(top_genes, bottom_genes)


# 상하위 유전자를 모두 포함한 heatmap 그리기

DoHeatmap(seurat_combined, features = selected_genes, group.by = "orig.ident") + NoLegend()


만약 유전자의 expression이 낮거나, 분석한 data set에서 없는 expression이 없는 유전자가 있다면 R console 창에 경고가 뜰텐데, 이에 대한 개별 expression을 보고자 하면 아래의 코드를 실행하면 됌.


# 유전자가 RNA assay의 데이터에 존재하는지 확인

missing_genes <- selected_genes[!selected_genes %in% rownames(seurat_combined[["RNA"]]@layers$scale.data)]

missing_genes


# 유전자 발현 확인

VlnPlot(seurat_combined, features = missing_genes)

댓글

이 블로그의 인기 게시물

#single cell sequencing 기초 분석 - #1 R 설치 및 package 설치

리눅스 기초 #10 GATK calling을 사용하기 위하여, reference file indexing하는 방법

Single cell 분석을 위한 package 소개