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

NaN values for (alpha) chain recombination probabilities! #28

Open
JonasMir opened this issue Sep 5, 2018 · 4 comments
Open

NaN values for (alpha) chain recombination probabilities! #28

JonasMir opened this issue Sep 5, 2018 · 4 comments
Labels

Comments

@JonasMir
Copy link

JonasMir commented Sep 5, 2018

Hi Quentin,

I noticed that for calculating alpha chain probabilities I have the problem of almost always getting nan-values in the output. I looked at the sequences but I do not see a pattern. At the same time nan-values are an exception for my beta-chains.
Do you have an idea about what is going wrong there?

Best,
Jonas

@qmarcou
Copy link
Owner

qmarcou commented Sep 6, 2018

Hi Jonas,
Thanks for posting your question here.

For your alpha chains: in general the most problematic step is to get correct gene alignments in the pre processing step, after that the inference/evaluation is pretty smooth. What I would encourage you to do is :

  • go in your evaluate or inference folder and look at the inference_logs.txt file. This file will tell you how many V or J gene goes into the inference : if any of these two values is 0 then it is impossible for the inference to attach a complete scenario to the sequence. In that case you should revise your alignments thresholds and/or offsets. Please note that there is now a dedicated command line to load template specific offsets in order to make best use of the sequencing information. Similarly there is a dedicated command if your input is made of nucleotide CDR3 sequences.

  • if the latter do not provide more information the alignments might still be the problem. One thing you can do is lower the probability threshold for the inference to allow for scenarios with very low probability. Maybe some of the sequences that were tagged as NaN before will get a probability assigned this time. If this is the acse look at the inference_logs.txt file and look at the average (over scenarios) number of errors for this sequence. If the number is much larger that what you would expect from your sequencing process you should adjust your alignment threshold.

As I mentioned the best results are obtained by constraining the offsets as much as you can provided the sequencing mechanism (having a primer in the V makes you sure of the V offset for instance, as for CDR3s the gene anchors position automatically gives you an offset) and incorrect parameters there may bias your results. I know setting them correctly may seem tedious, but I know by experience that making blind alignments does not work well especially on short sequences (such as CDR3s)

@JonasMir
Copy link
Author

JonasMir commented Sep 6, 2018

Hi Quentin,

thanks for your detailed answer! Indeed the inference_logs.txt file showed the problem having zeroes. In my case already resetting the threshold for the alignment solved the problem.

Cheers,
Jonas

@spritelysauropods
Copy link

Hello, I am adding to this question because I think the problems I am encountering are related, but I am not sure what additional steps to try to resolve nan generation probability for ~10% of mouse CDR3beta sequences (60 bp-long reads) using the built-in models.

For a handful of sequences in the Pgen_counts.csv that had nan for Pgen_estimate, I tried the following:

  • Looked at inference_logs.txt. The nan-Pgen_stimate sequences have 0 for seq_likelihood, seq_mean_n_errors, and seq_n_scenarios. But there is at least 1 n_V_aligns and n_J_aligns, so I am not sure if it was the alignment that is causing the problem. The IGoR alignments in the aligns folder also broadly match provided V and J identities.

  • set P_ratio_thresh to 0 to explore every recombination scenario by the following command: igor -set_wd $wdpath -batch mouse1 -species mouse -chain beta -evaluate --P_ratio_thresh 0.0 -output --Pgen. This lead to nan for every sequence, and I just saw this referenced in General guidelines for Pgen #4 (comment). (I will also try with very small but non-zero P_ratio_thresh.

I have not tried using the --ntCDR3 flag in the alignment step because it seems like the alignment step is successful. Should I try using the --ntCDR3 flag? We have indices of V and J positions in the read but it may just take me some thinking to match that to offsets.

Thank you!
I've attached a extract of the inference_logs.txt for 4 sequences that had nan Pgen_estimate with the default P_ratio_thresh and with P_ratio_thresh set to 0.0.
inference_logs_example.txt

@qmarcou
Copy link
Owner

qmarcou commented Sep 13, 2019

Dear @spritelysauropods ,
Apologies for the late reply. Did you have any luck setting the probability ratio to a low value? Setting to 0 must lead to a division by 0 somewhere in the code, hence the NaNs. I should probably introduce a small fix to replace 0 by the minimum double value.

As for your other questions:

I have not tried using the --ntCDR3 flag in the alignment step because it seems like the alignment step is successful. Should I try using the --ntCDR3 flag? We have indices of V and J positions in the read but it may just take me some thinking to match that to offsets.

In general I would advise you to use your V and J position knowledge, especially since you have such short reads (60bp). Disregarding this information is increasing uncertainty for the algorithm and can only produce worse results.
As for CDR3, this would require you to first preprocess your sequences in order to extract their CDR3 sequences. Many tools can perform this operation, although they all rely on some kind of alignment, and because you have very short reads you cannot be guaranteed they will spit out the correct CDR3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants