mp_cal_dist {MicrobiotaProcess} | R Documentation |
Calculate the distances between the samples with specified abundance.
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, ... )
.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
|
update object or tibble according the 'action'
Shuangbin Xu
[mp_extract_dist()] and [mp_plot_dist()]
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)