# #设置,包括= FALSE --------------------------------------------------------------------------------------------- knitr: opts_chunk美元集(崩溃= TRUE,发表评论 = "#>" ) ## ----" 加载包”,消息= FALSE --------------------------------------------------------------------------------- ## 我们加载所需的包库(分离)图书馆(dplyr)图书馆(宠物猫)图书馆(tidyr)图书馆(ggplot2)图书馆(pheatmap)图书馆(ggrepel ) ## ----" 加载数据 "------------------------------------------------------------------------------------------------------ inputs_dir < -系统。file("extdata", package = "去耦器")data <- readRDS(file. exe)路径(bk_data.rds inputs_dir。 ")) ## ----" 计数 "--------------------------------------------------------------------------------------------------------- # 删除NAs和设置行名称数量< -数据计算美元% > % dplyr:: mutate_if(~任何(is.na(方式)),~ if_else (is.na(方式),0,以下方式))% > % column_to_rownames (var = "基因")% > % as.matrix()头(计数 ) ## ----" 设计 "--------------------------------------------------------------------------------------------------------- 设计< -数据美元设计设计# #——“度 "------------------------------------------------------------------------------------------------------------ # 数据提取每个基因t度< - $ limma_ttop % > % select (ID、t) % > %过滤器(! is.na (t) % > % column_to_rownames (var = " ID ") % > % as.matrix()头(度 ) ## ----" 后代”,消息= FALSE ----------------------------------------------------------------------------------------- 净< - get_progeny(生物=‘人类’,顶部= 100)净# #——“sample_wmean”,消息= FALSE ------------------------------------------------------------------------------------ # 运行wmean sample_acts < - run_wmean(垫=,=净,净.source =‘源’,.target =‘目标’,.mor =“重量”,* = 100, minsize = 5) sample_acts # #——“热图 "-------------------------------------------------------------------------------------------------------- # 广泛的矩阵变换sample_acts_mat < - sample_acts % > %过滤器(统计= = norm_wmean) % > % pivot_wider (id_cols =‘条件’,names_from =‘源’,values_from =“分数”)% > % column_to_rownames(条件)% > % as.matrix() #每个样本规模sample_acts_mat < -规模(sample_acts_mat) #选择调色板palette_length = 100 my_color = colorRampPalette (c(“Darkblue”、“白”、“红”))(palette_length) my_breaks < - c (seq (3 0 length.out =上限(palette_length / 2) + 1), seq (0.05, 3, length.out =地板(palette_length / 2))) #情节pheatmap (sample_acts_mat border_color = NA、颜色= my_color休息= my_breaks ) ## ----" contrast_wmean”,消息= FALSE ---------------------------------------------------------------------------------- # 运行wmean contrast_acts < - run_wmean(垫=度=净,净.source =‘源’,.target =‘目标’,.mor =“重量”,* = 100,minsize = 5) contrast_acts # #——“barplot "-------------------------------------------------------------------------------------------------------- # 过滤器norm_wmean f_contrast_acts < - contrast_acts % > %过滤器(统计= = norm_wmean) #情节ggplot (f_contrast_acts,Aes (x = reorder(source, score), y = score)) + geom_bar(Aes (fill = score), stat = "identity") + scale_fill_gradient2(low = "darkblue", high = "indianred", mid = "whitesmoke", midpoint = 0) + theme_minimal() + theme(坐标轴。title = element_text(=“大胆”,大小= 12),axis.text.x = element_text(角= 45,hjust = 1,大小= 10,幼圆“大胆”),axis.text.y = element_text(大小= 10,面对=“大胆”),panel.grid.major = element_blank (), panel.grid.minor = element_blank ()) + xlab(“通路 ") ## ----" 目标 "-------------------------------------------------------------------------------------------------------- 路径< - MAPK的df净% < - > %过滤器(源= =通路)% > %安排(目标)% > %变异(ID =目标, color = "3") %>% column_to_rownames('target') inter <- sort(intersect(rownames(deg),rownames(df))) df <- df[inter, ] df['t_value'] <- deg[inter, ] df <- df %>% mutate(color = if_else(weight > 0 & t_value > 0, '1', color)) %>% mutate(color = if_else(weight > 0 & t_value < 0, '2', color)) %>% mutate(color = if_else(weight < 0 & t_value > 0, '2', color)) %>% mutate(color = if_else(weight < 0 & t_value < 0, '1', color)) ggplot(df, aes(x = weight, y = t_value, color = color)) + geom_point() + scale_colour_manual(values = c("red","royalblue3","grey")) + geom_label_repel(aes(label = ID)) + theme_minimal() + theme(legend.position = "none") + geom_vline(xintercept = 0, linetype = 'dotted') + geom_hline(yintercept = 0, linetype = 'dotted') + ggtitle(pathway) ## ----session_info, echo=FALSE----------------------------------------------------------------------------------------- options(width = 120) sessioninfo::session_info()