-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add write,MSnExp and write,OnDiskMSnExp #253
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a5e3351
Add write,MSnExp and write,OnDiskMSnExp
jorainer f2c745e
Address @sgibb's comments.
jorainer 5163c3d
Expand file path for write,MSnExp (issue #255)
jorainer 3f2db2b
Preserve precursor data in export (issue #256)
jorainer 800eea4
Address next round of comments from @sgibb
jorainer cf29499
Change write,MSnExp to writeMSData,MSnExp
jorainer d771f58
Merge branch 'master' into writeMSData
jorainer 226c9b7
Fix writeMSData for CDF input files
jorainer d228a76
Address comment from @sgibb
jorainer 7214c12
Merge branch 'master' into writeMSData
jorainer 12c056b
Update NEWS and NEWS.md
jorainer 68be4f6
fix missing quote in smooth man page
LaurentGatto 367bd03
Check existing file at beginning of .writeMSData
jorainer 434ac16
Add more information to details section of writeMSData,MSnExp
jorainer c043544
Add note explaining precursorScanNum being set to 0
jorainer 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 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
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
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#' @title Write MS data to mzML or mzXML files | ||
#' | ||
#' @aliases writeMSData | ||
#' | ||
#' @description The `writeMSData,MSnExp` and `writeMSData,OnDiskMSnExp` saves | ||
#' the content of a [MSnExp] or [OnDiskMSnExp] object to MS file(s) in | ||
#' either *mzML* or *mzXML* format. | ||
#' | ||
#' @details The `writeMSData` method uses the *proteowizard* libraries through | ||
#' the `mzR` package to save the MS data. The data can be written to | ||
#' *mzML* or *mzXML* files with or without copying additional metadata | ||
#' information from the original files from which the data was read by the | ||
#' [readMSData()] function. This can be set using the `copy` parameter. | ||
#' Note that `copy = TRUE` requires the original files to be available and | ||
#' is not supported for input files in other than mzML or mzXML format. | ||
#' | ||
#' @note General spectrum data such as total ion current, peak count, base peak | ||
#' m/z or base peak intensity are calculated from the actual spectrum data | ||
#' before writing the data to the files. | ||
#' | ||
#' For MSn data, if the `OnDiskMSnExp` or `MSnExp` does not contain also the | ||
#' precursor scan of a MS level > 1 spectrum `precursorMZ`, | ||
#' `precursorCharge` and `precursorIntensity` of the spectrum is set to 0 | ||
#' in the output file. | ||
#' | ||
#' @param object `OnDiskMSnExp` or `MSnExp` object. | ||
#' | ||
#' @param file `character` with the file name(s). Its length has to match the | ||
#' number of samples/files of `x`. | ||
#' | ||
#' @param outformat `character(1)` defining the format of the output files. | ||
#' Default output format is `"mzml"`. | ||
#' | ||
#' @param merge `logical(1)` whether the data should be saved into a single | ||
#' *mzML* file. Default is `merge = FALSE`, i.e. each sample is saved to | ||
#' a separate file. **Note**: `merge = TRUE` is not yet implemented. | ||
#' | ||
#' @param verbose `logical(1)` if progress messages should be displayed. | ||
#' | ||
#' @param copy `logical(1)` if metadata (data processings, original file names | ||
#' etc) should be copied from the original files. See details for more | ||
#' information. | ||
#' | ||
#' @param software_processing optionally provide specific data processing steps. | ||
#' See documentation of the `software_processing` parameter of | ||
#' [mzR::writeMSData()]. | ||
#' | ||
#' @author Johannes Rainer | ||
#' | ||
#' @md | ||
#' | ||
#' @rdname writeMSData | ||
setMethod("writeMSData", signature(object = "MSnExp", file = "character"), | ||
function(object, file, outformat = c("mzml", "mzxml"), | ||
merge = FALSE, verbose = isMSnbaseVerbose(), copy = FALSE, | ||
software_processing = NULL) { | ||
## Set copy to false if not all original files are available. | ||
if (copy & !all(file.exists(fileNames(object)))) { | ||
warning("Setting 'copy = FALSE' because the original files ", | ||
"can not be found.") | ||
copy <- FALSE | ||
} | ||
if (merge) { | ||
stop("Not yet implemented.") | ||
## Set copy to FALSE | ||
## Call .writeMSDataMerged | ||
} else { | ||
.writeMSData(object = object, file = file, | ||
outformat = outformat, verbose = verbose, | ||
copy = copy, software_processing) | ||
} | ||
}) | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be
isTRUE(MSnbaseOptions()$fastload)
sufficient here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also thought so. But I got very strange errors that took me one day to hunt down: seems that sometimes
MSnbaseOptions()$fastload
is simply not set andNULL
is returned. This was somehow related to parallel processing.Re:
camelCase
, I know, I'm inconsistent here. I used to use always only camelCase, but now I got used to snake case because I find it reads better - I can change back if you don't like.