繪圖
1.降維圖形繪制
降維圖可以通過plot_scdata()
函數(shù)繪制:
plot_scdata(scRNA_int, pal_setup = pal)
plot_scdata()
有三個可選參數(shù):color_by
赚导,split_by
击费,和pal_setup
烹困。至于color_by
參數(shù)莫其,默認(rèn)情況下魂迄,這個函數(shù)會給不同的"seurat_clusters"
上色粗截,并且它可以被修改為metadata中的任何因素,比如"sample"
或"group"
:
plot_scdata(scRNA_int, color_by = "group", pal_setup = pal)
如果split_by
參數(shù)被指定為metadat中的一個因子熊昌,圖形將被該因子分割成不同的塊(可參考ggplot2分面):
plot_scdata(scRNA_int, split_by = "sample", pal_setup = pal)
與plot_qc()
函數(shù)類似湿酸,pal_setup
參數(shù)可以是RColorBrewer
調(diào)色板名稱婿屹、調(diào)色板設(shè)置數(shù)據(jù)框或手動指定的顏色向量。
plot_scdata(scRNA_int, pal_setup = "Dark2")
plot_scdata(scRNA_int, color_by = "sample", pal_setup = c("red","orange","yellow","green","blue","purple"))
2.統(tǒng)計數(shù)據(jù)繪制
集群的計數(shù)和比例統(tǒng)計可以通過函數(shù)plot_stat()
繪制蜂奸,plot_type
參數(shù)必須提供為三個值之一:“group_count”
犁苏、“prop_fill”
和“prop_multi”
。他們的圖表如下:
plot_stat(scRNA_int, plot_type = "group_count")
plot_stat(scRNA_int, "group_count", group_by = "seurat_clusters", pal_setup = pal)
plot_stat(scRNA_int, plot_type = "prop_fill",
pal_setup = c("grey90","grey80","grey70","grey60","grey50","grey40","grey30","grey20"))
plot_stat(scRNA_int, plot_type = "prop_multi", pal_setup = "Set3")
該group_by
參數(shù)"sample"
用作默認(rèn)分組變量扩所,并且可以指定為元數(shù)據(jù)中的其他因素(例如 "group"
)围详。
plot_stat(scRNA_int, plot_type = "prop_fill", group_by = "group")
plot_stat(scRNA_int, plot_type = "prop_multi", group_by = "group", pal_setup = c("sienna","bisque3"))
3.熱圖繪制
熱圖的繪制需要 Seurat 找到聚類標(biāo)記:
markers <- FindAllMarkers(scRNA_int, logfc.threshold = 0.1, min.pct = 0, only.pos = T)
然后,用plot_heatmap()
繪制每個聚類中的top基因祖屏。每個群集n中繪制的基因數(shù)量的默認(rèn)值是8助赞。在熱圖中,每一行代表一個基因袁勺,每一列代表一個細(xì)胞雹食。細(xì)胞可以按sort_var
排序,如果默認(rèn)設(shè)置為c("seurat_clusters")
期丰,這意味著細(xì)胞按集群標(biāo)識排序群叶。可以在sort_var中
指定多個變量咐汞,細(xì)胞將按變量的順序排序盖呼。熱圖上方是注釋欄,可以通過指定anno_var
參數(shù)顯示metadata數(shù)據(jù)中的分類或連續(xù)變量化撕,變量名作為字符向量。anno_colors
參數(shù)是一個列表约炎,它為相應(yīng)的注釋變量指定注釋顏色植阴,因此它應(yīng)該與anno_var
相同的長度。建議對分類變量和連續(xù)變量使用適當(dāng)?shù)恼{(diào)色板圾浅。和前面一樣掠手,支持RColorBrewer調(diào)色板和手工指定的調(diào)色板,并且三色向量可以用于連續(xù)變量注釋狸捕。
plot_heatmap(dataset = scRNA_int,
markers = markers,
sort_var = c("seurat_clusters","sample"),
anno_var = c("seurat_clusters","sample","percent.mt","S.Score","G2M.Score"),
anno_colors = list("Set2", # RColorBrewer palette
c("red","orange","yellow","purple","blue","green"), # color vector
"Reds",
c("blue","white","red"), # Three-color gradient
"Greens"))
此外喷鸽,hm_limit
和hm_colors
用于指定熱圖主體的顏色梯度和限制。
plot_heatmap(dataset = scRNA_int,
n = 6,
markers = markers,
sort_var = c("seurat_clusters","sample"),
anno_var = c("seurat_clusters","sample","percent.mt"),
anno_colors = list("Set2",
c("red","orange","yellow","purple","blue","green"),
"Reds"),
hm_limit = c(-1,0,1),
hm_colors = c("purple","black","yellow"))
4.GO分析
GO分析結(jié)果可以通過plot_cluster_go()和
plot_all_cluster_go()繪制灸拍。前者繪制一個特定的集群做祝,而后者迭代所有集群。
plot_cluster_go()中的
topn參數(shù)指定用于GO分析的top基因的數(shù)量鸡岗,默認(rèn)值為100混槐。
org參數(shù)指定生物體,
“human”和
“mouse”是可接受的值轩性。
plot_all_cluster_go()是
plot_cluster_go()的包裝器声登,后者又是
clusterProfilter:: richgo()`的包裝器。因此,…參數(shù)可以傳遞給內(nèi)部函數(shù)。
plot_cluster_go(markers, cluster_name = "1", org = "human", ont = "CC")
plot_all_cluster_go(markers, org = "human", ont = "CC")
5.Measures繪圖
Measures被定義為metadata中的連續(xù)變量以及基因表達(dá)值悯嗓。plot_measure()
和plot_measure_dim()
將這些變量分別歸納為箱線圖件舵、小提琴圖和降維圖。像group_by
脯厨、split_by
和pal_setup
這樣的參數(shù)可以像上面描述的那樣使用芦圾。
plot_measure(dataset = scRNA_int,
measures = c("KRT14","percent.mt"),
group_by = "seurat_clusters",
pal_setup = pal)
plot_measure_dim(dataset = scRNA_int,
measures = c("nFeature_RNA","nCount_RNA","percent.mt","KRT14"))
plot_measure_dim(dataset = scRNA_int,
measures = c("nFeature_RNA","nCount_RNA","percent.mt","KRT14"),
split_by = "sample")
6.GSEA分析
為了進(jìn)行GSEA分析,我們將首先通過find_diff_genes()
找到差異表達(dá)基因(DEGs)和相關(guān)measures俄认。然后个少,通過test_GSEA()
輸入經(jīng)過排序的列表進(jìn)行GSEA分析。(注:Seurat可能需要很長時間才能找到DEG眯杏。建議使用future
包進(jìn)行多線程分析處理)夜焦。最后,可以使用plot_GSEA()
繪制輸出岂贩,并提供用于調(diào)整p值
截止和顏色漸提供附加參數(shù)茫经。
de <- find_diff_genes(dataset = scRNA_int,
clusters = as.character(0:7),
comparison = c("group", "CTCL", "Normal"),
logfc.threshold = 0, # threshold of 0 is used for GSEA
min.cells.group = 1) # To include clusters with only 1 cell
gsea_res <- test_GSEA(de,
pathway = pathways.hallmark)
plot_GSEA(gsea_res, p_cutoff = 0.1, colors = c("#0570b0", "grey", "#d7301f"))
參考文獻(xiàn):
https://github.com/xmc811/Scillus