Commit 4daaa3f5 authored by Etienne Rifa's avatar Etienne Rifa
Browse files

update

add aggregate_top_taxa
parent 529c46d8
......@@ -3,6 +3,7 @@
export(ASVenn_fun)
export(VENNFUN)
export(aggregate_fun)
export(aggregate_top_taxa)
export(assign_taxo_fun)
export(bars_fun)
export(check_tax_fun)
......@@ -84,8 +85,9 @@ importFrom(metacoder,heat_tree)
importFrom(metacoder,parse_phyloseq)
importFrom(metacoder,taxon_names)
importFrom(metacoder,zero_low_counts)
importFrom(microbiome,aggregate_top_taxa)
importFrom(microbiome,aggregate_taxa)
importFrom(microbiome,core_members)
importFrom(microbiome,top_taxa)
importFrom(microbiome,transform)
importFrom(nlme,lme)
importFrom(phangorn,NJ)
......
......@@ -31,6 +31,32 @@ rarefaction <- function(data = data, col = NULL, step = 100, ggplotly = TRUE){
}
#' aggregate_top_taxa from microbiome package
#'
#'
#' @param x phyloseq object
#' @param top Keep the top-n taxa, and merge the rest under the category 'Other'. Instead of top-n numeric this can also be a character vector listing the groups to combine.
#' @param level Summarization level (from ‘rank_names(pseq)’)
#'
#' @importFrom microbiome aggregate_taxa
#' @importFrom microbiome top_taxa
#'
#' @export
aggregate_top_taxa <- function (x, top, level){
x <- aggregate_taxa(x, level)
tops <- top_taxa(x, top)
tax <- tax_table(x)
inds <- which(!rownames(tax) %in% tops)
tax[inds, level] <- "Other"
tax_table(x) <- tax
tt <- tax_table(x)[, level]
tax_table(x) <- tax_table(tt)
aggregate_taxa(x, level)
}
#' Barplots plotly
#'
#'
......@@ -48,7 +74,6 @@ rarefaction <- function(data = data, col = NULL, step = 100, ggplotly = TRUE){
#' @return Returns barplots in an interactive plotly community plot
#'
#' @import plotly
#' @importFrom microbiome aggregate_top_taxa
#' @importFrom reshape2 melt
#' @importFrom gtools mixedsort
#' @importFrom dplyr group_map group_by across
......@@ -75,6 +100,8 @@ if( all(Ord1 != sample_variables(data)) | all(Fact1 != sample_variables(data))){
Fdata = data
psobj.top <- aggregate_top_taxa(Fdata, rank, top = top)
# print("get data")
sdata <- as.data.frame(sample_data(psobj.top), stringsAsFactors = TRUE)
# sdata$sample.id = sample_names(psobj.top)
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bars_fun.R
\name{aggregate_top_taxa}
\alias{aggregate_top_taxa}
\title{aggregate_top_taxa from microbiome package}
\usage{
aggregate_top_taxa(x, top, level)
}
\arguments{
\item{x}{phyloseq object}
\item{top}{Keep the top-n taxa, and merge the rest under the category 'Other'. Instead of top-n numeric this can also be a character vector listing the groups to combine.}
\item{level}{Summarization level (from ‘rank_names(pseq)’)}
}
\description{
aggregate_top_taxa from microbiome package
}
......@@ -12,6 +12,7 @@ bars_fun(
Fact1 = NULL,
split = FALSE,
relative = TRUE,
autoorder = TRUE,
ylab = "Abundance",
outfile = "plot_compo.html",
verbose = TRUE
......@@ -32,6 +33,8 @@ bars_fun(
\item{relative}{Plot relative (TRUE, default) or raw abundance plot (FALSE)}
\item{autoorder}{Order xaxis with gtools::mixedorder function (TRUE).}
\item{ylab}{Y axis title ("Abundance")}
\item{outfile}{Output html file.}
......
......@@ -12,7 +12,9 @@ diversity_beta_light(
dist0 = "bray",
ord0 = "MDS",
output = "./plot_div_beta/",
tests = TRUE
axes = c(1, 2),
tests = TRUE,
verbose = 2
)
}
\arguments{
......@@ -30,7 +32,11 @@ diversity_beta_light(
\item{output}{The output file directory.}
\item{axes}{Axes to plot (c(1,2))}
\item{tests}{Whether to compute tests or not (TRUE/FALSE)}
\item{verbose}{Verbose level. (1: quiet, 2: print infos, 3: print infos + debug)}
}
\value{
Return specific plots and tests in list and output them in the output directory.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment