Skip to content

Issue with the .plotChromPeakDensity function? #812

@melpetera

Description

@melpetera

Hi,

I have noticed strange results in the past about plots obtained for groupChromPeaks regarding the maxFeatures and minFraction parameters of the PeakDensity method. As somebody reached to me to ask a question about that yesterday, I decided to properly check that and I may have spotted the issue.

The initial problem

Changing the maxFeatures parameter values does not affect the plot obtained with the plotChromPeakDensity function: always the same number of "grey rectangles". For example: 15 grey rectangles plotted on a given slice eventhough maxFeatures is set to 10.

Other issue observed: the minFraction also behave strangely on the grey rectangles -> some are plotted when the number of "points" concerned by the density peak is higher than the number of samples corresponding to the threshold implied by the minFraction parameter, although the concerned number of samples actually do not reach the threshold (as some samples have several "points"). Example: {4 samples analysed, minFraction of 0.4} -> a grey rectangle is plotted for density peaks composed of 3 points from one single sample (with no points on any of the other 3 samples).

The function used to obtain the plots

Here this issue has been observed specifically when using the plotChromPeakDensity function. To note, the tables obtained with the groupChromPeaks function are consistant with the changes of maxFeatures and minFraction values, so it is only a plot issue.

My investigation trying to understand why this occurs

I first looked at how the groupChromPeak function was plotting these grey rectangles. Arriving at the .group_peaks_density function, everything seems all right: the while loop is properly handling the two parameters for the table processing, and the plot code only highlights the areas that have been retained through the while loop. So by using the groupChromPeak function to get the plots, it should be ok.

So then I looked at the plotChromPeakDensity function (that was actually used when facing the issue), and arrived at the .plotChromPeakDensity function. As far as I understand, the "simulate" parameter is meant to enable to get plots that are consistant with the groupChromPeaks parameter one would use, by only plotting grey squares for peak groups retained by the conditions implied by the parameter choice. For that, the code is inspired by the .group_peaks_density code, in particular we find the while loop with the maxFeatures and minFraction parameters being taken into account. As the objects were not exactly the same, some adaptations have been made, and I would guess this is at that moment that the issue was introduced.

To what I see, I would say the following:

  • Concerning the maxFeatures parameter, snum is defined before the while loop to count the number of features included, but the increment has not been added in the loop.
  • Concerning the minFraction parameter, when comparing the testing instruction to the one from the original .group_peaks_density function, I see that the use of unique() to restrict the count to samples and not to all points has been removed.

These two observations would explain why the issue occurs. To note, I have not tested the minSamples parameter but I would guess the same issue as the one observed with minFraction should be observed, based on the things spotted in the code.

To sum up

Currently the plotChromPeakDensity function does not take into account the maxFeatures, minFraction (and potentially minSamples) parameters properly, with the issue being potentially in the underlying .plotChromPeakDensity function, with adjutments to do in the while loop inside the if (simulate) { [...] } brackets.

Potential fixes:

  • adding a snum <- snum + 1 equivalent in the while loop
  • adding a unique() when getting the sample groups to create the tt object

This is as far as I could reasonably investigate. Any idea?

Best regards,
Mélanie

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions