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 support for OnDiskMSnExp in selectFeatureData #285

Merged
merged 5 commits into from
Dec 13, 2017
Merged

Add support for OnDiskMSnExp in selectFeatureData #285

merged 5 commits into from
Dec 13, 2017

Conversation

jorainer
Copy link
Collaborator

  • Add support for OnDiskMSnExp in selectFeatureData function (issue Required fvarLabels #283).
  • Add requiredFvarLabels function to return the minimal required columns in the
    featureData of an object.
  • Fix Spectrum1 and Spectrum2 constructor functions to accept also missing
    values for some columns/attributes.
  • Add related unit tests and documentation.

- Add support for OnDiskMSnExp in selectFeatureData function (issue #283).
- Add requiredFvarLabels function to return the minimal required columns in the
  featureData of an object.
- Fix Spectrum1 and Spectrum2 constructor functions to accept also missing
  values for some columns/attributes.
- Add related unit tests and documentation.
@jorainer jorainer requested a review from sgibb December 11, 2017 14:54
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.

I have just a few minor (code styling) comments. You could ignore them completely if you like.

## "retentionTime", "polarity", "msLevel",
## "totIonCurrent", "originalPeaksCount",
## "centroided")
reqCols <- .MSnExpReqFvarLabels
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor point: Do you really need the new variable reqCols here? Beside the following line it is never used. Why do you not use .MSnExpReqFvarLabels[!(.MSnExpReqFvarLabels %in% colnames(x))]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nope, don't need reqCols - will remove.

@@ -102,60 +103,63 @@ Spectra1_mz_sorted <- function(peaksCount = NULL, rt = numeric(),
if (length(mz) != length(intensity))
stop("Lengths of 'mz' and 'intensity' do not match!")
nvals <- length(nvalues)
empty_int <- rep(NA_integer_, nvals)
empty_num <- as.numeric(empty_int)
empty_log <- as.logical(empty_int)
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 we will lose the fight against snake_case 😉

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

😄 no way - snake_case rules. I'll actually replace em all with 🐫 since the rest of the function uses also only CamelCase.

if (length(rt) == 0){
rt <- rep(NA_integer_, nvals)
if (!length(rt)) {
rt <- empty_int
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are all this if(!length(...)) statements really necessary? I have no clue about the input values. Would it be possible to set the default argument of this constructor to e.g. rt=rep_len(NA_integer_, length(nvalues))?

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 know, it's ugly this way. The problem is that the upstream function uses e.g. fdata$polarity to pass the polarity column from the feature data to the function. If the featureData has been reduced and column "polarity" was removed, fdata$polarity is NULL and NULL is then passed with the polarity parameter.

R/utils.R Outdated
if (missing(fcol)) {
if (graphics) {
if (!requireNamespace("shiny"))
warning("The shiny package is required to use the graphical interface.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMHO this should be if (graphics && !requireNamespace("shiny")). Currently a warning is thrown if shiny is missing. Nevertheless the .selectShinyFeatureData is executed and will fail.

@lgatto MSnbase really suggests shiny just for fcol selection? MSnbase has already a lot of dependencies. Starting a browser and build a webpage for selecting some columns of a DataFrame is a little bit weird. I would suggest to remove this shiny part.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could move shiny from Suggests to Enhances and use your suggested requireNamespace. Most users will have shiny anyway installed.

Copy link
Owner

Choose a reason for hiding this comment

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

In some applications (mainly with MSnSet for spatial proteomics), large feature tables are really annoying, and a shiny app to easily select them is handy (we even have such a tab in our pRolocGUI apps).

@jotsetung - I don't think that Enhances is correct - it would imply that MSnbase enhances shiny (the meaning of Enhances has been confused and is confusing). Suggests is the right place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I'll put it back to Suggests.

R/utils.R Outdated
varl <- character()
if (x == "OnDiskMSnExp")
varl <- .MSnExpReqFvarLabels
varl
Copy link
Collaborator

Choose a reason for hiding this comment

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

varl needed? What about

if (match.arg(x) == "OnDiskMSnExp")
    .MSnExpReqFvarLabels
else
    character()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

@jorainer
Copy link
Collaborator Author

never ignoring any of your suggestions @sgibb ! thanks for reviewing.

Copy link
Owner

@lgatto lgatto left a comment

Choose a reason for hiding this comment

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

I have one suggestion, which is to move the code that was in functions-MSnSet.R, is now in utils.R into a new fdata-selection.R.

- Move feature data selection code to fdata-selection.R
- Move related unit tests to test_fdata-selection.R
@lgatto lgatto merged commit 1b55428 into master Dec 13, 2017
@lgatto
Copy link
Owner

lgatto commented Dec 13, 2017

@jotsetung - Checking locally when realising that I think you forgot to git add fdata-selection.R.

@jorainer
Copy link
Collaborator Author

Aaaah, sorry for that! I did push it now - too late

@jorainer jorainer mentioned this pull request Dec 13, 2017
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