Skip to content

MapAlignerIdentification without Reference yields weird transformation #2541

Closed

Description

@cbielow

If I run MapAlignerIdentification (default settings usingb spline, no reference set (0)) on a set of 5 files, I get trafo outputs like this (note this is a SINGLE trafo -- they all look similar):
rplot_noref

However, if I set a reference index (1), then the trafo looks much nicer:
rplot_withref

[wild guessing -- have not deeply looked into the code]
The heuristic which computes the reference map uses the median RT for each peptide idependently (if I get the code right). Hence, for each peptide sequence, the reference file is chosen anew. This is seemingly very unstable, and leads to reference which is a mixture of all input files, hence the trafo looks funny as well.

There is a few ways to fix this I guess:

  • just pick the reference with the most IDs (crude, and might have the most distorted RT profile, so not the best way, but easy)
  • pick the medians, but remember from which file they came from. Pick the file whose peptides most often represented the median (this will be the file with the 'average' RT behaviour -- extreme cases notwithstanding).
# dirty R code for the plots above:
data <- xmlParse("file3.trafoXML")
d = xmlToList(data)
un = unlist(d[["Transformation"]][["Pairs"]])
l = length(un)
plot(un[seq(1,l-1,by=2)], un[seq(2,l,by=2)], xlab="RT 1", ylab="RT 2")

Activity

  1. hendrikweisser commented on Apr 21, 2017

    @hendrikweisser
    Contributor

    If I run MapAlignerIdentification (default settings usingb spline, no reference set (0)) on a set of 5 files, I get trafo outputs like this (note this is a SINGLE trafo -- they all look similar):

    Those are the data before the smoothing is applied. Can you generate and share the plots after smoothing for both cases (with and without reference)? Just run the MapAligner again on the aligned data.

  2. cbielow commented on Apr 21, 2017

    @cbielow
    ContributorAuthor

    You mean that after smoothing, the b-spline will somehow find its way and these ghost traces do not matter, i.e. the result is stable? But is this indented behaviour? What if I use "interpolated" ?

  3. hendrikweisser commented on Apr 21, 2017

    @hendrikweisser
    Contributor

    You mean that after smoothing, the b-spline will somehow find its way and these ghost traces do not matter, i.e. the result is stable?

    I would hope so, but we should check to what extent that's true - by looking at the transformation after aligning.

    But is this indented behaviour? What if I use "interpolated" ?

    Not intended, but I haven't seen this before, so it may be an unusual case.
    It doesn't make sense to use the "interpolated" model with this algorithm.

  4. cbielow commented on Apr 24, 2017

    @cbielow
    ContributorAuthor

    I ran MA on the corrected results. The plot shows the first and second iteration for "auto-reference" vs. manual reference (file 1).

    rplot_comparealign

    With manual reference the alignment looks much cleaner.
    To put this in numbers, I computed the standard deviation of RT1-RT2 for the second iteration (averaged across all files)

    2 _withRef_2nd  202.0913
    4    noRef_2nd  315.2287
    
  5. cbielow commented on Apr 24, 2017

    @cbielow
    ContributorAuthor

    dirty R code (so I dont misplace it)

    dirs = grep("mapalignment.*", list.dirs("C:/TEMP/teaching/PTXQC data/Openms_processed_data/"), v= T)
    
    require(ggplot2)
    require(XML)
    require(plyr)
    
    d = dirs[1]
    df.all = NULL;
    for (d in dirs)
    {
      files = list.files(d, pattern = ".trafoXML", full.names = TRUE)
      f = files[1]
      for (f in files)
      {
        data <- xmlParse(f)
        dlist = xmlToList(data)
        un = unlist(dlist[["Transformation"]][["Pairs"]])
        if (is.null(un)) next;
        un = as.numeric(as.character(un))
        l = length(un)
        df = data.frame(type = d, f = basename(f), r1 = un[seq(1,l-1,by=2)], r2 = un[seq(2,l,by=2)])
        df.all = rbind(df.all, df)
      }
      
    }
    
    df.all$type2 = gsub(".*mapalignment.(.*)", "\\1", df.all$type)
    
    ggplot(df.all) + geom_point(aes(r1,r2)) + facet_grid(type2 ~ f)
    ddply(df.all, c("type2", "f"), function(x) sd(x$r1 - x$r2))
    ddply(df.all, c("type2"), function(x) sd(x$r1 - x$r2))
    
    
  6. hendrikweisser commented on Apr 24, 2017

    @hendrikweisser
    Contributor

    Thanks for getting the data, Chris.

    Some thoughts:

    • The transformations in the last row of your plot look decent enough to me, so I would say the "yields very bad transformation" in the title is a bit harsh.
    • Regarding the standard deviations: How many more data points do you have in the "no ref." case? That probably contributes to the difference.
    • If you don't mind doing a bit more testing: What happens if you increase the value for the "algorithm:min_run_occur" parameter (e.g. to the total number of runs)?
    • I agree that it would be good to have an option to automatically select "the best" reference to align to.
    • However, I still think it would be good to also have an option without a (single) reference run. (Because a: you bias your results towards that run, and b: if the overlaps in IDs between runs are small and vary, there may not be a single suitable reference.) Any ideas how the "reference-free" option could be improved? (Maybe by using a different metric than the median?)
  7. hendrikweisser commented on Apr 24, 2017

    @hendrikweisser
    Contributor

    Oh, another thing:

    • Could you perform an alignment of corresponding runs after the reference-based and reference-free alignment, and plot those transformations? That should show how different the results actually are between the two approaches.
  8. changed the title [-]MapAlignerIdentification without Reference yields very bad transformation[/-] [+]MapAlignerIdentification without Reference yields weird transformation[/+] on Apr 24, 2017
  9. cbielow commented on Apr 24, 2017

    @cbielow
    ContributorAuthor

    The transformations in the last row of your plot look decent enough to me, so I would say the "yields very bad transformation" in the title is a bit harsh.

    changed it.

    Regarding the standard deviations: How many more data points do you have in the "no ref." case? That probably contributes to the difference.

    50k vs 80k -- so 'n' is large here, i.e. it should not make any difference.
    If I only use 50k (randomly sampled) for both,

    2 _withRef_2nd  201.3117 50704
    4    noRef_2nd  316.4450 86164
    

    If you don't mind doing a bit more testing: What happens if you increase the value for the "algorithm:min_run_occur" parameter (e.g. to the total number of runs)?

    full schedule at the moment. maybe by the end of the week. Would the idxmls help you? Uploading is fast.

    I agree that it would be good to have an option to automatically select "the best" reference to align to.
    However, I still think it would be good to also have an option without a (single) reference run. (Because a: you bias your results towards that run, and b: if the overlaps in IDs between runs are small and vary, there may not be a single suitable reference.) Any ideas how the "reference-free" option could be improved? (Maybe by using a different metric than the median?)

    If the overlap in ID's is small, there is a general problem anyway, right? either a run is bad anyway (and id the IDs are bad, the quant is probably not better) or we're aligning mice + men -- not too sensible either.
    MaxQuant does it tree-like. The advantage is that very distant samples will get aligned last, when the maximum information is available from the sub-trees. The tricky part is to get the guide tree right (its O(n^2) to compute that, so the metric better be good. SD of rt1-rt2 of the intersecting IDs might be a good start. Thats not too hard to compute. Concerning reference free: you could quickly train an RT model based on the data :)

  10. hendrikweisser commented on Apr 24, 2017

    @hendrikweisser
    Contributor

    50k vs 80k -- so 'n' is large here, i.e. it should not make any difference.

    But you're comparing apples and oranges - the (RTs of) IDs that are in common between two runs, and the (RTs of) IDs that one run has in common with any other. Of course the deviations will be greater in the latter case.

    full schedule at the moment. maybe by the end of the week. Would the idxmls help you? Uploading is fast.

    Full schedule here as well. ;-)

    If the overlap in ID's is small, there is a general problem anyway, right?

    In practice that may be correct in most cases, but it's not necessarily true. There's generally not much point in re-sequencing the same peptides again and again, so it would make sense to reduce the overlap (e.g. using inclusion/exclusion lists).

    MaxQuant does it tree-like. The advantage is that very distant samples will get aligned last, when the maximum information is available from the sub-trees. The tricky part is to get the guide tree right (its O(n^2) to compute that, so the metric better be good. SD of rt1-rt2 of the intersecting IDs might be a good start. Thats not too hard to compute.

    That's a good idea. Comparing IDs and their RTs is fast, and the overlaps/deviations should be give you a good metric for the tree. Since you keep accumulating IDs into the reference, you avoid one of the problems that I had with selecting a single reference run. (I think that's basically what you said already.)
    Somebody should implement this. ;-)

  11. cbielow commented on Apr 24, 2017

    @cbielow
    ContributorAuthor

    But you're comparing apples and oranges - the (RTs of) IDs that are in common between two runs, and the (RTs of) IDs that one run has in common with any other. Of course the deviations will be greater in the latter case.

    I see your point, but:

    • that's the way you compute the 'reference' -- nothing I can do about it
    • you're saying that only FeatureLinking will tell who's better? But then again, alignment should be transitive, right? I.e. if A aligns well to B, and A well to C, then B and C should align somewhat(!) nice as well, right? so I guess, reference will win FeatureLinking here against reference-free. And the RT-coverage in this data is very good, so its not a problem of sparseness.
  12. hendrikweisser commented on Apr 24, 2017

    @hendrikweisser
    Contributor

    you're saying that only FeatureLinking will tell who's better? But then again, alignment should be transitive, right? I.e. if A aligns well to B, and A well to C, then B and C should align somewhat(!) nice as well, right? so I guess, reference will win FeatureLinking here against reference-free. And the RT-coverage in this data is very good, so its not a problem of sparseness.

    No, I wasn't saying that. (I wasn't thinking about feature linking at all.)
    I'm not even saying that the reference-free approach is better on your data. I'm just not sure how much worse it is. And I'm not sure if it will be worse in most cases. (If you align B and C to A and then compare the alignment of B and C, will that be better than the reference-free alignment?)

    Could you perform an alignment of corresponding runs after the reference-based and reference-free alignment, and plot those transformations? That should show how different the results actually are between the two approaches.

    We should really do that before we keep speculating more.

  13. hroest commented on Apr 26, 2017

    @hroest
    Contributor

    just as a comment here: In the TRIC algorithm, I also do the alignment tree-like and it is generally not a big problem to compute the tree even though it is O(N^2) if the actual operation you are performing is fast. In my case I basically calculate a distance matrix that is simply 1-R^2 for all intersecting ids, calculating that is pretty fast and allows for linear shifts but punishes runs that are highly nonlinear. Just a thought.

    PS: SD of rt1-rt2 may not be optimal as you often do see quite strong linear shifts that result from different start time of acquisition but would result in a large SD

  14. added
    major
    on Apr 28, 2017
  15. timosachsenberg commented on May 29, 2017

    @timosachsenberg
    Contributor

    still a major defect? sounds more like an enhancement?

  16. hroest commented on Jun 27, 2017

    @hroest
    Contributor

    not sure @cbielow does it look better now? did you try using the lowess transform instead of the spline?

  17. timosachsenberg commented on Jul 9, 2018

    @timosachsenberg
    Contributor

    @jpfeuffer might also be relevant to you

  18. timosachsenberg commented on Sep 28, 2026

    @timosachsenberg
    Contributor

    Still relevant as of today's nightly (pyOpenMS 3.6.0.dev20260928): the reference-free path of MapAlignmentAlgorithmIdentification hasn't changed since this issue was opened. Every peptide's target RT is the median of its per-run median RTs, so which run supplies the target changes from peptide to peptide, and the run being aligned is one of the candidates. That produces the parallel traces in the first plot above and leaves part of each run's shift uncorrected. ProteomicsLFQ (default alignment_order=star) and MS1LabeledWorkflow use this path, although their docs say they align to the run with the most IDs.

    Reproduced on simulated runs (known smooth RT distortions, DDA-like partial ID overlap, 8 s RT noise, default b_spline model):

    Trafo data points with and without a reference

    Measured on the same peptide pairs for every mode (the open question from the discussion above), one reference-free pass leaves roughly a tenth of the original offset between runs. Aligning to one run, or restricting the consensus to peptides seen in every run, gets down to the noise floor:

    5 runs, shifts ±180 s Spread left between runs Median difference on shared peptides
    Before alignment 354 s 170 s
    No reference (current default) 35 s 20 s
    No reference, run twice 4.6 s 7.0 s
    No reference, min_run_occur = 5 2.0 s 6.7 s
    Reference = run with most IDs 1.8 s 6.7 s

    (~6.7 s is the floor set by the simulated noise; ±60 s shifts and 10 runs behave the same way.)

    Proposed fix in #10316: without a reference, the input that shares the most identified sequences with every other input becomes the reference (on ties, the one with the most identified sequences). That is the single reference run the ProteomicsLFQ and MS1LabeledWorkflow docs already describe, and every other input can be aligned to it. If no input shares at least two sequences with every other input, the consensus is used as before. The old behaviour stays available as algorithm:auto_reference consensus. The same simulation through the patched MapAlignerIdentification:

    Old vs new default

    Effect on existing tests: MS1LabeledWorkflow outputs don't change. The two reference-free MapAlignerIdentification tests now set auto_reference consensus and still produce their old outputs; a new test covers the default. ProteomicsLFQ reference outputs change only in aligned retention times, the linker's quality values and, in the untargeted tests, the grouping of unidentified features (more of them linked across all runs). Feature, peptide and protein quantities are identical.

    MapAlignerTreeGuided (since 2.5) already avoids the problem by construction, and remains the better choice when no single run overlaps well with all the others.

    Simulation and plotting scripts: openms-test-lab/investigations/issue-2541

    Edited after review on the PR: the reference is now the input that shares the most sequences with every other input, instead of the input with the most IDs, which could share too few with some inputs. The figure and scripts are updated.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectenhancementmajor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions