早上起来看到了大雪,外面真的好冷啊!~⛄️
各位小伙伴那里有没有下雪啊!~😬
回国1年了,忙忙碌碌,碌碌无为。😂
尽人事,听天命吧,越发感觉到自己的渺小。🤒
rm(list = ls())
library(tidyverse)
library(monocle3)
寻找随着细胞轨迹进而变化的基因是做伪时分析的最终目的。😏
这里我们把之前的embryo
数据加载进来用一下。🤩
expression_matrix <- readRDS("./packer_embryo_expression.rds")
cell_metadata <- readRDS("./packer_embryo_colData.rds")
gene_annotation <- readRDS("./packer_embryo_rowData.rds")
cds <- new_cell_data_set(expression_matrix,
cell_metadata = cell_metadata,
gene_metadata = gene_annotation)
做一下常规的处理吧,之前都介绍过了。😂
cds <- preprocess_cds(cds, num_dim = 50)
cds <- align_cds(cds, alignment_group = "batch",
residual_model_formula_str = "~ bg.300.loading + bg.400.loading + bg.500.1.loading + bg.500.2.loading + bg.r17.loading + bg.b01.loading + bg.b02.loading")
cds <- reduce_dimension(cds)
cds <- cluster_cells(cds)
cds <- learn_graph(cds)
cds <- order_cells(cds)
plot_cells(cds,
color_cells_by = "cell.type",
label_groups_by_cluster=FALSE,
label_leaves=FALSE,
label_branch_points=FALSE)
这次,我们用一下啊graph_test()
函数,设置neighbor_graph="principal_graph"
测试轨迹上相似位置的细胞是否具有相关的表达。🤒
ciliated_cds_pr_test_res <- graph_test(cds,
neighbor_graph="principal_graph",
cores=4)
pr_deg_ids <- row.names(subset(ciliated_cds_pr_test_res, q_value < 0.05))
可视化一下。🥳
得分越高,重要性越高。🥰
plot_cells(cds, genes=c("hlh-4", "gcy-8", "dac-1", "oig-8"),
show_trajectory_graph=FALSE,
label_cell_groups=FALSE,
label_leaves=FALSE)
gene_module_df <- find_gene_modules(cds[pr_deg_ids,], resolution=c(10^seq(-6,-1)))
这里是注释的每组细胞类型中的聚合模块分数。😘
cell_group_df <- tibble::tibble(cell=row.names(colData(cds)),
cell_group=colData(cds)$cell.type)
agg_mat <- aggregate_gene_expression(cds, gene_module_df, cell_group_df)
row.names(agg_mat) <- stringr::str_c("Module ", row.names(agg_mat))
pheatmap::pheatmap(agg_mat,
scale="column", clustering_method="ward.D2")
我们再比较一下不同模块。🥸
plot_cells(cds,
genes=gene_module_df %>% filter(module %in% c(27, 10, 7, 30)),
label_cell_groups=FALSE,
show_trajectory_graph=FALSE)
我们可以根据自己的需要,选择一部分path
,来看看基因的变化。
而且,是用另外一种可视化方式。😅
AFD_genes <- c("gcy-8", "dac-1", "oig-8")
AFD_lineage_cds <- cds[rowData(cds)$gene_short_name %in% AFD_genes,
colData(cds)$cell.type %in% c("AFD")]
AFD_lineage_cds <- order_cells(AFD_lineage_cds)
可视化一下吧。🧐
这里可以看到,dac-1
在其他两个基因之前被激活。😏
plot_genes_in_pseudotime(AFD_lineage_cds,
color_cells_by="embryo.time.bin",
min_expr=0.5)
最后祝大家早日不卷!~