<p>dS = -1 
.. there are two suggestions</p>

<ol>
<li><p>I suggest its an error, possibly based on nucleotide calls within the S, check for anomylous nucleotides, particularly over a non-synonymous codon</p></li>
<li><p>It might mean their are no synonymous mutations. It is not the best idea to assign this a value of 0 in a ratio because it will cause the ratio to fall over when in fact their could be strong selection pressure, ie non-synon mutations. Having an incrementally small value is problematic because dN if positive could anything up to infinity, so -1 might flag this problem.</p></li>
</ol>

<hr>

<p>Okay I now know why... You are correct to be concerned with the result because its serious. </p>

<p>My sincere advice to you is do not use any dN/dS ratio where -1 is occurring under any circumstances. On this occasion I'm not going to explain why for two reasons:</p>

<ol>
<li>First and foremost, as a phylogeneticist you should know why, it relates to the fundamentals of the discipline.</li>
<li>(Hint) The answer is in my past posts on this forum.</li>
</ol>

<p>To conclude, I'm pretty nuanced in statistical dogma, you can check my record, IMO most dogma is tribalism because every calculation has weaknesses. HERE HOWEVER, there is a real problem and again I urge you to ditch any data set where -1 is occurring and everything associated with it. That is a fairly dire warning should give you a clue about whats wrong. If you are not prepared to do this, then you must report the result and the situations where it is arising (don't hide it).</p>

CC BY-SA 4.0
2019-05-14T08:16:29.893Z
Thank you for your reply, I provided some more details for you at Upd 3. I checked my nucleotide sequences, and they do not have anything except ATGC, if that's what you meant by 1.
Maxim Krabov
CC BY-SA 4.0
2019-05-13T18:34:26.257Z
2019-05-16T09:26:34.513Z
2019-05-16T09:26:34.513Z
M__
<p>I'm noobie in bioinformatics. I use <code>cal_dn_ds</code> from <code>Bio.codonalign.codonseq</code> with method 'NG86'. Sometimes I get dS=-1. What does it mean? How can number of substitutions be negative? Does it mean that something is wrong with my data?</p>

<p>Upd.
1) Chris_Rands pointed to sources, I read them already, but the question remain. What is that <code>ps</code> variable, and why if it's greater than 3/4, dS = -1? </p>

<p>2) Some more details. 
<code>cal_dn_ds</code> requires sequences from <code>CodonAlignment</code> object, which is created by function <code>Bio.codonalign.build</code> that requires (quote from docs) <code>protein alignment and corresponding nucleotides</code>. I have nucleotide sequences from NCBI at the beginning. So I trim non-coding regions from nucleotide sequences, translate all trimmed sequences, write them to a file, perform multiple alignment of the protein sequences, and then pass the list of aligned protein sequences and the list of nucleotide sequences to the <code>build</code> function.
I analize protein DKK1, and example sequences that get negatives are <em>Empidonax traillii XM_027898752.1</em> and <em>Physeter catodon XM_007110600.1</em>. But I just want to understand general idea behind dS = -1, what can it mean it different cases.</p>

<p>3) Michael G. gave an interesting suggestion that it means zero, but it's strange because the function returns dN and dS separately, so Biopython might as well return zero, so the user would handle those cases himself. And for some sequences Biopython actually returns normal positive dS and dN = 0 at the same time. If it's an error, what are the possible causes? And why in those error cases Biopython can calculate dN, but dS is -1?</p>

CC BY-SA 4.0
2019-05-13T14:12:02.300Z
Please [edit] your question and give us some more details. What kind of input do you have? What are you passing as input to `cal_dn_ds`? If you are using some sort of alignment, what species are involved? The more details you give us, the better your chances of getting a useful answer.
terdon
CC BY-SA 4.0
2019-05-13T14:59:22.930Z
https://github.com/biopython/biopython/blob/master/Bio/codonalign/codonseq.py#L390
Chris_Rands
CC BY-SA 4.0
2019-05-14T08:04:04.920Z
terdon, Chirs_Rands, thank you for replies, I updated my question with more details.
Maxim Krabov
<python><phylogenetics><phylogeny>
What do negative dN or dS mean in cal_dn_ds in Biopython?
# What do negative dN or dS mean in cal_dn_ds in Biopython?

(Asked by: username_0 on 2019-05-13)

I'm noobie in bioinformatics. I use `cal_dn_ds` from `Bio.codonalign.codonseq` with method 'NG86'. Sometimes I get dS=-1. What does it mean? How can number of substitutions be negative? Does it mean that something is wrong with my data?

Upd.
1) Chris\_Rands pointed to sources, I read them already, but the question remain. What is that `ps` variable, and why if it's greater than 3/4, dS = -1?

2) Some more details.
`cal_dn_ds` requires sequences from `CodonAlignment` object, which is created by function `Bio.codonalign.build` that requires (quote from docs) `protein alignment and corresponding nucleotides`. I have nucleotide sequences from NCBI at the beginning. So I trim non-coding regions from nucleotide sequences, translate all trimmed sequences, write them to a file, perform multiple alignment of the protein sequences, and then pass the list of aligned protein sequences and the list of nucleotide sequences to the `build` function.
I analize protein DKK1, and example sequences that get negatives are *Empidonax traillii XM\_027898752.1* and *Physeter catodon XM\_007110600.1*. But I just want to understand general idea behind dS = -1, what can it mean it different cases.

3) Michael G. gave an interesting suggestion that it means zero, but it's strange because the function returns dN and dS separately, so Biopython might as well return zero, so the user would handle those cases himself. And for some sequences Biopython actually returns normal positive dS and dN = 0 at the same time. If it's an error, what are the possible causes? And why in those error cases Biopython can calculate dN, but dS is -1?

**Tags:** python, phylogenetics, phylogeny
> **Comments:**
> **username_1**: Please [edit] your question and give us some more details. What kind of input do you have? What are you passing as input to `cal_dn_ds`? If you are using some sort of alignment, what species are involved? The more details you give us, the better your chances of getting a useful answer.  
> **username_2**: https://github.com/biopython/biopython/blob/master/Bio/codonalign/codonseq.py#L390  
> **username_0**: terdon, Chirs_Rands, thank you for replies, I updated my question with more details.  

---

## 1 answers

### Answer by username_3 on 2019-05-13. Score: 0 | Accepted answer

dS = -1
.. there are two suggestions

1. I suggest its an error, possibly based on nucleotide calls within the S, check for anomylous nucleotides, particularly over a non-synonymous codon
2. It might mean their are no synonymous mutations. It is not the best idea to assign this a value of 0 in a ratio because it will cause the ratio to fall over when in fact their could be strong selection pressure, ie non-synon mutations. Having an incrementally small value is problematic because dN if positive could anything up to infinity, so -1 might flag this problem.

---

Okay I now know why... You are correct to be concerned with the result because its serious.

My sincere advice to you is do not use any dN/dS ratio where -1 is occurring under any circumstances. On this occasion I'm not going to explain why for two reasons:

1. First and foremost, as a phylogeneticist you should know why, it relates to the fundamentals of the discipline.
2. (Hint) The answer is in my past posts on this forum.

To conclude, I'm pretty nuanced in statistical dogma, you can check my record, IMO most dogma is tribalism because every calculation has weaknesses. HERE HOWEVER, there is a real problem and again I urge you to ditch any data set where -1 is occurring and everything associated with it. That is a fairly dire warning should give you a clue about whats wrong. If you are not prepared to do this, then you must report the result and the situations where it is arising (don't hide it).

> **Comments:**
> **username_0**: Thank you for your reply, I provided some more details for you at Upd 3. I checked my nucleotide sequences, and they do not have anything except ATGC, if that's what you meant by 1.  

---

