Skip to content

Commit

Permalink
update docs, fix sarch_spectra bug, change to GPL3
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbass committed Jan 25, 2023
1 parent e22351a commit 761a213
Show file tree
Hide file tree
Showing 9 changed files with 620 additions and 33 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Imports:
tidyr
Suggests:
plotly
License: MIT + file LICENSE
License: GPL (>= 3)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.1
616 changes: 595 additions & 21 deletions LICENSE.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# msdialreadr 0.2.0

* Update license to GPL3.
* Added a `NEWS.md` file to track changes to the package.
* Added `search_msp` function to conduct database searches for spectra.
8 changes: 8 additions & 0 deletions R/attach_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@ keep_order <- function(data, fn, ...) {
out[,col] <- NULL
out
}

transfer_metadata <- function(new_object, old_object,
exclude = c('names','row.names','class','dim','dimnames')){
a <- attributes(old_object)
a[exclude] <- NULL
attributes(new_object) <- c(attributes(new_object), a)
new_object
}
3 changes: 2 additions & 1 deletion R/normalization.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#' @author E. Nevedomskaya
#' @author Rico Derks
#' @author Ethan Bass
#' @note Adapted from Rcpm package (https://github.com/ricoderks/Rcpm)
#' @note Adapted from the \href{https://github.com/ricoderks/Rcpm}{Rcpm} package
#' by Rico Derks (licensed under GPL3).
#' @references Dieterle, F., Ross, A., Schlotterbeck, G. & Senn, H. Probabilistic Quotient
#' Normalization as Robust Method to Account for Dilution of Complex Biological Mixtures.
#' Application in H1 NMR Metabonomics. Anal. Chem. 78, 4281-4290 (2006).
Expand Down
14 changes: 8 additions & 6 deletions R/search_spectra.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Search spectra in MSDIAL alignment against database
#' @param x An \code{msdial_alignment} object.
#' @param db MSP database as list
Expand All @@ -11,7 +10,7 @@
#' @param n.results How many results to return.
#' @param mc.cores How many cores to use for parallel processing? Defaults to 2.
#' @param ris Retention indices to use
#' @note See [mspcompiler](https://github.com/QizhiSu/mspcompiler) for help compiling
#' @note See \href{https://github.com/QizhiSu/mspcompiler}{mspcompiler} for help compiling
#' an msp database.
#' @return Returns a modified \code{msdial_alignment} object with database matches
#' in the \code{matches} slot.
Expand All @@ -27,6 +26,9 @@ search_spectra <- function(x, db, cols, ..., ri_thresh = 100, spectral_weight =
if (missing(ris)){
ris <- sapply(db, function(x) x$RI)
}
if (missing(cols)){
cols <- seq_len(ncol(x$tab))
}
for (col in cols){
sp <- get_spectrum(x, col)
ri_diff <- abs(as.numeric(x$peak_meta[col, "Average.RI"]) - ris)
Expand Down Expand Up @@ -64,16 +66,16 @@ get_spectrum <- function(x, col){
#' @param parallel Logical. Whether to use parallel processing. (This feature
#' does not work on Windows).
#' @param mc.cores How many cores to use for parallel processing? Defaults to 2.
#' @param what What kind of object to return. Either \code{msdial_alignment} object (\code{msd})
#' or \code{data.frame} (\code{df}).
#' @param what What kind of object to return. Either \code{msdial_alignment} object,
#' (\code{msd}), or \code{data.frame} (\code{df}).
#' @importFrom pbapply pblapply
#' @importFrom OrgMassSpecR SpectrumSimilarity
#' @author Ethan Bass
#' @export

search_msp <- function(x, db, ..., n.results = 10, parallel, mc.cores = 2,
what=c("msd", "df","scores")){
# result <- match.arg(result, c("msd", "df", "scores"))
what=c("msd", "df", "scores")){
result <- match.arg(result, c("msd", "df", "scores"))
if (missing(parallel)){
parallel <- .Platform$OS.type != "windows"
} else if (parallel & .Platform$OS.type == "windows"){
Expand Down
3 changes: 2 additions & 1 deletion man/pqn.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/search_msp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/search_spectra.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 761a213

Please sign in to comment.