加权共表达分析总结

综述

经典的WGCNA分析
用于疾病两组比较的MEGENA
用于两组处理比较的DGCA
整合工具CEMiTool
CEMiTool的一段代码如下:

## ----style, echo=FALSE, results="asis", message=FALSE--------------------
knitr::opts_chunk$set(tidy = FALSE,
                      warning = FALSE,
                      message = FALSE,
                      cache=TRUE)

## ------------------------------------------------------------------------
BiocManager::install("CEMiTool")
library("CEMiTool")
# load expression data
data(expr0)
head(expr0[,1:4])

## ---- results='hide'-----------------------------------------------------
cem <- cemitool(expr0)

## ------------------------------------------------------------------------
print(cem)
# or, more conveniently, just call `cem`
cem

## ------------------------------------------------------------------------
# inspect modules
nmodules(cem)
head(module_genes(cem))

## ---- eval=FALSE---------------------------------------------------------
#  generate_report(cem, output_format=c("pdf_document", "html_document"))

## ------------------------------------------------------------------------
write_files(cem, directory="./Tables", force=TRUE)

## ------------------------------------------------------------------------
# load your sample annotation data
data(sample_annot)
head(sample_annot)

## ---- results='hide'-----------------------------------------------------
# run cemitool with sample annotation
cem <- cemitool(expr0,sample_annot)

## ------------------------------------------------------------------------
sample_annotation(cem, 
                  sample_name_column="SampleName", 
                  class_column="Class") <- sample_annot

## ------------------------------------------------------------------------
# generate heatmap of gene set enrichment analysis
cem <- mod_gsea(cem)
cem <- plot_gsea(cem)
show_plot(cem, "gsea")

## ------------------------------------------------------------------------
# plot gene expression within each module
cem <- plot_profile(cem)
plots <- show_plot(cem, "profile")
plots[1]

## ------------------------------------------------------------------------
# read GMT file
gmt_fname <- system.file("extdata", "pathways.gmt", package = "CEMiTool")
gmt_in <- read_gmt(gmt_fname)

## ------------------------------------------------------------------------
# perform over representation analysis
cem <- mod_ora(cem, gmt_in)

## ------------------------------------------------------------------------
# plot ora results
cem <- plot_ora(cem)
plots <- show_plot(cem, "ora")
plots[1]

## ------------------------------------------------------------------------
# read interactions
int_fname <- system.file("extdata", "interactions.tsv", package = "CEMiTool")
int_df <- read.delim(int_fname)
head(int_df)

## ------------------------------------------------------------------------
# plot interactions
library(ggplot2)
interactions_data(cem) <- int_df # add interactions
cem <- plot_interactions(cem) # generate plot
plots <- show_plot(cem, "interaction") # view the plot for the first module
plots[3]

## ---- eval=FALSE---------------------------------------------------------
#  # run cemitool
#  library(ggplot2)
#  cem <- cemitool(expr0, sample_annot, gmt_in, interactions=int_df,
#                  filter=TRUE, plot=TRUE, verbose=TRUE)
#  # create report as html document
#  generate_report(cem, directory="./Report")
#  
#  # write analysis results into files
#  write_files(cem, directory="./Tables")
#  
#  # save all plots
#  save_plots(cem, "all", directory="./Plots")

## ---- eval=FALSE---------------------------------------------------------
#  diagnostic_report(cem, directory="./Diagnostics")

MEGENA使用

#!/usr/bin/env Rscript
suppressMessages(library(MEGENA))
rm(list=ls())
FC=0
p=0.05
suppressMessages(library(tidyverse))
n.cores <- 19; # number of cores/threads to call for PCP
doPar <- T; # do we want to parallelize?
method = "pearson" # method for correlation. either pearson or spearman. 
FDR.cutoff = 0.05 # FDR threshold to define significant correlations upon shuffling samples. 
module.pval = 0.05 # module significance p-value. Recommended is 0.05. 
hub.pval = 0.05 # connectivity significance p-value based random tetrahedral networks
cor.perm = 10; # number of permutations for calculating FDRs for all correlation pairs. 
hub.perm = 100; # number of permutations for calculating connectivity significance p-value. 

dir="/data_dir/"
rt_out_dir<-paste0(dir,"rt_logFC_",as.character(FC))
dir.create(rt_out_dir,recursive = T)
setwd(rt_out_dir)
rt_DESeq2_filter_trans<-read.csv(paste0(opposite_dir,"DESeq2_filter_trans_logFC_",as.character(FC),"_padj_",as.character(p),".csv"),header=T,row.names=1)
rt_DESeq2_filter_trans<-rt_DESeq2_filter_trans[,3:ncol(rt_DESeq2_filter_trans)]
rt_info<-read.csv(paste0(opposite_dir,"DESeq2_info.csv"),header=T,row.names=1)

datExpr<-rt_DESeq2_filter_trans
sample_annot<-rt_info[,c(4,5)]
colnames(sample_annot)<-c("SampleName","Class")
ijw <- calculate.correlation(datExpr,doPerm = cor.perm)

library(parallel)
cl <- makePSOCKcluster(n.cores)
registerDoParallel(cl)

##### calculate PFN
el <- calculate.PFN(ijw[,1:3],doPar = doPar,num.cores = n.cores)

g <- graph.data.frame(el,directed = FALSE)
save.image(file=paste0(rt_out_dir,"/rt_logFC_",as.character(FC),"_1.RData"))

MEGENA.output <- do.MEGENA(g,
                           mod.pval = module.pval,hub.pval = hub.pval,remove.unsig = TRUE,
                           min.size = 10,max.size = vcount(g)/2,
                           doPar = doPar,num.cores = n.cores,n.perm = hub.perm,
                           save.output = TRUE)

annot.table=sample_annot
id.col = 1
symbol.col= 2
save.image(file=paste0(rt_out_dir,"/rt_logFC_",as.character(FC),"_2.RData"))
summary.output <- MEGENA.ModuleSummary(MEGENA.output,
                                       mod.pvalue = module.pval,hub.pvalue = hub.pval,
                                       min.size = 10,max.size = vcount(g)/2,
                                       annot.table = annot.table,id.col = id.col,symbol.col = symbol.col,
                                       output.sig = TRUE)

pnet.obj <- plot_module(output = summary.output,PFN = g,subset.module = "comp1_3",
                        layout = "kamada.kawai",label.hubs.only = FALSE,
                        gene.set = NULL,color.code =  "grey",
                        output.plot = FALSE,out.dir = "modulePlot",col.names = c("magenta","green","cyan"),label.scaleFactor = 2,
                        hubLabel.col = "black",hubLabel.sizeProp = 1,show.topn.hubs = Inf,show.legend = TRUE)
stopCluster(cl)
save.image(file=paste0(rt_out_dir,"/rt_logFC_",as.character(FC),"_all.RData"))

####Print
setwd("/rt_out_dir")
load("rt_logFC_0_2.RData")

summary.output <- MEGENA.ModuleSummary(MEGENA.output,
                                       mod.pvalue = module.pval,hub.pvalue = hub.pval,
                                       min.size = 10,max.size = vcount(g)/2,
                                       annot.table = annot.table,id.col = id.col,symbol.col = symbol.col,
                                       output.sig = TRUE)
#Get module table
module.df = module_convert_to_table(MEGENA.output,mod.pval = 0.05,
                                    hub.pval = 0.05,min.size = 10,max.size = vcount(g)/2)

library(ggplot2)
mdf= summary.output$module.table
mdf$module.id<-unlist(lapply(as.character(mdf$module.id), FUN = function(x) {return(paste0("M",strsplit(x, split = "_",fixed = T)[[1]][2]))}))
mdf$module.parent<-unlist(lapply(as.character(mdf$module.parent), FUN = function(x) {return(paste0("M",strsplit(x, split = "_",fixed = T)[[1]][2]))}))

mdf$heat.pvalue = runif(nrow(mdf),0,0.1)

sbobj = draw_sunburst_wt_fill(module.df = mdf,feat.col = "heat.pvalue",log.transform = TRUE,
                              fill.type = "continuous",
                              fill.scale = scale_fill_gradient2(low = "white",mid = "white",high = "blue",
                                                                midpoint = -log10(0.05),na.value = "white"), 
                              id.col = "module.id",parent.col = "module.parent")
sbobj

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,546评论 6 507
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,224评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,911评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,737评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,753评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,598评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,338评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,249评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,696评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,888评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,013评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,731评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,348评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,929评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,048评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,203评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,960评论 2 355

推荐阅读更多精彩内容

  • 修女Maria阅读 839评论 0 1
  • 2019年7月17号,星期三,晴 今天开部门中心会议,这次也是我们中心的半年总结会,这次公司总经理也跟着我们一起在...
    94089e328c05阅读 108评论 0 1
  • .•点,Ⅰ线,面,⊙体,真常应化全维。 动量驻中,皆太极。量动化易,皆无极。 内玄结点,外玄立体,体内点结,点外体...
    厚生168阅读 358评论 4 4
  • 1.大娃~~~这几首古诗都是娃的暑假作业。拿来看看,才知道自己好多都没学过呢。于是跟娃说,咱们一起学习吧 2.二娃...
    爱莲说Alice阅读 392评论 1 2