Skip to content

Commit

Permalink
Merge pull request #14 from biobakery/devel
Browse files Browse the repository at this point in the history
Allow assay_type
  • Loading branch information
WillNickols authored Jan 30, 2025
2 parents 5be8dba + 76bde7d commit c52f782
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: maaslin3
Title: "Refining and extending generalized multivariate linear models
for meta-omic association discovery"
Year: 2024
Version: 0.99.3
Version: 1.0.0
Authors@R: c(
person("William", "Nickols", email = "[email protected]", role = c("aut", "cre"), comment=c(ORCID="0000-0001-8214-9746")),
person("Jacob", "Nearing", email = "[email protected]", role = "aut")
Expand Down
5 changes: 3 additions & 2 deletions R/maaslin3.R
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,8 @@ maaslin3 <- function(input_data,
save_models = FALSE,
save_plots_rds = FALSE,
verbosity = 'FINEST',
summary_plot_balanced = FALSE) {
summary_plot_balanced = FALSE,
assay_type = 1) {
match.arg(verbosity, c("FINEST", "FINER", "FINE", "DEBUG", "INFO",
"WARN", "ERROR"))
logging::logReset()
Expand All @@ -2679,7 +2680,7 @@ maaslin3 <- function(input_data,

if (inherits(input_data, "SummarizedExperiment")) {
summarized_experiment_out <-
maaslin_read_summarized_experiment_data(input_data)
maaslin_read_summarized_experiment_data(input_data, assay_type)

input_data <- summarized_experiment_out[['data']]
input_metadata <- summarized_experiment_out[['metadata']]
Expand Down
4 changes: 2 additions & 2 deletions R/utility_scripts.R
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,12 @@ preprocess_dna_mtx <- function(dna_table, rna_table) {
# Read from SummarizedExperiment #
##################################

maaslin_read_summarized_experiment_data <- function(summarized_experiment) {
maaslin_read_summarized_experiment_data <- function(summarized_experiment, assay_type = 1) {
if (!inherits(summarized_experiment, "SummarizedExperiment")) {
stop("Input must be a SummarizedExperiment object")
}

data <- as.data.frame(t(SummarizedExperiment::assay(summarized_experiment)))
data <- as.data.frame(t(SummarizedExperiment::assay(summarized_experiment, assay_type)))
metadata <- as.data.frame(
SummarizedExperiment::colData(summarized_experiment))
return(list(
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ significant associations.
* `max_pngs` (default `30`): The top `max_pngs` significant associations
will be plotted.

#### Technical parameters ####
#### Technical/miscellaneous parameters ####

* `cores` (default `1`): How many cores to use when fitting models.
(Using multiple cores will likely be faster only for large datasets or
Expand All @@ -661,6 +661,8 @@ save them to an RData file.
* `verbosity` (default `'FINEST'`): The level of verbosity for the
`logging` package.
* `save_plots_rds` (default `FALSE`): Whether to save the plots as RDS files.
* `assay_type` (default `1`): A string or index to select the assay when using
a `SummarizedExperiment` object.

## Troubleshooting ##

Expand Down
7 changes: 5 additions & 2 deletions man/maaslin3.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This wrapper for all MaAsLin 3 steps finds abundance and prevalence
}
\usage{
maaslin3(input_data,
input_metadata,
input_metadata = NULL,
output,
formula = NULL,
fixed_effects = NULL,
Expand Down Expand Up @@ -59,7 +59,8 @@ maaslin3(input_data,
save_models = FALSE,
save_plots_rds = FALSE,
verbosity = 'FINEST',
summary_plot_balanced = FALSE)
summary_plot_balanced = FALSE,
assay_type = 1)
}
\arguments{
\item{input_data}{A data frame of feature abundances or read counts, a
Expand Down Expand Up @@ -222,6 +223,8 @@ maaslin3(input_data,
\code{coef_plot_vars} where N is equal to:
\code{ceiling(summary_plot_first_n/length(coef_plot_vars))}. Will error
if \code{coef_plot_vars} = \code{NULL}}
\item{assay_type}{A string or index to select the assay when using
a \code{SummarizedExperiment} object}
}
\value{
A list containing the following items:
Expand Down
13 changes: 8 additions & 5 deletions tests/testthat/test_Maaslin3.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ fit_out <- maaslin3(input_data = se,
verbosity = 'WARN')

tse <- TreeSummarizedExperiment::TreeSummarizedExperiment(
assays = list(taxa_table = t(taxa_table)),
assays = list(taxa_table_junk = matrix(0, nrow = ncol(taxa_table), ncol = nrow(taxa_table)),
another_taxa_table = t(taxa_table)),
colData = metadata
)

metadata_df <- as(metadata, "DataFrame")
fit_out <- maaslin3(input_data = tse,
input_metadata = metadata,
input_metadata = metadata_df,
output = output_tmp,
normalization = 'TSS',
transform = 'LOG',
Expand All @@ -79,9 +81,9 @@ fit_out <- maaslin3(input_data = tse,
median_comparison_abundance = TRUE,
median_comparison_prevalence = FALSE,
cores=1,
verbosity = 'WARN')
verbosity = 'WARN',
assay_type = 'another_taxa_table')

metadata <- as(metadata, "DataFrame")
fit_out <- maaslin3(input_data = tse,
input_metadata = metadata,
output = output_tmp,
Expand All @@ -96,6 +98,7 @@ fit_out <- maaslin3(input_data = tse,
median_comparison_abundance = TRUE,
median_comparison_prevalence = FALSE,
cores=1,
verbosity = 'WARN')
verbosity = 'WARN',
assay_type = 2)

unlink(output_tmp, recursive = T)
4 changes: 3 additions & 1 deletion vignettes/maaslin3_manual.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ significant associations.
* `max_pngs` (default `30`): The top `max_pngs` significant associations
will be plotted.

#### Technical parameters ####
#### Technical/miscellaneous parameters ####

* `cores` (default `1`): How many cores to use when fitting models.
(Using multiple cores will likely be faster only for large datasets or
Expand All @@ -899,6 +899,8 @@ save them to an RData file.
* `verbosity` (default `'FINEST'`): The level of verbosity for the
`logging` package.
* `save_plots_rds` (default `FALSE`): Whether to save the plots as RDS files.
* `assay_type` (default `1`): A string or index to select the assay when using
a `SummarizedExperiment` object.

## Tool comparison ##

Expand Down

0 comments on commit c52f782

Please sign in to comment.