featureplot 统一scale

使用Seurat 中自带函数featureplot 在使用了split函数之后就没有legend了

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")   # 只有右侧的图有bar

FeaturePlot(object = obj, features = "Gene", split.by = "Meta_Name", order = T) & theme(legend.position = "right")   # 两个都有bar, 但不是统一的scale,可能有修饰图片的可能


FeaturePlot(object = obj, features = "Gene", split.by = "Meta_Name", keep_scale = T, order = T) & theme(legend.position = "right") #统一的scale,但函数版本可能过时,keep_scale 已经换掉


FeaturePlot(object = obj, features = "Gene", split.by = "Meta_Name", keep.scale = "all" , order = T) & theme(legend.position = "right")  ##统一的scale,keep.scale 已经换掉

keep.scale函数介绍:
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轴刻度标签
m_featureplot <- m_featureplot & scale_y_continuous(breaks=seq(-30, 20, 10)) ## 改y轴刻度标签
m_featureplot <- m_featureplot +  theme(axis.text.y = element_blank()) +   ## 删去所有刻度标签
                                  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的范围,自定义标尺

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)

参考:
Add keep.scale param to FeaturePlot when creating split plots by samuel-marsh · Pull Request #3748 · satijalab/seurat · GitHub

FeaturePlot color scale legend with custom colors · Issue #2400 · satijalab/seurat · GitHub

Set range for color code in FeaturePlot · Issue #1841 · satijalab/seurat · GitHub

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容