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

LamaParama implementation for AdjustRtime(): correcting alignment based on external dataset. #732

Merged
merged 20 commits into from
Mar 21, 2024

Conversation

philouail
Copy link
Collaborator

Here I propose the implementation of a new parameter for AdjustRtime() called LamaParama which compute adjustment of retention file by file based on landmarks features (lamas) of an external dataset.

I also implemented some diagnostic function matchLamaChromPeaks(), summarizeLamaMatch to evaluate matching of
chromatographic peaks against lamas before adjustment.

Of note, I also wrote a new interpolation function .force_sorted() which could be reused in other cases and might be moved to another package.

I also wrote an example in the vignette describing everything.

Welcoming any feedback. I'm also not sure that the functions/documentations are in the right files, would appreciate input for that. For example the diagnostic functions should probably have their own documentation ? I'm not completely sure.

@philouail philouail requested a review from jorainer March 14, 2024 13:46
@philouail philouail marked this pull request as draft March 14, 2024 13:46
Copy link
Collaborator

@jorainer jorainer left a comment

Choose a reason for hiding this comment

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

Looks great Phili! I have some general suggestions on restructuring the documentation - having all documentation related to the LaMa method in one place. The code and the vignette looks however great.

R/AllGenerics.R Outdated Show resolved Hide resolved
R/DataClasses.R Outdated Show resolved Hide resolved
R/AllGenerics.R Outdated Show resolved Hide resolved
R/do_adjustRtime-functions.R Outdated Show resolved Hide resolved
R/XcmsExperiment.R Outdated Show resolved Hide resolved
R/do_adjustRtime-functions.R Outdated Show resolved Hide resolved
R/functions-Params.R Outdated Show resolved Hide resolved
vignettes/xcms.Rmd Show resolved Hide resolved
vignettes/xcms.Rmd Outdated Show resolved Hide resolved
vignettes/xcms.Rmd Outdated Show resolved Hide resolved
Copy link
Collaborator

@jorainer jorainer left a comment

Choose a reason for hiding this comment

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

Really great Phili! only very little minor comments. After fixing that please convert to a PR and re-request review, and also review from Steffen.

R/XcmsExperiment.R Outdated Show resolved Hide resolved
R/do_adjustRtime-functions.R Outdated Show resolved Hide resolved
R/do_adjustRtime-functions.R Outdated Show resolved Hide resolved
R/do_adjustRtime-functions.R Outdated Show resolved Hide resolved
R/do_adjustRtime-functions.R Outdated Show resolved Hide resolved
R/do_adjustRtime-functions.R Outdated Show resolved Hide resolved
philouail and others added 3 commits March 19, 2024 16:38
commit c37baa7
Author: jorainer <johannes.rainer@gmail.com>
Date:   Mon Mar 18 07:59:02 2024 +0100

    fix: update required Spectra version

commit 2faed90
Author: jorainer <johannes.rainer@gmail.com>
Date:   Fri Mar 15 14:58:39 2024 +0100

    fix: require ProtGenerics 1.35.4

commit 086999d
Author: jorainer <johannes.rainer@gmail.com>
Date:   Thu Mar 14 14:46:02 2024 +0100

    refactor: cleanup NAMESPACE and dependencies and documentation

    - Re-save data object.
    - Fix documentation and unit tests following the move of `MSnbase` from Depends
      to Imports.

commit 97d7d4c
Author: jorainer <johannes.rainer@gmail.com>
Date:   Thu Mar 14 13:54:53 2024 +0100

    docs: replace inst/NEWS with NEWS.md

commit a455e6b
Author: jorainer <johannes.rainer@gmail.com>
Date:   Wed Mar 13 09:54:18 2024 +0100

    refactor: clean up namespace

    - Remove not required packages.
    - Move packages from Depends to Imports.

commit 28e4ca7
Merge: 19b1b9a 90c30b8
Author: jorainer <johannes.rainer@gmail.com>
Date:   Fri Mar 8 16:09:04 2024 +0100

    Merge branch 'devel' into jomain

commit 19b1b9a
Author: jorainer <johannes.rainer@gmail.com>
Date:   Tue Feb 27 11:04:15 2024 +0100

    refactor: ensure backward compatibility of parameter objects

commit 40c09c0
Merge: 17b487f 48ac5e0
Author: jorainer <johannes.rainer@gmail.com>
Date:   Tue Feb 27 11:01:02 2024 +0100

    Merge branch 'devel' into jomain

commit 17b487f
Merge: c36018b 1cf7cda
Author: jorainer <johannes.rainer@gmail.com>
Date:   Mon Feb 5 14:49:22 2024 +0100

    Merge branch 'devel' into jomain

commit c36018b
Author: jorainer <johannes.rainer@gmail.com>
Date:   Thu Feb 1 15:43:19 2024 +0100

    fix: call updateObject for some Param classes in as.list
@philouail philouail marked this pull request as ready for review March 19, 2024 15:48
@philouail philouail requested a review from sneumann March 19, 2024 15:48
Copy link
Collaborator

@jorainer jorainer left a comment

Choose a reason for hiding this comment

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

Thanks Phili for this great contribution!

I have only one very minor comment in the vignette.

vignettes/xcms.Rmd Show resolved Hide resolved
R/do_adjustRtime-functions.R Outdated Show resolved Hide resolved
@@ -79,7 +79,8 @@ Suggests:
RANN,
multtest,
MsBackendMgf,
signal
signal,
mgcv
Copy link
Owner

Choose a reason for hiding this comment

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

Hi, I see a new package dependency here. Where is it used ?

I see an explicit library(mgcv) in test_do_adjustRtime-functions.R,
but I suspect it us used somewhere in xcms/R/*.R as well.

I'd love to be able to handle DESCRIPTION and NAMESPACE through roxygen2 one day, and for that we'd need to start annotations
like #' @importFrom MsCoreUtils ndotproduct
Does that make sense for

LamaParama <- function(lamas = matrix(ncol = 2, nrow = 0,
?

Or is the package really only needed in the test_do_adjustRtime-functions.R ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So in do_adjustRtime-functions.R you will see there is helper function a function called .check_gam_library which will check if mgcv is installed and that is only necessary if the user decide to run a gam model (e.g. method = "gam", default being method = "loess").
The function mgcv:::gam() in this package is then used in the .rt_model() helper function (again only if the user specifically ask for it).
This was a suggestion from @jorainer, if i understood well that allows for the package to only be in suggested and therefore for xcms to not be fully dependent on it, which would not be ideal as only this implementation uses it. Please correct if i'm wrong as I am not 100% confident about that.
I do agree that it would be great if xcms namespace could be regulated by roxygen2, for the other implementations I've done I added these @importFrom mentions (e.g. filterFeatures.R).

Hope that was clear :)

ps: However leaving the library(mgcv) in test_do_adjustedRtime-function.R was a mistake on my part, I forgot to remove it from when I was making the test. I will remove that in the next push !

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also chiming in here - I absolutely want to avoid any additional (potentially unnecessary) dependency. We can have the mgcv either in Suggests or Enhances since we're not importing any functionality. We're loading the namespace specifically in the function, and only if that method is used. If the package is not installed an error is thrown that, to use the functionality, the mgcv package needs to be installed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, maybe it's good (also good practice in general) to already add the @importFrom roxygen directives into the documentation. @philouail , can you please add them to your new functions?

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 think it should be good now, just had to move one package around to make it more clear + added the now published force_sorted(), function from MsCoreUtils.

@sneumann
Copy link
Owner

Excellent, so let's merge now and watch the build reports. Yours, Steffen

@sneumann sneumann merged commit d6cc33d into devel Mar 21, 2024
0 of 3 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.

3 participants