Skip to content

PERMANOVA final output table #863

Description

@artur-sannikov

We had a short discussion on Mattermost about it.

Currently in the chapter on the community
similarity
,
we use getPERMANOVA function to output it into a separate object. We can also
use addPERMANOVA() function to add it directly to metadata of TreeSE (see
docs):

tse <- addPERMANOVA(
    tse,
    assay.type = "relabundance",
    method = "bray",
    formula = x ~ SampleType,
    permutations = 99
    )
# The results are stored to metadata
metadata(tse)[["permanova"]]

We can rewrite that part by using addPERMANOVA().

For my own project I wrote this function, which can be used to output the
final table in Quarto document.

library(mia)
library(janitor)
library(tidyverse)
library(knitr)
library(kableExtra)

outputFullPermanova <- function(x) {
  x$permanova |>
    as.data.frame() |>
    slice(1:3) |>
    rename(p_val = "Pr(>F)") |>
    cbind(
      x$homogeneity |>
        rename("p_homogeneity" = "Pr(>F)")
    ) |>
    clean_names() |>
    rownames_to_column("variable") |>
    select(variable, r2, p_val, p_homogeneity) |>
    mutate(
      variable = str_to_title(variable)
    ) |>
    kable(
      digits = 3,
      row.names = FALSE,
      booktabs = TRUE,
      col.names = c("Variable", "R2", "P", "P Homogeneity")
    ) |>
    kable_styling(latex_options = c("hold_position", "striped"), font_size = 8)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions