Skip to content

Commit

Permalink
quickfix to read_CoreMS_data vignette to allow use of iso_cols in as.…
Browse files Browse the repository at this point in the history
…CoreMSData
  • Loading branch information
clabornd committed Dec 8, 2023
1 parent 2356084 commit 6513b46
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Suggests:
viridis,
DT
VignetteBuilder: knitr
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
15 changes: 5 additions & 10 deletions R/as.CoreMSData.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@
#' column containing the monoisotopic index in \code{all_data}
#' @param mf_cname a character string specifying the name of the column
#' containing the molecular formula in \code{all_data}
#' @param c13_cname a character string specifying the name of the column
#' containing the C13 logical indicator in \code{all_data}
#' @param s34_cname a character string specifying the name of the column
#' containing the S43 logical indicator in \code{all_data}
#' @param o18_cname a character string specifying the name of the column
#' containing the O18 logical indicator in \code{all_data}
#' @param n15_cname a character string specifying the name of the column
#' containing the N15 logical indicator in \code{all_data}
#'
#' @param iso_cols a character vector specifying columns indicating the presence
#' of isotopic peaks, e.g. a column "13C" with T/F specifying the presence of
#' 13C. Defaults to \code{c("13C", "18O", "15N", "34S")}.
#'
#' @return `CoreMSData` object, consisting of a list of two data frames
#'
#' @author Natalie Winans
Expand Down Expand Up @@ -93,7 +88,7 @@ as.CoreMSData <- function(all_data,

# check that all isotopic peaks are indicated by isotopic columns and correct if not
iso_mf_peaks <- monoiso_data %>%
dplyr::filter(stringr::str_detect(.data[[mf_cname]], "13C|18O|15N|34S"))
dplyr::filter(stringr::str_detect(.data[[mf_cname]], paste(iso_cols, collapse="|")))

if (nrow(iso_mf_peaks) > 0) {
iso_data <- rbind(iso_data, iso_mf_peaks)
Expand Down
14 changes: 3 additions & 11 deletions man/as.CoreMSData.Rd

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

2 changes: 1 addition & 1 deletion vignettes/read_CoreMS_data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dat %>%
The next step is to convert the `CoreMSrbind` object into a `CoreMSData` object using the function `as.CoreMSData`. The arguments for this function are the `data.frame` output by the function `read_CoreMS_data` and, optionally, the names of the columns corresponding to mass-to-error ratio (m/z), peak height, mass error, confidence score, molecular formula, and other peak metadata. The default values for these parameters are set to the column names in typical CoreMS output. The column names corresponding to isotope columns C13, S34, O18, and N15 should be included if and only if present in the dataset. In this case, we will include names for the C13 and O18 columns.

```{r}
cmsDat <- as.CoreMSData(dat, c13_cname = "13C", o18_cname = "18O")
cmsDat <- as.CoreMSData(dat)
```

The `CoreMSData` object consists of a list of two `data.frames`, `monoiso_data` and `iso_data`, containing the monoisotopic peaks and isotopic peaks, respectively. At this time, the isotopic peaks are not used for downstream analyses.
Expand Down

0 comments on commit 6513b46

Please sign in to comment.