Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #174: TreeSE support non-taxonomic ranks #201

Merged
merged 5 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/ancombc2.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@
#' (only applicable if data object is a \code{(Tree)SummarizedExperiment}).
#' Default is "counts".
#' See \code{?SummarizedExperiment::assay} for more details.
#' @param tax_level character. The taxonomic level of interest. The input data
#' can be analyzed at any taxonomic level without prior agglomeration.
#' Note that \code{tax_level} must be a value from \code{taxonomyRanks}, which
#' includes "Kingdom", "Phylum" "Class", "Order", "Family" "Genus" or "Species".
#' @param tax_level character. The taxonomic or non taxonomic(rowData) level of interest. The input data
#' can be analyzed at any taxonomic or rowData level without prior agglomeration.
#' Note that \code{tax_level} must be a value from \code{taxonomyRanks} or \code{rowData}, which
#' includes "Kingdom", "Phylum" "Class", "Order", "Family" "Genus" "Species" etc.
#' See \code{?mia::taxonomyRanks} for more details.
#' Default is NULL, i.e., do not perform agglomeration, and the
#' ANCOM-BC2 anlysis will be performed at the lowest taxonomic level of the
#' ANCOM-BC2 analysis will be performed at the lowest taxonomic level of the
#' input \code{data}.
#' @param fix_formula the character string expresses how the microbial absolute
#' abundances for each taxon depend on the fixed effects in metadata. When
Expand Down
20 changes: 2 additions & 18 deletions R/ancombc_prep.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,10 @@ tse_construct = function(data, assay_name, tax_level, phyloseq) {

# Check if agglomeration should be performed
if (is.null(tax_level)) {
tax_levels = mia::taxonomyRanks(tse)
txt = sprintf(paste0("`tax_level` is not specified \n",
"No agglomeration will be performed",
"\n",
"Otherwise, please specify `tax_level` ",
"by one of the following: \n",
paste(tax_levels, collapse = ", ")))
message(txt)
tax_level = "ASV"
tse_alt = tse
} else {
tse_alt = mia::agglomerateByRank(tse, tax_level)
tse_alt = mia:::.merge_features(tse, tax_level)
}
SingleCellExperiment::altExp(tse, tax_level) = tse_alt
} else if (!is.null(phyloseq)) {
Expand All @@ -57,18 +49,10 @@ tse_construct = function(data, assay_name, tax_level, phyloseq) {
}

if (is.null(tax_level)) {
tax_levels = mia::taxonomyRanks(tse)
txt = sprintf(paste0("`tax_level` is not speficified \n",
"No agglomeration will be performed",
"\n",
"Otherwise, please speficy `tax_level` ",
"by one of the following: \n",
paste(tax_levels, collapse = ", ")))
message(txt)
tax_level = "ASV"
tse_alt = tse
} else {
tse_alt = mia::agglomerateByRank(tse, tax_level)
tse_alt = mia:::.merge_features(tse, tax_level)
}
SingleCellExperiment::altExp(tse, tax_level) = tse_alt
} else {
Expand Down