Repository navigation
add tests #10
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
Merged
Merged
add tests #10
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e7653ed
up
0xMuluh 547cca7
up
0xMuluh f4f4d0a
Merge pull request #2 from 0xMuluh/new_stuff2
0xMuluh 5ac523a
up
0xMuluh d838806
up
0xMuluh ebb77ca
Merge pull request #3 from 0xMuluh/new_stuff2
0xMuluh c7ca84a
up
0xMuluh aa1ef55
Merge pull request #4 from 0xMuluh/new_stuff2
0xMuluh 34c5c7c
up
0xMuluh 54300b4
Merge pull request #5 from 0xMuluh/new_stuff2
0xMuluh 1b44f39
up
0xMuluh 4ed37ed
Merge pull request #6 from 0xMuluh/new_stuff2
0xMuluh 4fd98eb
up
0xMuluh f064341
Merge pull request #7 from 0xMuluh/new_stuff2
0xMuluh ab5249c
Update DESCRIPTION
TuomasBorman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,7 @@ | |
| ^README\.Rmd$ | ||
| ^\.github$ | ||
| ^codecov\.yml$ | ||
| ^pkgdown$ | ||
| ^README\.html$ | ||
| ^doc$ | ||
| ^Meta$ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ dev | |
| inst/doc | ||
| vignettes/*.html | ||
| vignettes/*.R | ||
| /doc/ | ||
| /Meta/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,30 @@ | ||
| # Generated by roxygen2: do not edit by hand | ||
|
|
||
| export(getAnova) | ||
| export(getFirth) | ||
| export(getKruskal) | ||
| export(getLimma) | ||
| export(getLm) | ||
| export(getOrm) | ||
| export(getTTest) | ||
| export(getWilcoxonTest) | ||
| importFrom(SummarizedExperiment,assay) | ||
| importFrom(SummarizedExperiment,assayNames) | ||
| importFrom(SummarizedExperiment,colData) | ||
| importFrom(SummarizedExperiment,rowData) | ||
| importFrom(dplyr,arrange) | ||
| importFrom(dplyr,bind_rows) | ||
| importFrom(dplyr,filter) | ||
| importFrom(dplyr,group_by) | ||
| importFrom(dplyr,left_join) | ||
| importFrom(dplyr,mutate) | ||
| importFrom(dplyr,n_distinct) | ||
| importFrom(dplyr,ungroup) | ||
| importFrom(rlang,"!!") | ||
| importFrom(rlang,.data) | ||
| importFrom(rlang,sym) | ||
| importFrom(rstatix,anova_test) | ||
| importFrom(rstatix,kruskal_test) | ||
| importFrom(rstatix,t_test) | ||
| importFrom(rstatix,wilcox_test) | ||
| importFrom(tidyr,pivot_longer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #' @title Perform ANOVA | ||
| #' | ||
| #' @description | ||
| #' Performs ANOVA to compare values between two or more groups. | ||
| #' | ||
| #' @param tse A \code{SummarizedExperiment} object. | ||
| #' @param formula A formula where the LHS specifies the variable to test | ||
| #' (assay name, colData, or rowData variable) and the RHS specifies the | ||
| #' grouping variable, e.g., \code{counts ~ Group}. | ||
| #' @param ... Additional arguments passed to \code{rstatix::anova_test}. | ||
| #' | ||
| #' @return A \code{data.frame} with test results. | ||
| #' | ||
| #' @examples | ||
| #' data(peerj13075, package = "mia") | ||
| #' tse <- peerj13075 | ||
| #' tse <- mia::agglomerateByRank(tse, "phylum") | ||
| #' res <- getAnova(tse, counts ~ Geographical_location) | ||
| #' | ||
| #' @importFrom rstatix anova_test | ||
| #' @export | ||
| getAnova <- function(tse, formula, ...) { | ||
| if (length(all.vars(formula[[3]])) != 1L) { | ||
| stop("Formula RHS must specify exactly one grouping variable.", | ||
| call. = FALSE | ||
| ) | ||
| } | ||
| df <- .get_long_data(tse, formula) | ||
| res <- .calculate_rstatix( | ||
| df = df, formula = formula, | ||
| FUN = rstatix::anova_test, ... | ||
| ) | ||
| return(res) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #' @title Fit Firth logistic regression per feature | ||
| #' | ||
| #' @description | ||
| #' Fits Firth logistic regression per feature using wide-format data. | ||
| #' | ||
| #' @param tse A \code{SummarizedExperiment} object. | ||
| #' @param formula A formula where the LHS specifies the assay or colData | ||
| #' variable (must be binary/presence-absence) and the RHS specifies variables | ||
| #' from \code{colData(tse)}, e.g., \code{pa ~ Group + Age}. | ||
| #' @param ... Additional arguments (reserved for future use). | ||
| #' | ||
| #' @return A \code{data.frame} with per-feature model coefficients, p-values, | ||
| #' and BH-adjusted q-values. | ||
| #' | ||
| #' @examples | ||
| #' \dontrun{ | ||
| #' data(peerj13075, package = "mia") | ||
| #' tse <- peerj13075 | ||
| #' tse <- mia::agglomerateByRank(tse, "phylum") | ||
| #' tse <- mia::transformAssay(tse, method = "pa") | ||
| #' res <- getFirth(tse, pa ~ Geographical_location) | ||
| #' } | ||
| #' | ||
| #' @export | ||
| getFirth <- function(tse, formula, ...) { | ||
| data_list <- .get_wide_data(tse, formula) | ||
| res <- .train_model_per_feature( | ||
| formula = formula, | ||
| mat = data_list[["matrix"]], | ||
| metadata = data_list[["sample_metadata"]], | ||
| FUN = .run_firth | ||
| ) | ||
| return(res) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #' @title Perform Kruskal-Wallis test | ||
| #' | ||
| #' @description | ||
| #' Performs Kruskal-Wallis test to compare values between two or more groups. | ||
| #' | ||
| #' @param tse A \code{SummarizedExperiment} object. | ||
| #' @param formula A formula where the LHS specifies the variable to test | ||
| #' (assay name, colData, or rowData variable) and the RHS specifies the | ||
| #' grouping variable, e.g., \code{counts ~ Group}. | ||
| #' @param ... Additional arguments passed to \code{rstatix::kruskal_test}. | ||
| #' | ||
| #' @return A \code{data.frame} with test results. | ||
| #' | ||
| #' @examples | ||
| #' data(peerj13075, package = "mia") | ||
| #' tse <- peerj13075 | ||
| #' tse <- mia::agglomerateByRank(tse, "phylum") | ||
| #' res <- getKruskal(tse, counts ~ Geographical_location) | ||
| #' | ||
| #' @importFrom rstatix kruskal_test | ||
| #' @export | ||
| getKruskal <- function(tse, formula, ...) { | ||
| if (length(all.vars(formula[[3]])) != 1L) { | ||
| stop("Formula RHS must specify exactly one grouping variable.", | ||
| call. = FALSE | ||
| ) | ||
| } | ||
| df <- .get_long_data(tse, formula) | ||
| res <- .calculate_rstatix( | ||
| df = df, formula = formula, | ||
| FUN = rstatix::kruskal_test, ... | ||
| ) | ||
| return(res) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #' @title Fit limma model | ||
| #' | ||
| #' @description | ||
| #' Fits a limma model using wide-format data and sample metadata. | ||
| #' | ||
| #' @param tse A \code{SummarizedExperiment} object. | ||
| #' @param formula A formula where the LHS specifies the assay or colData | ||
| #' variable and the RHS specifies variables from \code{colData(tse)}, | ||
| #' e.g., \code{counts ~ Group}. | ||
| #' @param ... Additional arguments (reserved for future use). | ||
| #' | ||
| #' @return A fitted limma model object (result of \code{limma::eBayes}). | ||
| #' | ||
| #' @examples | ||
| #' data(peerj13075, package = "mia") | ||
| #' tse <- peerj13075 | ||
| #' tse <- mia::agglomerateByRank(tse, "phylum") | ||
| #' fit <- getLimma(tse, counts ~ Geographical_location) | ||
| #' | ||
| #' @export | ||
| getLimma <- function(tse, formula, ...) { | ||
| data_list <- .get_wide_data(tse, formula) | ||
| res <- .calculate_limma( | ||
| formula = formula, | ||
| mat = data_list[["matrix"]], | ||
| metadata = data_list[["sample_metadata"]] | ||
| ) | ||
| return(res) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #' @title Fit linear model per feature | ||
| #' | ||
| #' @description | ||
| #' Fits a linear model per feature using wide-format data and sample metadata. | ||
| #' | ||
| #' @param tse A \code{SummarizedExperiment} object. | ||
| #' @param formula A formula where the LHS specifies the assay or colData | ||
| #' variable and the RHS specifies variables from \code{colData(tse)}, | ||
| #' e.g., \code{rclr ~ Group}. | ||
| #' @param ... Additional arguments (reserved for future use). | ||
| #' | ||
| #' @return A \code{data.frame} with per-feature model coefficients, p-values, | ||
| #' and BH-adjusted q-values. | ||
| #' | ||
| #' @examples | ||
| #' data(peerj13075, package = "mia") | ||
| #' tse <- peerj13075 | ||
| #' tse <- mia::agglomerateByRank(tse, "phylum") | ||
| #' tse <- mia::transformAssay(tse, method = "rclr") | ||
| #' res <- getLm(tse, rclr ~ Geographical_location) | ||
| #' | ||
| #' @export | ||
| getLm <- function(tse, formula, ...) { | ||
| data_list <- .get_wide_data(tse, formula) | ||
| res <- .train_model_per_feature( | ||
| formula = formula, | ||
| mat = data_list[["matrix"]], | ||
| metadata = data_list[["sample_metadata"]], | ||
| FUN = .run_lm | ||
| ) | ||
| return(res) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #' @title Fit ordinal regression model per feature | ||
| #' | ||
| #' @description | ||
| #' Fits an ordinal regression model (ORM) per feature using wide-format data. | ||
| #' | ||
| #' @param tse A \code{SummarizedExperiment} object. | ||
| #' @param formula A formula where the LHS specifies the assay or colData | ||
| #' variable and the RHS specifies variables from \code{colData(tse)}, | ||
| #' e.g., \code{counts ~ Group}. | ||
| #' @param ... Additional arguments (reserved for future use). | ||
| #' | ||
| #' @return A \code{data.frame} with per-feature model coefficients, p-values, | ||
| #' and BH-adjusted q-values. | ||
| #' | ||
| #' @examples | ||
| #' data(peerj13075, package = "mia") | ||
| #' tse <- peerj13075 | ||
| #' tse <- mia::agglomerateByRank(tse, "phylum") | ||
| #' res <- getOrm(tse, counts ~ Geographical_location) | ||
| #' | ||
| #' @export | ||
| getOrm <- function(tse, formula, ...) { | ||
| data_list <- .get_wide_data(tse, formula) | ||
| res <- .train_model_per_feature( | ||
| formula = formula, | ||
| mat = data_list[["matrix"]], | ||
| metadata = data_list[["sample_metadata"]], | ||
| FUN = .run_orm | ||
| ) | ||
| return(res) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #' @title Perform t-test | ||
| #' | ||
| #' @description | ||
| #' Performs t-test to compare values between two groups. | ||
| #' | ||
| #' @param tse A \code{SummarizedExperiment} object. | ||
| #' @param formula A formula where the LHS specifies the variable to test | ||
| #' (assay name, colData, or rowData variable) and the RHS specifies the | ||
| #' grouping variable, e.g., \code{counts ~ Group}. | ||
| #' @param pair.by \code{Character scalar} or \code{NULL}. Column for pairing | ||
| #' samples in paired tests. (Default: \code{NULL}) | ||
| #' @param ... Additional arguments passed to \code{rstatix::t_test}. | ||
| #' | ||
| #' @return A \code{data.frame} with test results. | ||
| #' | ||
| #' @examples | ||
| #' data(peerj13075, package = "mia") | ||
| #' tse <- peerj13075 | ||
| #' tse <- mia::agglomerateByRank(tse, "phylum") | ||
| #' res <- getTTest(tse, counts ~ Geographical_location) | ||
| #' | ||
| #' @importFrom rstatix t_test | ||
| #' @export | ||
| getTTest <- function(tse, formula, pair.by = NULL, ...) { | ||
| if (length(all.vars(formula[[3]])) != 1L) { | ||
| stop("Formula RHS must specify exactly one grouping variable.", | ||
| call. = FALSE | ||
| ) | ||
| } | ||
| df <- .get_long_data(tse, formula, pair.by) | ||
| res <- .calculate_rstatix( | ||
| df = df, formula = formula, | ||
| pair.by = pair.by, FUN = rstatix::t_test, ... | ||
| ) | ||
| return(res) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #' @title Perform Wilcoxon rank-sum test | ||
| #' | ||
| #' @description | ||
| #' Performs Wilcoxon rank-sum test (Mann-Whitney U) to compare values between | ||
| #' two groups. | ||
| #' | ||
| #' @param tse A \code{SummarizedExperiment} object. | ||
| #' @param formula A formula where the LHS specifies the variable to test | ||
| #' (assay name, colData, or rowData variable) and the RHS specifies the | ||
| #' grouping variable, e.g., \code{counts ~ Group}. | ||
| #' @param pair.by \code{Character scalar} or \code{NULL}. Column for pairing | ||
| #' samples in paired tests. (Default: \code{NULL}) | ||
| #' @param ... Additional arguments passed to \code{rstatix::wilcox_test}. | ||
| #' | ||
| #' @return A \code{data.frame} with test results. | ||
| #' | ||
| #' @examples | ||
| #' data(peerj13075, package = "mia") | ||
| #' tse <- peerj13075 | ||
| #' tse <- mia::agglomerateByRank(tse, "phylum") | ||
| #' res <- getWilcoxonTest(tse, counts ~ Geographical_location) | ||
| #' | ||
| #' @importFrom rstatix wilcox_test | ||
| #' @export | ||
| getWilcoxonTest <- function(tse, formula, pair.by = NULL, ...) { | ||
| if (length(all.vars(formula[[3]])) != 1L) { | ||
| stop("Formula RHS must specify exactly one grouping variable.", | ||
| call. = FALSE | ||
| ) | ||
| } | ||
| df <- .get_long_data(tse, formula, pair.by) | ||
| res <- .calculate_rstatix( | ||
| df = df, formula = formula, | ||
| pair.by = pair.by, FUN = rstatix::wilcox_test, ... | ||
| ) | ||
| return(res) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.