内容

下面我们只生成必要的图来解释黑洞是如何工作的。

库(ggplot2)库(“dplyr”)
## ##附加包:'dplyr'
以下对象从'package:stats'中屏蔽:## ## filter, lag
以下对象从'package:base'中屏蔽:## ## intersect, setdiff, setequal, union
library("wesanderson") library("grid") library("gridExtra")
## ##附加包:“gridExtra”
下面的对象从'package:dplyr'中屏蔽:## ## combine
库(“IHW”)
## ##附件:“IHW”
以下对象从'package:ggplot2'中屏蔽:## ## alpha

1学士学位论文情节(低\ \ pi_0 \ ()

图如在学士学位论文与非常低\ \ pi_0 \ ().(使用这种方法,可以清楚地证明BH阈值是Bonferroni阈值和未校正阈值之间的中间阈值,也是这样\ \ pi_0 \ ()允许在第二个图中显示所有p值,并且仍然观察到有趣的行为。)

simplesimsimulation <- function(m,m1,betaA,betaB){pvalue <- runif(m) H <- rep(0,m) alternatives <- sample(1:m,m1) pvalue[alternatives] <- rbeta(m1,betaA,betaB) H[alternatives] <- - simDf <- data.frame(pvalue =pvalue, group=runif(m), filterstat =runif(m), H=H) return(simDf)} set.seed(1) sim <- simplesimsimulation (1000,700,0.3, 8) sim$rank <- rank(sim$pvalue) histogram_plot <- ggplot(sim, aes(x=pvalue)) + geom_histogram(binwidth=0.1,填补= wes_palette(“Chevalier1”)[4])+ xlab(假定值)+ theme_bw () bh_threshold < - get_bh_threshold (sim pvalue美元。1)bh_plot < - ggplot (sim, aes (x =排名,y = pvalue)) + geom_step (col = wes_palette(“Chevalier1”)[4])+ ylim (c (0, - 0.2)) + geom_abline(拦截= 0,斜率= 0.1/1000,坳= wes_palette(“Chevalier1”)[2])+ geom_hline (yintercept = bh_threshold线型= 2)+注释(“文本”,x = 250, y = 0.065,标签=“黑洞测试”)+ geom_hline (yintercept = 0.1,线型= 2)+注释(“文本”,x = 250, y = 0.11,label="uncorrected testing") + geom_hline(yintercept =0.1/1000, linetype=2) + annotation ("text",x=850, y=0.1/1000+0.01, label="Bonferroni testing") + ylab("p-value") + xlab(" p-value的rank ") + theme_bw() + scale_color_manual (values=wes_palette("Chevalier1")[c(3,4)]))
网格。排列(histogram_plot, bh_plot, nrow=1)

Pdf (file="bh_explanation.pdf", width=11, height=5)排列(histogram_plot, bh_plot, nrow=1) dev.off()

2生物展示图(更高\ \ pi_0 \ ()

对于ddhw表示,用更高的重制上面的图\ \ pi_0 \ ()

set.seed(1) sim <- simplesimsimulation (10000, 2000, 0.3, 8) sim$rank <- rank(sim$pvalue) histogram_plot <- ggplot(sim, aes(x=pvalue)) + geom_histogram(binwidth=0.1, fill =wes_palette("Chevalier1")[4])+ xlab("p-value") + theme_bw(14) bh_threshold <- get_bh_threshold(sim$pvalue, .1) bh_plot <- ggplot(sim, aes(x=rank, y=pvalue)) + geom_step(col=wes_palette("Chevalier1")[4], size=1.2) + scale_x_continuous(limits=c(0,2000),expand =c(0,0))+ scale_y_continuous(limit=c(0,0.06),expand=c(0,0)) + geom_abline(intercept=0, slope= 0.1/10000, col =wes_palette("Chevalier1")[2], size=1.2) + annotate("text",x=500, y=1.3*bh_threshold, label="BH拒绝阈值")+ geom_hline(yintercept=bh_threshold, linetype=2, size=1.2) + ylab("p-value") + xlab(" p-value的rank ") + theme_bw() + scale_color_manual (values=wes_palette("Chevalier1")[c(3,4)]))
网格。排列(histogram_plot, bh_plot, nrow=1)
##警告:删除了4行包含缺失值(geom_path)。

Pdf (file=" bh_explation_high_pi0 . Pdf ", width=11, height=5)排列(histogram_plot, bh_plot, nrow=1) dev.off()