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

Add some more Spectra methods #378

Merged
merged 5 commits into from
Nov 9, 2018
Merged

Add some more Spectra methods #378

merged 5 commits into from
Nov 9, 2018

Conversation

jorainer
Copy link
Collaborator

@jorainer jorainer commented Nov 7, 2018

Add filterMsLevel,Spectra, coerce,Spectra,list and coerce,Spectra,MSnExp (issue #370) and clean,Chromatograms (issue #354).

@jorainer jorainer requested review from lgatto and sgibb November 7, 2018 08:10
@jorainer jorainer mentioned this pull request Nov 7, 2018
Copy link
Collaborator

@sgibb sgibb left a comment

Choose a reason for hiding this comment

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

Great!

R/DataClasses.R Show resolved Hide resolved
@jorainer
Copy link
Collaborator Author

jorainer commented Nov 7, 2018

No change requests at all @sgibb ? for real?

fd <- AnnotatedDataFrame(as.data.frame(mcols(from)))
fromf <- as.character(unique(fromFile(from)))
process <- new("MSnProcess", files = fromf,
processing = paste("Data converted from Spectra:", date()))
Copy link
Collaborator

@sgibb sgibb Nov 7, 2018

Choose a reason for hiding this comment

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

No, IMHO its fine. There is only a small point with the processing message for the MSnExp. We have a logging function in R/utils.R where we use "[", date(), "]" instead of date():

MSnbase/R/utils.R

Lines 619 to 626 in 367b26f

logging <- function(object, msg, date. = TRUE) {
if (date.)
msg <- paste0(msg, " [", date(), "]")
object@processingData@processing <-
c(object@processingData@processing, msg)
if (validObject(object))
return(object)
}

But I have seen that we don't be consistent here:

MSnbase/R/readMSData.R

Lines 89 to 90 in 367b26f

process <- new("MSnProcess",
processing = paste("No data loaded:", date()))

processing = paste("Data loaded:", date()),

MSnbase/R/readMSnSet.R

Lines 23 to 24 in 70a9ec3

processing=paste("Quantitation data loaded:",date(),
" using readMSnSet."),

object@processingData@processing <- c(object@processingData@processing,
paste(n," (",m,
") precursors (spectra) extracted: ",
date(),sep=""))

object@processingData@processing <- c(object@processingData@processing,
paste("Curves <= ",
t
," set to '0': ",
date(),sep=""))

In fact we more often use the date() construct than "[", date(), "]" or logging:

$ grep -o "date()" *.R | wc -l
45
$ grep -o "logging(" *.R | wc -l
27

So I wasn't sure what to do and didn't mention it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wasn't even aware of the "[", date(), "]" - I used readMSData as template.

"collisionEnergy", "ionisationEnergy", "precursorScanNum",
"precursorMZ", "precursorCharge", "precursorIntensity",
"mergedScan", "centroided", "spectrum")
fdta <- fdta[, !colnames(fdta) %in% red_cn, drop = FALSE]
Copy link
Owner

Choose a reason for hiding this comment

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

Why aren't all feature variables passed along during coercion? I would prefer to keep all of them by default and have a selectFeatureData function to select those to keep.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guessed because they are part of a Spectrum object?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did not pass all feature variables to avoid redundancy. All these that are not passed along will be present (are set) in the individual Spectrum object - so no need to have them in addition as metadata columns.

Copy link
Owner

Choose a reason for hiding this comment

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

Indeed, thank you. Is there already an accessor for these (centroided,Spectra, ...)? The implementation will be identical to the corresponding in memory MSnExp methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, all methods to access slot values for Spectrum objects are also implemented for Spectra objects (in methods-Spectra.R), returning always a vector of length equal to Spectra with the corresponding slot values.

@lgatto lgatto merged commit c5c7a9c into master Nov 9, 2018
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.

3 participants