# #设置,包括= 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_progeny(生物=‘人类’,顶部= 100)净# #——“wmean”,消息= FALSE ------------------------------------------------------------------------------------------- # 提取规范化对数转换计算垫< - as.matrix (data@assays RNA@data美元)#运行wmean行为<——run_wmean(垫=垫,净=净,.source =‘源’,.target =‘目标’,.mor =“重量”,* = 100,minsize = 5)行为# #——“new_assay”,消息= FALSE --------------------------------------------------------------------------------------- # 提取norm_wmean数据数据并将其存储在pathwayswmean [[' pathwayswmean ']] < -行为% > %过滤器(统计= = norm_wmean) % > % pivot_wider (id_cols =‘源’,names_from =“条件”,values_from = 'score') %>% column_to_rownames('source') %>% Seurat::CreateAssayObject(.) # Change assay DefaultAssay(object = data) <- "pathwayswmean" #缩放数据数据<- ScaleData(data) data@assays$pathwayswmean@data <- data@assays$pathwayswmean@scale.data ## ----"projected_acts", message = FALSE, warning = FALSE, figure width = 8, figure height = 4-------------------------------- p1 <- DimPlot(data, reduction = "umap", label = TRUE,pt.size = 0.5) + NoLegend() + ggtitle('Cell types') p2 <- (FeaturePlot(data, features = c("Trail")) & scale_colour_gradient2(low = 'blue', mid = 'white', high = 'red')) + ggtitle('Trail activity') p1 | p2 ## ----"mean_acts", message = FALSE,警告= FALSE -------------------------------------------------------------------- # 从对象作为提取活动长dataframe df < - t (as.matrix (data@assays pathwayswmean@data)美元)% > % as.data.frame() % > %变异(集群=识别(数据)% > % pivot_longer(关口=集群,names_to =“源”,values_to = "分数")% > % group_by(集群,源)% > %总结(平均=平均(分数))#宽变换矩阵top_acts_mat < - df % > % pivot_wider (id_cols =“集群”,names_from =‘源’,values_from = 'mean') %>% column_to_rownames('cluster') %>% as.matrix() #选择调色板palette_length = 100 my_color = colorRampPalette(c("深蓝色","白色","红色"))(palette_length) my_breaks <- c(seq(- 2,0, length.out=ceiling(palette_length/2) + 1), seq(0.05, 2, length.out=floor(palette_length/2))) # Plot pheatmap(top_acts_mat, border_color = NA, color=my_color, breaks = my_breaks) ## ----session_info,回声= FALSE ----------------------------------------------------------------------------------------- 选项(宽度= 120)sessioninfo: session_info ()