ggbox {MicrobiotaProcess} | R Documentation

## A box or violin plot with significance test

### Description

A box or violin plot with significance test

### Usage

    ggbox(obj, factorNames, ...)

    ## S4 method for signature 'data.frame'
    ggbox(
      obj,
      sampleda,
      factorNames,
      indexNames,
      geom = "boxplot",
      factorLevels = NULL,
      compare = TRUE,
      testmethod = "wilcox.test",
      signifmap = FALSE,
      p_textsize = 2,
      step_increase = 0.1,
      boxwidth = 0.2,
      facetnrow = 1,
      controlgroup = NULL,
      comparelist = NULL,
      ...
    )

    ## S4 method for signature 'alphasample'
    ggbox(obj, factorNames, ...)

### Arguments

`obj` | object, alphasample or data.frame (row sample x column features).
`factorNames` | character, the names of factor contained in sampleda.
`...` | additional arguments, see also `stat_signif`.
`sampleda` | data.frame, sample information if obj is data.frame, the sampleda should be provided.
`indexNames` | character, the vector character, should be the names of features contained object.
`geom` | character, "boxplot" or "violin", default is "boxplot".
`factorLevels` | list, the levels of the factors, default is NULL, if you want to order the levels of factor, you can set this.
`compare` | logical, whether test the features among groups,default is TRUE.
`testmethod` | character, the method of test, default is 'wilcox.test'. see also `stat_signif`.
`signifmap` | logical, whether the pvalue are directly written a annotaion or asterisks are used instead, default is (pvalue) FALSE. see also `stat_signif`.
`p_textsize` | numeric, the size of text of pvalue or asterisks, default is 2.
`step_increase` | numeric, see also `stat_signif`, default is 0.1.
`boxwidth` | numeric, the width of boxplot when the geom is 'violin', default is 0.2.
`facetnrow` | integer, the nrow of facet, default is 1.
`controlgroup` | character, the names of control group, if it was set, the other groups will compare to it, default is NULL.
`comparelist` | list, the list of vector, default is NULL.

### Value

a 'ggplot' plot object, a box or violine plot.

### Author(s)

Shuangbin Xu

### Examples

    ## Not run:
    library(magrittr)
    otudafile <- system.file("extdata", "otu_tax_table.txt",
                             package="MicrobiotaProcess")
    otuda <- read.table(otudafile, sep="\t",
                        header=TRUE, row.names=1,
                        check.names=FALSE, skip=1,
                        comment.char="")
    samplefile <- system.file("extdata",
                              "sample_info.txt",
                              package="MicrobiotaProcess")
    sampleda <- read.table(samplefile,
                           sep="\t", header=TRUE, row.names=1)
    otuda <- otuda[sapply(otuda, is.numeric)] %>% t() %>%
             data.frame(check.names=FALSE)
    set.seed(1024)
    alphaobj1 <- get_alphaindex(otuda, sampleda=sampleda)
    p1 <- ggbox(alphaobj1, factorNames="group")
    data(test_otu_data)
    set.seed(1024)
    alphaobj2 <- get_alphaindex(test_otu_data)
    class(alphaobj2)
    head(as.data.frame(alphaobj2))
    p2 <- ggbox(alphaobj2, factorNames="group")
    # set factor levels.
    p3 <- ggbox(obj=alphaobj2, factorNames="group",
                factorLevels=list(group=c("M", "N", "B", "D")))
    # set control group.
    p4 <- ggbox(obj=alphaobj2, factorNames="group", controlgroup="B")
     set comparelist
    p5 <- ggbox(obj=alphaobj2, factorNames="group",
                comparelist=list(c("B", "D"), c("B", "M"), c("B", "N")))

    ## End(Not run)

[Package MicrobiotaProcess version 1.4.4 Index]