mp_cal_divergence-methods: calculate the divergence with MPSE or tbl_mpse

mp_cal_divergenceR Documentation

calculate the divergence with MPSE or tbl_mpse

Description

calculate the divergence with MPSE or tbl_mpse

Usage

mp_cal_divergence(
  .data,
  .abundance,
  .name = "divergence",
  reference = "mean",
  distFUN = vegan::vegdist,
  method = "bray",
  action = "add",
  ...
)

## S4 method for signature 'MPSE'
mp_cal_divergence(
  .data,
  .abundance,
  .name = "divergence",
  reference = "mean",
  distFUN = vegan::vegdist,
  method = "bray",
  action = "add",
  ...
)

## S4 method for signature 'tbl_mpse'
mp_cal_divergence(
  .data,
  .abundance,
  .name = "divergence",
  reference = "mean",
  distFUN = vegan::vegdist,
  method = "bray",
  action = "add",
  ...
)

## S4 method for signature 'grouped_df_mpse'
mp_cal_divergence(
  .data,
  .abundance,
  .name = "divergence",
  reference = "mean",
  distFUN = vegan::vegdist,
  method = "bray",
  action = "add",
  ...
)

Arguments

.data

MPSE or tbl_mpse object

.abundance

The column name of OTU abundance column to be calculate.

.name

the colname name of the divergence results, default is 'divergence'.

reference

a no-empty character, either 'median' or 'mean' or the sample name, or a numeric vector which has length equal to the number of features, default is 'mean'.

distFUN

the function to calculate the distance between the reference and samples, default is 'vegan::vegdist'.

method

the method to calculate the distance, which will pass to the function that is specified in 'distFUN', default is 'bray'.

action

character it has three options, "add" joins the new information to the input tbl (default), "only" return a non-redundant tibble with the just new information, ang 'get' return a 'alphasample' object.

...

additional arguments, see also the arguments of 'distFUN' function.

Value

update object or other (refer to action)

Author(s)

Shuangbin Xu

See Also

[mp_plot_alpha()]

Examples

## Not run: 
# example(mp_cal_divergence, run.dontrun = TRUE) to run the example.
data(mouse.time.mpse)
mouse.time.mpse %>% 
  mp_cal_divergence(
    .abundance = Abundance,
    .name = 'divergence.mean',
    distFUN = vegan::vegdist,
    method = 'bray'
  ) %>% 
  mp_plot_alpha(
    .alpha = divergence.mean,
    .group = time,
  )

## End(Not run)

YuLab-SMU/MicrobiotaProcess documentation built on July 26, 2024, 4:21 a.m.