-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from waldronlab/sdgamboa/scml
Add scml function for the dataset with spike-in bacteria
- Loading branch information
Showing
8 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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,3 +1,8 @@ | ||
# Changes in version 0.99.0 (2021-09-26) | ||
|
||
+ Added a `NEWS.md` file to track changes to the package. | ||
|
||
# Changes in version 1.7.1 (2021-09-26) | ||
|
||
+ Added a function (`scml`) for re-calibrating the "Stammler_2016_16S_spikein" | ||
dataset with SCML: spike-in-based calibration to total microbial load. |
This file contains 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,50 @@ | ||
#' SCML: spike-in-based calibration to total microbial load | ||
#' | ||
#' The \code{scml} function applies the | ||
#' spike-in-based calibration to total microbial load (SCML) method to | ||
#' | ||
#' @param tse A treeSummarizedExperiment from the \code{getBenchmarkData} | ||
#' function. | ||
#' @param bac A character. One of the following options: | ||
#' s = Salinibacter ruber (AF323500), r = Rhizobium radiobacter (AB247615), | ||
#' a, = Alicyclobacillus acidiphilus (AB076660) | ||
#' | ||
#' @return A TreeSummarizedExperiment with SCML data instead of counts. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' tse <- getBenchmarkData("Stammler_2016_16S_spikein", dryrun = FALSE)[[1]] | ||
#' tseSCML <- scml(tse, bac = "s") | ||
#' | ||
scml <- function(tse, bac = c("s", "r", "a")) { | ||
bacLetter <- match.arg(bac) | ||
bacNames <- c( | ||
s = "AF323500XXXX", r = "AB247615XXXX", a = "AB076660XXXX" | ||
) | ||
bacFullNames <- c( | ||
AF323500XXXX = "Salinibacter ruber (AF323500)", | ||
AB247615XXXX = "Rhizobium radiobacter (AB247615)", | ||
AB076660XXXX = "Alicyclobacillus acidiphilus (AB076660)" | ||
|
||
) | ||
bacName <- bacNames[bacLetter] | ||
|
||
lgl <- bacName %in% rownames(tse) | ||
if (!lgl) { | ||
stop( | ||
"Feature", bacName, "not found.", | ||
"Are you sure you're using the Stammler_2016_16S_spikein", | ||
call. = FALSE | ||
) | ||
} | ||
message("Re-calibrating counts with ", bacFullNames[bacName]) | ||
counts <- SummarizedExperiment::assay(tse, 1) | ||
bacAb <- counts[bacName, ] | ||
sizeFactor <- bacAb/mean(bacAb) | ||
scmlData <- counts | ||
for(i in seq(ncol(scmlData))){ | ||
scmlData[,i] <- round(scmlData[,i] / sizeFactor[i]) | ||
} | ||
SummarizedExperiment::assay(tse) <- scmlData | ||
return(tse) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,6 @@ | ||
test_that("scml works", { | ||
tse <- suppressWarnings(getBenchmarkData("Stammler_2016_16S_spikein", dryrun = FALSE)[[1]]) | ||
expect_s4_class(scml(tse, bac = "s"), "TreeSummarizedExperiment") | ||
expect_s4_class(scml(tse, bac = "r"), "TreeSummarizedExperiment") | ||
expect_s4_class(scml(tse, bac = "a"), "TreeSummarizedExperiment") | ||
}) |
This file contains 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