# #设置,包括= FALSE --------------------------------------------------------------------------------------------- knitr: opts_chunk美元集(崩溃= TRUE,发表评论 = "#>" ) ## ----" 加载包”,消息= FALSE --------------------------------------------------------------------------------- ## 我们加载所需的包库(修)图书馆(分离)#只有数据处理和绘图所需库(dplyr)库(宠物猫)库(tidyr)图书馆(拼接)图书馆(ggplot2)库(pheatmap ) ## ----" 加载数据 "------------------------------------------------------------------------------------------------------ inputs_dir < -系统。file("extdata", package = "去耦器")data <- readRDS(file. exe)路径(sc_data.rds inputs_dir。 ")) ## ----" umap”,消息= FALSE,警告= FALSE ------------------------------------------------------------------------- DimPlot(数据,减少=“umap”标签= TRUE, pt.size = 0.5) + NoLegend () ## ----" 多萝西娅”,消息= FALSE ---------------------------------------------------------------------------------------- 净< - get_dorothea(生物=‘人类’,水平= c (A, B, c))净# #——“wmean”,消息= FALSE ------------------------------------------------------------------------------------------- # 提取规范化对数转换计算垫< - as.matrix (data@assays RNA@data美元)#运行wmean行为<——run_wmean(垫=垫,净=净,.source =‘源’,.target =‘目标’,.mor =“铁道部”* = 100,minsize = 5)行为# #——“new_assay”,消息= FALSE --------------------------------------------------------------------------------------- # norm_wmean提取数据并将其存储在pbmc tfswmean [[' tfswmean ']] < -行为% > %过滤器(统计= = norm_wmean) % > % pivot_wider (id_cols =‘源’,names_from =“条件”,values_from =“分数”)% > % column_to_rownames(“源”)% > %修::CreateAssayObject(.) #变化测定DefaultAssay(对象=数据)<——“tfswmean”#规模数据数据< - ScaleData(数据)data@assays tfswmean@data <美元——data@assays tfswmean@scale.data # #——“projected_acts”美元,消息= FALSE,警告= FALSE, fig.width = 12, fig.height = 4 ------------------------------- p1 < - DimPlot(数据,减少=“umap”标签= TRUE, pt.size = 0.5) + NoLegend () + ggtitle(“细胞”)p2 < - (FeaturePlot(数据,features = c("PAX5")) & scale_colour_gradient2(low = 'blue', mid = 'white', high = 'red')) + ggtitle('PAX5 activity') DefaultAssay(object = data) <- "RNA" p3 <- FeaturePlot(data, features = c("PAX5")) + ggtitle('PAX5 expression') DefaultAssay(object = data) <- "tfswmean" p1 | p2 | p3 ## ----"mean_acts", message = FALSE,警告= FALSE -------------------------------------------------------------------- n_tfs < - 25 #从对象作为提取活动长dataframe df < - t (as.matrix (data@assays tfswmean@data)美元)% > % as.data.frame() % > %变异(集群=识别(数据)% > % pivot_longer(关口=集群,names_to =“源”,values_to = "分数")% > % group_by(集群,来源)%>% summary (mean = mean(score)) #获得top tfs与更多的变量跨集群tfs <- df %>% group_by(source) %>% summary (std = sd(mean)) %>% arrange(-abs(std)) %>% head(n_tfs) %>% pull(source) #子集长数据帧到top tfs和转换为宽矩阵top_acts_mat <- df %>% filter(source %in% tfs) %>% pivot_wider(id_cols = 'cluster', names_from = 'source',values_from = 'mean') %>% column_to_rownames('cluster') %>% as.matrix() #选择调色板palette_length = 100 my_color = colorRampPalette(c("深蓝色","白色","红色"))(palette_length) my_breaks <- c(seq(- 3,0, length.out=天花板(palette_length/2) + 1), seq(0.05, 3, length.out=地板(palette_length/2))) # Plot pheatmap(top_acts_mat, border_color = NA, color=my_color, breaks = my_breaks) ## ----session_info, echo=FALSE----------------------------------------------------------------------------------------- options(width = 120) sessioninfo::session_info()