偷偷问一下,关注了吗?
内容获取
1、购买打包合集(《KS科研分享与服务》付费内容打包集合),价格感人,可以加入微信VIP群(答疑交流群,甚至有小伙伴觉得群比代码更好),可以获取建号以来所有内容,群成员专享视频教程,提前更新,其他更多福利!
2、《KS科研分享与服务》公众号有QQ群,进入门槛是20元(完全是为了防止白嫖党,请理解),请考虑清楚。群里有免费推文的注释代码和示例数据(终身拥有),没有付费内容,群成员福利是购买单个付费内容半价!
需要者详情请联系作者(非需要者勿扰,处理太费时间):
library(ggplot2)
library(monocle3)
source('./ks_run_monocle3.R')
#monocle3 analysis
#运行monocle3分析0参照monocle3视频教程
cds_data <- ks_run_monocle3(object=cytotrace2_sce,
idents="cluster",
use_partition=F,
learn_graph_control=list(minimal_branch_len=9.5,euclidean_distance_ratio=1),
define_root=T,
know_root=T,
root_state="YSMP")
#plot-拟时基本作图
plot_cells(cds_data, label_cell_groups = F,
color_cells_by = "pseudotime",
label_branch_points = F,
label_roots =F,
label_leaves =F,
graph_label_size = 0,
cell_size=2,
trajectory_graph_color='black',
trajectory_graph_segment_size = 2)
pseudotime <- pseudotime(cds_data) %>% as.data.frame()
pseudotime$cell <- rownames(pseudotime)
colnames(pseudotime)[1] <- "peu"
celltype <- cds_data@clusters$UMAP %>% as.data.frame()
celltype$cell <- rownames(celltype)
merge <-merge(pseudotime, celltype, by = 'cell')
merge <- merge[order(merge$peu), ]
p=ggplot(merge,aes(peu,fill=clusters, color=clusters)) +
geom_density(alpha = 0.5,size=1.2)+
scale_fill_manual(values=c("#3F6F76", "#C65840", "#F4CE4B", "#62496F"))+ #设置颜色
scale_color_manual(values=c("#3F6F76", "#C65840", "#F4CE4B", "#62496F"))+
theme_classic()+ #我这里不展示坐标轴信息,可自行设置
scale_y_continuous(expand = c(0,0))+
theme(axis.line = element_blank(),
axis.ticks.y=element_blank(),
axis.title = element_blank(),
axis.text.y = element_blank(),
axis.text.x=element_text(colour='black',size=10))+
labs(title = "Pseudotime")
p
p+scale_y_break(c(1, 2),
scales = c(0.5,2),
expand=expansion(add = c(0, 0)),
space = 0.2)
##或者加一个热图,使用AI将两者结合起来即可
source('./ks_monocle3_heatmap.R')
label gene
"C1QB","C1QC","C1QA","MRC1","LGMN","MS4A7","MAF","FOLR2", genes <- c(
"HLA-DPA1","CLEC10A","IL10RA","CD163","KCTD12","CLEC7A","MS4A6A","CD14",
"ITM2A","CYTL1","MDK","SELP","CD24",
"S100A8","S100A9","S100A12")
ht2 = ks_monocle3_heatmap(cds = cds_data,
graph_gene = plot_genes,
"#E69253", "#EDB931", "#E4502E", "#4f372d"), celltype_color = c(
"#8f657d", "#42819F", "#86AA7D", "#CBB396"), cluster_color =c(
num_clusters=4,
labels = T,
label_genes = genes)
ggplot(merge, aes(x=peu,y=clusters,fill=clusters))+
geom_density_ridges(scale=1) +
scale_y_discrete(position = 'right')+
theme_minimal()+
theme(panel.grid = element_blank(),
axis.title = element_blank(),
axis.text = element_text(colour = 'black', size=8))+
scale_x_continuous(position = 'top')+
scale_fill_manual(values=c("#3F6F76", "#C65840", "#F4CE4B", "#62496F"))
觉得我们分享有些用的,点个赞再走呗!
关注我们获取精彩内容:
关注不迷路:扫描下面二维码关注公众号!
B站视频号链接:https://space.bilibili.com/471040659?spm_id_from=333.1007.0.0
关注 KS科研分享与服务,
认清正版优质内容和服务!
优质内容持续输出,物超所值!
合作联系:ks_account@163.com