View source: R/table_functions.R
formattable_pq | R Documentation |
formattable_pq(
physeq,
modality,
taxonomic_levels = c("Phylum", "Order", "Family", "Genus"),
min_nb_seq_taxa = 1000,
log10trans = FALSE,
void_style = FALSE,
lev_col_taxa = "Phylum",
arrange_by = "nb_seq",
descending_order = TRUE,
na_remove = TRUE,
formattable_args = NULL
)
physeq |
(required): a |
modality |
(required) The name of a column present in the |
taxonomic_levels |
(default = c("Phylum", "Order", "Family", "Genus"))
The taxonomic levels (must be present in the |
min_nb_seq_taxa |
(default = 1000) filter out taxa with less than |
log10trans |
(logical, default TRUE) Do sequences count is log10 transformed (using log10(x + 1) to allow 0) |
void_style |
(logical, default FALSE) Do the default style is discard ? |
lev_col_taxa |
Taxonomic level used to plot the background color of taxa names |
arrange_by |
The column used to sort the table. Can take the values NULL, "proportion_samp", "nb_seq" (default), , "nb_sam" "OTU", or a column names from the levels of modality or from taxonomic levels |
descending_order |
(logical, default TRUE) Do we use descending order when sort the table (if arrange_by is not NULL) ? |
na_remove |
(logical, default TRUE) if TRUE remove all the samples
with NA in the |
formattable_args |
Other args to the formattable function. See examples and |
This function is mainly a wrapper of the work of others.
Please make a reference to formattable::formattable()
if you
use this function.
A datatable
Adrien Taudière
formattable::formattable()
if (requireNamespace("formattable")) {
## Distribution of the nb of sequences per OTU across Height
## modality (nb of sequences are log-transformed).
## Only OTU with more than 10000 sequences are taking into account
## The Phylum column is discarded
formattable_pq(
data_fungi,
"Height",
min_nb_seq_taxa = 10000,
formattable_args = list("Phylum" = FALSE),
log10trans = TRUE
)
## Distribution of the nb of samples per OTU across Height modality
## Only OTU present in more than 50 samples are taking into account
formattable_pq(
as_binary_otu_table(data_fungi),
"Height",
min_nb_seq_taxa = 50,
formattable_args = list("nb_seq" = FALSE),
)
## Distribution of the nb of sequences per OTU across Time modality
## arranged by Family Name in ascending order.
## Only OTU with more than 10000 sequences are taking into account
## The Phylum column is discarded
formattable_pq(
data_fungi,
"Time",
min_nb_seq_taxa = 10000,
taxonomic_levels = c("Order", "Family", "Genus", "Species"),
formattable_args = list(
Order = FALSE,
Species = formattable::formatter(
"span",
style = x ~ formattable::style(
"font-style" = "italic",
`color` = ifelse(is.na(x), "white", "grey")
)
)
),
arrange_by = "Family",
descending_order = FALSE
)
}
if (requireNamespace("formattable")) {
## Distribution of the nb of sequences per OTU across Height modality
## (nb of sequences are log-transformed).
## OTU name background is light gray for Basidiomycota
## and dark grey otherwise (Ascomycota)
## A different color is defined for each modality level
formattable_pq(
data_fungi,
"Height",
taxonomic_levels = c("Phylum", "Family", "Genus"),
void_style = TRUE,
formattable_args = list(
OTU = formattable::formatter(
"span",
style = ~ formattable::style(
"display" = "block",
`border-radius` = "5px",
`background-color` = ifelse(Phylum == "Basidiomycota", transp("gray"), "gray")
),
`padding-right` = "2px"
),
High = formattable::formatter(
"span",
style = x ~ formattable::style(
"font-size" = "80%",
"display" = "inline-block",
direction = "rtl",
`border-radius` = "0px",
`padding-right` = "2px",
`background-color` = formattable::csscolor(formattable::gradient(
as.numeric(x), transp("#1a91ff"), "#1a91ff"
)),
width = formattable::percent(formattable::proportion(as.numeric(x), na.rm = TRUE))
)
),
Low = formattable::formatter(
"span",
style = x ~ formattable::style(
"font-size" = "80%",
"display" = "inline-block",
direction = "rtl",
`border-radius` = "0px",
`padding-right` = "2px",
`background-color` = formattable::csscolor(formattable::gradient(
as.numeric(x),
transp("green"), "green"
)),
width = formattable::percent(formattable::proportion(as.numeric(x), na.rm = TRUE))
)
),
Middle = formattable::formatter(
"span",
style = x ~ formattable::style(
"font-size" = "80%",
"display" = "inline-block",
direction = "rtl",
`border-radius` = "0px",
`padding-right` = "2px",
`background-color` = formattable::csscolor(formattable::gradient(
as.numeric(x), transp("orange"), "orange"
)),
width = formattable::percent(formattable::proportion(as.numeric(x), na.rm = TRUE))
)
)
)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.