mp_cal_dist {MicrobiotaProcess} | R Documentation

## Calculate the distances between the samples with specified abundance.

### Description

Calculate the distances between the samples with specified abundance.

### Usage

    mp_cal_dist(
      .data,
      .abundance,
      .env = NULL,
      distmethod = "bray",
      action = "add",
      scale = FALSE,
      ...
    )

    ## S4 method for signature 'MPSE'
    mp_cal_dist(
      .data,
      .abundance,
      .env = NULL,
      distmethod = "bray",
      action = "add",
      scale = FALSE,
      ...
    )

    ## S4 method for signature 'tbl_mpse'
    mp_cal_dist(
      .data,
      .abundance,
      .env = NULL,
      distmethod = "bray",
      action = "add",
      scale = FALSE,
      ...
    )

    ## S4 method for signature 'grouped_df_mpse'
    mp_cal_dist(
      .data,
      .abundance,
      .env = NULL,
      distmethod = "bray",
      action = "add",
      scale = FALSE,
      ...
    )

### Arguments

`.data` | MPSE or tbl_mpse object
`.abundance` | the name of otu abundance to be calculated
`.env` | the column names of continuous environment factors, default is NULL.
`distmethod` | character the method to calculate distance. option is "manhattan", "euclidean", "canberra", "bray", "kulczynski", "jaccard", "gower", "altGower", "morisita", "horn", "mountford", "raup", "binomial", "chao", "cao" (implemented in vegdist of vegan), and "w", "-1", "c", "wb", "r", "I", "e", "t", "me", "j", "sor", "m", "-2", "co" "cc", "g", "-3", "l", "19", "hk", "rlb", "sim", "gl", "z" (implemented in betadiver of vegan), "maximum", "binary", "minkowski" (implemented in dist of stats), "unifrac", "weighted unifrac" (implemented in phyloseq),
`action` | character, "add" joins the distance data to the object, "only" return a non-redundant tibble with the distance information. "get" return 'dist' object.
`scale` | logical whether scale the metric of environment (.env is provided) before the distance was calculated, default is FALSE. The environment matrix can be processed when it was joined to the MPSE or tbl_mpse object.
`...` | additional parameters. some dot arguments if `distmethod` is `unifrac` or `weighted unifrac`: `weighted` logical, whether to use weighted-UniFrac calculation, which considers the relative abundance of taxa, default is FALSE, meaning unweightrd-UniFrac, which only considers presence/absence of taxa. `normalized` logical, whether normaized the branch length of tree to the range between 0 and 1 when the `weighted`=`TRUE`. `parallel` logical, whether to execute the calculation in parallel, default is FALSE.

### Value

update object or tibble according the 'action'

### Author(s)

Shuangbin Xu

### See Also

[mp_extract_dist()] and [mp_plot_dist()]

### Examples

    data(mouse.time.mpse)
    mouse.time.mpse %<>%
        mp_decostand(.abundance=Abundance) %>%
        mp_cal_dist(.abundance=hellinger, distmethod="bray")
    mouse.time.mpse
    p1 <- mouse.time.mpse %>%
            mp_plot_dist(.distmethod=bray)
    p2 <- mouse.time.mpse %>%
            mp_plot_dist(.distmethod=bray, .group=time, group.test=TRUE)
    p3 <- mouse.time.mpse %>%
            mp_plot_dist(.distmethod=bray, .group=time)

    ## Not run:
    # Visualization manual
    library(ggplot2)
    tbl <- mouse.time.mpse %>%
           mp_extract_dist(distmethod="bray", .group=time)
    tbl
    tbl %>%
      ggplot(aes(x=GroupsComparison, y=bray)) +
      geom_boxplot(aes(fill=GroupsComparison)) +
      geom_jitter(width=0.1) +
      xlab(NULL) +
      theme(legend.position="none")

    ## End(Not run)

[Package MicrobiotaProcess version 1.4.4 Index]