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

Erase split ends that lead to different peaks #27

Closed
jenny-mrchl opened this issue Aug 1, 2023 · 16 comments
Closed

Erase split ends that lead to different peaks #27

jenny-mrchl opened this issue Aug 1, 2023 · 16 comments

Comments

@jenny-mrchl
Copy link

jenny-mrchl commented Aug 1, 2023

Hi again! 👋🏼

I have some chromatograms that have a very tiny split at the tip of a peak and when I want to get the peak table they are counted as two peaks while it is obviously the same peak (see some pics I put).

Do you know how to resolve this issue ? That would help me a lot!!
Capture d’écran 2023-08-01 à 15 49 06

Capture d’écran 2023-08-01 à 15 49 23

Thank you very very much in advance,
Have a great day. ☺️

Jenny

@ethanbass
Copy link
Owner

ethanbass commented Aug 1, 2023

Hi Jenny,
I suspect you can probably solve this this issue by changing the smooth_window argument. The default is .001 -- you could try turning it down to .005 or .01 and see if it helps. You can consult the help page for find_peaks if you want more details about the parameters for peak finding.
Ethan

@jenny-mrchl
Copy link
Author

Hi Ethan,

Thank you very much for your reply.

I tried the find_peaks functions, but it is not very convenient in my pipeline because I have to treat chromatograms one by one with this function and I would prefer something that smooth all the chromatograms at the same time.
But great indication on the find_peaks page : I tried to reduce the resolution along the time axis and it is working wonderfully! Thanks again for your help!

Have a great day,

Jenny

@ethanbass
Copy link
Owner

Glad to hear you got it working! FIY, when you run get_peaks, it is already running find_peaks under the hood and you can pass through arguments from get_peaks to find_peaks. So you can do get_peaks(..., smooth_window=.01). Sorry if my earlier answer was hard to follow. I will try to edit the documentation for get_peaks to make this clearer.

Ethan

@ethanbass
Copy link
Owner

Hi Jenny,
I'm going to close this issue. Feel free to reopen if you run into any further problems with this!

@jenny-mrchl
Copy link
Author

Hi Ethan,

Sorry for my late reply, it was a wetlab week!
Back to the analysis of my chromatograms, I tried to adjust the smooth_window parameter in the get_peaks function and it is working perfectly! All my split ends are gone!
Indeed, you could perhaps highlight how to get rid of this problem in the get_peaks documentation but atherwise everything is pretty clear and working smoothly :)
Thank you very much for your help,

I wish you a very nice weekend,
Best,

Jenny

@ethanbass
Copy link
Owner

great, glad to hear it's working for you! I will try to add a little passage about this to the get_peaks documentation as you suggest!

@ethanbass
Copy link
Owner

I added a few more details about these additional arguments to the docs for get_peaks (c6e96a2). Please let me know if you have any additional suggestions.
Ethan

@jenny-mrchl
Copy link
Author

jenny-mrchl commented Nov 24, 2023

Hi Ethan,

I have another kind of problem with split ends... For example I have this peak (see pictures below) that is read as two peaks but I would like it to be read as one. So I am adjusting the smooth window parameter (which is by the way better explained thanks to the comment you added on the get_peaks function) to be able to join the peaks. Even if I do a slight adjustment from 0.001 to 0.002, it gives back an error message and no peak is detected at all.
Do you know how I can fix that?

Thank you very much in advance,
Best,
Capture d’écran 2023-11-23 à 22 32 19
Capture d’écran 2023-11-23 à 22 32 36

Jenny

@ethanbass
Copy link
Owner

ethanbass commented Nov 24, 2023

Hi Jenny,
I think with such a big valley, the integration results wouldn't be very good even if you were able to adjusted the smooth window so that this would be coded as a single peak. I think a better approach might be to sum these two peaks together after they're assembled in the peak table. Perhaps I could add an extra parameter to the merge_peaks function (https://ethanbass.github.io/chromatographR/reference/merge_peaks.html) to facilitate this? Currently it merges two peaks by taking the maximum value from each row, but it wouldn't be hard to add an option where they are summed together instead. Do you think that would work for you?

@jenny-mrchl
Copy link
Author

Hi Ethan,

Thanks for your answer! I summed the area as you recommended and it is working :)

Now I have another issue. I am running functions in this order : preprocess(), get_peaks(fit="egh"), filter_peaks(). And then I print the filter_peaks() result to see how many peaks and which I have on the chromatographs. For a set of chromatographs on the chemical Orotic Acid, the code detects peaks on each chromatograph except, the n°3. You can see picture of number 2, 3 & my code. In the filter_peaks function changed the rt window, used other parameter to detect the peaks of n°3. I tried to change the smooth window parameter but still no detection. Do you have any suggestion on what I can do?

Capture d’écran 2023-11-25 à 18 17 44 Capture d’écran 2023-11-25 à 18 18 09 Capture d’écran 2023-11-25 à 18 18 39

Thanks again!!
Have a nice day,

Jenny

@ethanbass
Copy link
Owner

Hmm, I'm not really sure. It would be a little easier to troubleshoot if you could share the file containing the problematic chromatogram. I would check if the peak shows up in the raw peaklist (before you run filter_peaks) to narrow down if the issue is in the peak finding routine or if you are filtering it out when you run filter_peaks.

@jenny-mrchl
Copy link
Author

Hi Ethan,

Sorry for my late reply, it is my part time job so I am not working on this all the time.
Thanks for your message,
Here are the problematic .csv file (OroticAcid-C3) and a good one (OroticAcid-C2).
I don't how how to give you .arw file. Do you have an email address? :))

Again thank you very very much for your help!

Jenny
s02-r1-OroticAcid-C2_254.csv
s02-r1-OroticAcid-C3_254.csv

@ethanbass
Copy link
Owner

Sure, you could email it to me at ethanbass@gmail.com Also if you change the extension of the arw file to .txt you could post it here directly

@ethanbass
Copy link
Owner

ethanbass commented Dec 5, 2023

Hi Jenny,
It looks like your peak is getting filtered out by the width filter in get_peaks. Try increasing sd.max to 100. The default is 50.

@jenny-mrchl
Copy link
Author

Hi Ethan! Thanks for your answer!

Happy New Year by the way :)

So I still have peaks that are not detected and I get this error message : "Warning: no non-missing arguments to max; returning -Inf" do you know what I can do ?

Thank yooouuuuuu

@ethanbass
Copy link
Owner

Hi Jenny,
I'm not really sure what the problem might be without a little more information. Is this in reference to the same set of chromatograms as before? If the peaks are really misshapen, it could be that the algorithm can't fit an exponential gaussian hybrid to the peak shape. Or if the peaks are really wide it could still be that the standard error (width) cutoff is set too low

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

No branches or pull requests

2 participants