plot_bin_psig: plot_bin_psig

Usage Arguments Examples

View source: R/plot_bin_psig.R

Usage

1
plot_bin_psig(alloutputs, psigtitle, psigyrange = NULL, savepsigfile, psigpicdim)

Arguments

alloutputs
psigtitle
psigyrange
savepsigfile
psigpicdim

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (alloutputs, psigtitle, psigyrange = NULL, savepsigfile, 
    psigpicdim) 
{
    require(ggplot2)
    results <- alloutputs$alldist
    selname0 <- alloutputs$selname
    df <- as.data.frame(results$psigdist)
    df$highlight <- ifelse(df$dif == 0, "real data", "permutation")
    df$highlight <- factor(df$highlight, levels = c("real data", 
        "permutation"))
    mycolours <- c(permutation = "black", `real data` = "red")
    N0 <- max(df$dif)
    if (sum(is.na(df))) {
        stop("Missing values exist in psigdist")
    }
    else {
        df$dif <- df$dif/N0
        if (is.null(psigyrange)) {
            y_range <- range(floor(min(df$q1)), ceiling(max(df$q2)))
        }
        else {
            y_range <- psigyrange
        }
        p <- ggplot(df, aes(x = dif, y = median)) + geom_point(size = 5, 
            aes(colour = highlight)) + scale_color_manual("Scenarios", 
            values = mycolours) + geom_pointrange(aes(ymin = q1, 
            ymax = q2, colour = highlight), size = 0.5) + geom_line(size = 1) + 
            xlab("Proportion of exchanges") + ylab("Number of significant hits") + 
            ggtitle(psigtitle) + ylim(y_range) + theme_bw() + 
            theme(plot.title = element_text(size = 30, face = "bold"), 
                legend.title = element_text(size = 20), legend.text = element_text(size = 16)) + 
            theme(axis.line = element_line(colour = "black"), 
                panel.grid.major = element_blank(), panel.border = element_blank(), 
                panel.background = element_blank(), axis.line.x = element_line(color = "black", 
                  size = 1.5), axis.line.y = element_line(color = "black", 
                  size = 1.5), axis.text = element_text(size = 16, 
                  face = "bold"), axis.title = element_text(size = 20, 
                  face = "bold"))
        ggsave(filename = savepsigfile, width = psigpicdim[1], 
            height = psigpicdim[2])
    }
    return(p)
  }

LyonsZhang/ProgPerm documentation built on July 16, 2020, 12:45 a.m.