使用Seurat 中自帶函數(shù)featureplot 在使用了split函數(shù)之后就沒有l(wèi)egend了
FeaturePlot(object = obj, features = "Gene", split.by = "Meta_Name", order = T) # 沒有scale bar
FeaturePlot(object = obj, features = "Gene", split.by = "Meta_Name", order = T) + theme(legend.position = "right") # 只有右側(cè)的圖有bar
FeaturePlot(object = obj, features = "Gene", split.by = "Meta_Name", order = T) & theme(legend.position = "right") # 兩個都有bar, 但不是統(tǒng)一的scale,可能有修飾圖片的可能
FeaturePlot(object = obj, features = "Gene", split.by = "Meta_Name", keep_scale = T, order = T) & theme(legend.position = "right") #統(tǒng)一的scale崖咨,但函數(shù)版本可能過時击蹲,keep_scale 已經(jīng)換掉
FeaturePlot(object = obj, features = "Gene", split.by = "Meta_Name", keep.scale = "all" , order = T) & theme(legend.position = "right") ##統(tǒng)一的scale,keep.scale 已經(jīng)換掉
keep.scale函數(shù)介紹:
How to handle the color scale across multiple plots. Options are:
"feature" (default; by row/feature scaling): The plots for each individual feature are scaled to the maximum expression of the feature across the conditions provided to 'split.by'.
"all" (universal scaling): The plots for all features and conditions are scaled to the maximum expression value for the feature with the highest overall expression.
NULL (no scaling): Each individual plot is scaled to the maximum expression value of the feature in the condition provided to 'split.by'. Be aware setting NULL will result in color scales that are not comparable between plots.
只是用+是不可以的芯丧,那樣就只會只改split圖中右邊的那個圖 使用&符號的時候是會兩個都改的
m_featureplot <- FeaturePlot(M_Aggregated_seurat, features = "Lepr", reduction = "tsne",
split.by = "orig.ident", pt.size = 1.8, repel = F, label = F,
order = T, max.cutoff = 1)
m_featureplot <- m_featureplot & scale_x_continuous(breaks=seq(-30, 20, 10)) ## 改x軸刻度標(biāo)簽
m_featureplot <- m_featureplot & scale_y_continuous(breaks=seq(-30, 20, 10)) ## 改y軸刻度標(biāo)簽
m_featureplot <- m_featureplot + theme(axis.text.y = element_blank()) + ## 刪去所有刻度標(biāo)簽
theme(axis.ticks.y = element_blank()) + ##則只刪去 Y 軸的刻度線
theme(axis.line.y = element_blank())
m_featureplot <- m_featureplot + ylab("")
更改顏色
FeaturePlot(pbmc_small, "LYZ") + scale_colour_gradientn(colours = rev(brewer.pal(n = 11, name = "RdBu")))
更改scale的范圍,自定義標(biāo)尺
p1 <- FeaturePlot(pbmc_small, features = c("PPBP", "IGLL5", "SDPR"), combine = FALSE )
fix.sc <- scale_color_gradientn( colours = c('lightgrey', 'blue'), limits = c(1, 8))
p2 <- lapply(p1, function (x) x + fix.sc)
CombinePlots(p2)
另:自定義featureplot customize FeaturePlot in Seurat for multi-condition comparisons using patchwork | DNA confesses Data speak (rbind.io)
FeaturePlot color scale legend with custom colors · Issue #2400 · satijalab/seurat · GitHub
Set range for color code in FeaturePlot · Issue #1841 · satijalab/seurat · GitHub