-
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.
v0.3.2, updates to
ms_tidy_msdial
function
- Loading branch information
Showing
8 changed files
with
63 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: msdialreadr | ||
Type: Package | ||
Title: Read and Analyze MS-DIAL Alignment Files | ||
Version: 0.3.1 | ||
Version: 0.3.2 | ||
Authors@R: | ||
person("Ethan", "Bass", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-6175-6739")) | ||
|
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,22 +1,39 @@ | ||
#' Convert peak to tidy format for plotting | ||
#' @param x An MS dial alignment object | ||
#' @param peaks Peaks to include in tidy output | ||
#' @param treatments Treatments to include in tidy output | ||
#' @param x An MS dial alignment object. | ||
#' @param peaks A character vector specifying the peaks to include in tidy output. | ||
#' If the character vector is named, the names of the vector elements will be | ||
#' used in place of the original peak names. | ||
#' @param metadata A character vector specifying the metadata to include in | ||
#' the tidy output. | ||
#' @param treatments This argument is deprecated as of version 0.3.2. It is | ||
#' synonymous with the new metadata argument which should be used instead. | ||
#' @importFrom dplyr select mutate any_of | ||
#' @importFrom tidyr pivot_longer | ||
#' @return If \code{export} is \code{TRUE}, returns spectrum as \code{data.frame}. | ||
#' Otherwise, no return value. | ||
#' @author Ethan Bass | ||
#' @export | ||
|
||
ms_tidy_msdial <- function(x, peaks, treatments){ | ||
df <- as.data.frame(x$tab) | ||
if (is.numeric(peaks)){ | ||
peaks <- colnames(df)[peaks] | ||
ms_tidy_msdial <- function(x, peaks, metadata, treatments){ | ||
if (!missing(treatments)){ | ||
.Deprecated("metadata", package="msdialreadr", old = "treatments", | ||
msg="The `treatments` argument is deprecated as of msdialreadr v0.3.2. | ||
\t Please use the `metadata` argument instead.") | ||
metadata <- treatments | ||
} | ||
df <- select(df, any_of(peaks)) | ||
df <- cbind(df, select(x$sample_meta, any_of(treatments))) | ||
if (!missing(peaks)){ | ||
if (is.numeric(peaks)){ | ||
peaks <- colnames(df)[peaks] | ||
} | ||
x$tab <- x$tab[,which(colnames(x$tab) %in% peaks), drop = FALSE] | ||
if (!is.null(names(peaks))){ | ||
colnames(x$tab) <- names(peaks) | ||
peaks <- names(peaks) | ||
} | ||
x} | ||
df <- as.data.frame(x$tab) | ||
df <- cbind(df, select(x$sample_meta, any_of(metadata))) | ||
df <- mutate(df, sample = row.names(x)) | ||
df <- pivot_longer(df, cols=peaks, names_to="peak") | ||
df <- pivot_longer(df, cols = peaks, names_to="peak") | ||
df | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.