Skip to content
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

Suggested updates and fixes for PlainTextParam #7

Merged
merged 7 commits into from
Jul 30, 2024
Merged

Suggested updates and fixes for PlainTextParam #7

merged 7 commits into from
Jul 30, 2024

Conversation

jorainer
Copy link
Member

Major changes in this PR:

  • use file names that (somewhat) resemble the exported data structure, i.e. ms_backend... for a MsBackendMzR backend, ms_experiment_sample_data.txt for the sampleData() of an MsExperiment etc. This should make it a bit clearer which files belong to each other.
  • spectraDataPath is now only a parameter for loadMsObject,MsBackendMzR - with the other objects just having ... in their definition. This parameter might not be needed for other backends, or they might need even different/more parameters. Using ... instead of a dedicated parameter gives us more flexibility in future.
  • some smaller refactoring and changes in the documentation

@jorainer jorainer requested a review from philouail July 29, 2024 09:17
R/Spectra.R Outdated Show resolved Hide resolved
R/Spectra.R Show resolved Hide resolved
@@ -37,24 +37,19 @@ setMethod("readMsObject",
#' @noRd
.store_xcmsexperiment <- function(x, path = tempdir()) {
.export_process_history(x, path = path)
if (xcms::hasChromPeaks(x))
.export_chrom_peaks(x, path)
## if (xcms::hasChromPeaks(x)) # maybe also export chromPeaks.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused aha. What do you mean maybe ? and the function after is not hashed ? We don't need to do that check ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true - I completely forgot that message. My thought was more what if an user exports an XcmsExperiment object without chrom peak results. It would maybe still be nice to be able to import such an "empty" object? so, chromPeaks()should return ALWAYS amatrix` with column names (but eventually no rows), so we could export/import that.

I would just like to avoid throwing an error if the XcmsExperiment is empty. I don't like errors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added now unit tests checking export/import of empty objects. and along that I had to fix the export of MsExperiment: if @sampleData is an empty data frame I'm replacing it with a zero-row data frame with one column (sample_name). Otherwise the read.table call will fail.

@@ -19,62 +19,73 @@ setMethod("saveMsObject",
recursive = TRUE,
showWarnings = FALSE)
## sample data
write.table(as.data.frame(object@sampleData), sep = "\t",
sdata <- object@sampleData
if (!length(sdata)) # initialize with empty data frame
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a workaround to ensure that a valid data frame is exported. If data.frame is completely empty, the content of the text file will be just "" and the read.table() call fails. With a single column, but no rows the data can be exported and imported.

@jorainer jorainer requested a review from philouail July 29, 2024 12:17
@jorainer
Copy link
Member Author

@philouail , I've addressed some of your comments and also added support for empty object export/import (and added unit tests for that).

Copy link
Collaborator

@philouail philouail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good for me just one comment

@@ -17,8 +17,10 @@ importFrom(jsonlite,write_json)
importFrom(methods,as)
importFrom(methods,callNextMethod)
importFrom(methods,existsMethod)
importFrom(methods,getFunction)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be removed ?

@jorainer jorainer merged commit a9f393a into phili Jul 30, 2024
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants