mp_cal_alpha | R Documentation |
calculate the alpha index with MPSE or tbl_mpse
mp_cal_alpha(
.data,
.abundance = NULL,
action = c("add", "only", "get"),
force = FALSE,
...
)
## S4 method for signature 'MPSE'
mp_cal_alpha(.data, .abundance = NULL, action = "add", force = FALSE, ...)
## S4 method for signature 'tbl_mpse'
mp_cal_alpha(.data, .abundance = NULL, action = "add", force = FALSE, ...)
## S4 method for signature 'grouped_df_mpse'
mp_cal_alpha(.data, .abundance = NULL, action = "add", force = FALSE, ...)
.data |
MPSE or tbl_mpse object |
.abundance |
The column name of OTU abundance column to be calculate |
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. |
force |
logical whether calculate the alpha index even the '.abundance' is not rarefied, default is FALSE. |
... |
additional arguments |
update object or other (refer to action)
Shuangbin Xu
[mp_plot_alpha()]
data(mouse.time.mpse)
mpse <- mouse.time.mpse %>%
mp_rrarefy() %>%
mp_cal_alpha(.abundance=RareAbundance)
mpse
p <- mpse %>% mp_plot_alpha(.group=time, .alpha=c(Observe, Shannon, Pielou))
p
# Or you can extract the result and visualize it with ggplot2 and ggplot2-extensions
## Not run:
tbl <- mpse %>%
mp_extract_sample
tbl
tbl %<>%
tidyr::pivot_longer(cols=!c("Sample", "time"), names_to="measure", values_to="alpha")
tbl
library(ggplot2)
library(ggsignif)
library(gghalves)
p <- ggplot(data=tbl, aes(x=time, y=alpha, fill=time)) +
geom_half_violin(color=NA, side="l", trim=FALSE) +
geom_boxplot(aes(color=time), fill=NA, position=position_nudge(x=.22), width=0.2) +
geom_half_point(side="r", shape=21) +
geom_signif(comparisons=list(c("Early", "Late")), test="wilcox.test", textsize=2) +
facet_wrap(facet=vars(measure), scales="free_y", nrow=1) +
scale_fill_manual(values=c("#00A087FF", "#3C5488FF")) +
scale_color_manual(values=c("#00A087FF", "#3C5488FF"))
p
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.