偷偷问一下,关注了吗?
内容获取
1、购买打包合集(《KS科研分享与服务》付费内容打包集合),价格感人,可以加入微信VIP群(答疑交流群,甚至有小伙伴觉得群比代码更好),可以获取建号以来所有内容,群成员专享视频教程,提前更新,其他更多福利!
2、《KS科研分享与服务》公众号有QQ群,进入门槛是20元(完全是为了防止白嫖党,请理解),请考虑清楚。群里有免费推文的注释代码和示例数据(终身拥有),没有付费内容,群成员福利是购买单个付费内容半价!
需要者详情请联系作者(非需要者勿扰,处理太费时间):
玩转单细胞(16):Scanpy单细胞h5ad数据转化为Seurat对象
library(Seurat)
library(dplyr)
library(ggplot2)
library(ggrepel)
#===============================================================================
#UMAP plot
emb <- Embeddings(obj,reduction = 'umap') %>% #提取坐标数据
as.data.frame() %>%
mutate(clusters=obj@meta.data$seurat_clusters,#添加cell注释信息
celltype=obj@meta.data$celltype)
#ggplot作图
ggplot(emb, aes(UMAP_1,UMAP_2))+
geom_point(aes(colour = clusters), size=0.5)+#颜色选择cluster
theme_classic()+
theme(axis.text = element_text(color = 'black', size = 10))+
scale_color_manual(values = c("#edc951","#eb6841","#cc2a36","#4f372d","#00a0b0",
"#7A989A", "#849271", "#CF9546", "#C67052", "#C1AE8D",
"#3F6F76", "#C65840", "#F4CE4B", "#62496F", "#69B7CE",
"#A4B7E1", "#B8B87A"))#修改颜色
label <- emb %>%
group_by(celltype) %>%
summarise(UMAP_1 = median(UMAP_1),
UMAP_2 = median(UMAP_2))%>%
as.data.frame()
ggplot(emb, aes(UMAP_1,UMAP_2))+
geom_point(aes(colour = clusters), size=0.5)+#颜色选择cluster
theme_classic()+
theme(axis.text = element_text(color = 'black', size = 10))+
scale_color_manual(values = alpha(c("#edc951","#eb6841","#cc2a36","#4f372d","#00a0b0",
"#7A989A", "#849271", "#CF9546", "#C67052", "#C1AE8D",
"#3F6F76", "#C65840", "#F4CE4B", "#62496F", "#69B7CE",
"#A4B7E1", "#B8B87A"),0.5))+
geom_text(data = label[label$celltype %in% c("Muscle",'Fibroblasts','Endothlial'),],
aes(UMAP_1,UMAP_2, label=celltype),
nudge_y = 4,
color = 'black',
size = 4) +
geom_text(data = label[label$celltype %in% c("T cells",'Mast cells','Melanocytes','Lymphatic'),],
aes(UMAP_1,UMAP_2, label=celltype),
nudge_y = 2,
color = 'black',
size = 4) +
geom_text(data = label[label$celltype %in% c("Keratinocytes"),],
aes(UMAP_1,UMAP_2, label=celltype),
nudge_y = 2,nudge_x = 5,
color = 'black',
size = 4) +
geom_text(data = label[label$celltype %in% c('Myeloid'),],
aes(UMAP_1,UMAP_2, label=celltype),
nudge_y = 4,
color = 'black',
size = 4) +
NoLegend()
关注我们获取精彩内容:
关注不迷路:扫描下面二维码关注公众号!
B站视频号链接:https://space.bilibili.com/471040659?spm_id_from=333.1007.0.0
关注 KS科研分享与服务,
认清正版优质内容和服务!
优质内容持续输出,物超所值!
合作联系:ks_account@163.com