Answers.Body: <p>Well, here my thoughts:</p>
  <p>The equation <span class="math-container">$s$</span> somehow tries to represent the ratio <span class="math-container">$\frac{equality}{equality+inequality}$</span>. But <span class="math-container">$s$</span> returns only a value. And to assing the p-value to a single value... is complicated.</p>
  <p>How could you approach this?</p>
  <ul>
  <li>Using some kind of Hamming distance for each base pair at the position <span class="math-container">$n$</span> (<span class="math-container">$1 \leqslant n \leqslant len$</span>) between the <code>sequence i</code> (<span class="math-container">$s_{i}$</span>) and <code>sequence j</code> (<span class="math-container">$s_{j}$</span>) in order to get a set of binary data:</li>
  </ul>
  <p><span class="math-container">$$s_{ij} = \begin{Bmatrix} 1\ if\ seq_{i_{n}}=seq_{j_{n}} \\ 0\ if\ seq_{i_{n}}\neq seq_{j_{n}}   \end{Bmatrix}$$</span></p>
  <p>With this, you get a set of binomial data (eg <span class="math-container">$\{0,1,0,1,0,1,1,1,0,1,1,1,0,...\}$</span>). Now, you should be able to perform some (Binary?) test and get the p-value.</p>
  <p>PD: Consider aligning the two sequences if there is interest in discussing base pair homology.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-07T02:06:58.450Z
Answers.Text: The overlap is what the aligner labeled as the largest similar subsequence
Answers.UserDisplayName: 0x90
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-07T02:24:05.420Z
Answers.Text: Maybe something along the lines of [how blast compute p-value](http://synbio.info/download/attachments/1835109/stat_scores.pdf?version=1&modificationDate=1466522518650&api=v2)
Answers.UserDisplayName: 0x90
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-07T00:10:38.313Z
Answers.LastActivityDate: 2021-06-07T00:16:56.253Z
Answers.LastEditDate: 2021-06-07T00:16:56.253Z
Answers.UserDisplayName: Ivan Castro
Body: <p>I'm attempting to come up with a statistical model to determine the p-value for the similarity value <span class="math-container">$ 0 \le s \le 1 $</span> of two DNA contigs.
  The idea is to get a numerical measure to estimate if two contigs are homologous.</p>
  <p>I want to account for base composition (and/or other structural features) if possible, but not necessarily because I might want to do the analysis only from the information about the length of the sequences/contigs and largest overlaps. Maybe something inspired from other <a href="https://academic.oup.com/bib/article/7/1/2/262762" rel="nofollow noreferrer">statistical significance in bioinformatics </a>.</p>
  <p>Assume we have two DNA sequences: <span class="math-container">$a$</span> and <span class="math-container">$b$</span> with the basepair lengths <span class="math-container">$a_{\text{len}}$</span>, <span class="math-container">$b_{\text{len}}$</span>. Their overlap <span class="math-container">$o_{a-b}$</span> is the number of contiguous bases that appears in both sequences. If we define the similarity <span class="math-container">$s = \frac{o_{a-b}}{\min{(a_{\text{len}}, b_{\text{len}})}}$</span> how can we define a p-value for <span class="math-container">$s$</span>?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-04T11:22:14.187Z
Comments.Text: Okay, can you please give some more context in your question about a specific use case for this algorithm? It will help to get better answers.
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-02-04T03:49:30.827Z
Comments.Text: What is basis of your denominator ? How will you calculate ? what does  ,  comma here, stand for? How is it better measure ?
Comments.UserDisplayName: Subhash C. Davar
Tags: <sequence-analysis><phylogenetics><p-values>
Title: How to compute a p-value for the similarity measurement of two DNA sequences/contigs?
ThreadText: # How to compute a p-value for the similarity measurement of two DNA sequences/contigs?
  
  (Asked by: username_0 on 2021-06-03)
  
  I'm attempting to come up with a statistical model to determine the p-value for the similarity value $ 0 \le s \le 1 $ of two DNA contigs.
  The idea is to get a numerical measure to estimate if two contigs are homologous.
  
  I want to account for base composition (and/or other structural features) if possible, but not necessarily because I might want to do the analysis only from the information about the length of the sequences/contigs and largest overlaps. Maybe something inspired from other [statistical significance in bioinformatics](https://academic.oup.com/bib/article/7/1/2/262762) .
  
  Assume we have two DNA sequences: $a$ and $b$ with the basepair lengths $a\_{\text{len}}$, $b\_{\text{len}}$. Their overlap $o\_{a-b}$ is the number of contiguous bases that appears in both sequences. If we define the similarity $s = \frac{o\_{a-b}}{\min{(a\_{\text{len}}, b\_{\text{len}})}}$ how can we define a p-value for $s$?
  
  **Tags:** sequence-analysis, phylogenetics, p-values
  
  > **Comments:**
  > **username_1**: Okay, can you please give some more context in your question about a specific use case for this algorithm? It will help to get better answers.  
  > **username_2**: What is basis of your denominator ? How will you calculate ? what does  ,  comma here, stand for? How is it better measure ?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2021-06-07. Score: 1
  
  Well, here my thoughts:
  
  The equation $s$ somehow tries to represent the ratio $\frac{equality}{equality+inequality}$. But $s$ returns only a value. And to assing the p-value to a single value... is complicated.
  
  How could you approach this?
  
  * Using some kind of Hamming distance for each base pair at the position $n$ ($1 \leqslant n \leqslant len$) between the `sequence i` ($s\_{i}$) and `sequence j` ($s\_{j}$) in order to get a set of binary data:
  
  $$s\_{ij} = \begin{Bmatrix} 1\ if\ seq\_{i\_{n}}=seq\_{j\_{n}} \\ 0\ if\ seq\_{i\_{n}}\neq seq\_{j\_{n}} \end{Bmatrix}$$
  
  With this, you get a set of binomial data (eg $\{0,1,0,1,0,1,1,1,0,1,1,1,0,...\}$). Now, you should be able to perform some (Binary?) test and get the p-value.
  
  PD: Consider aligning the two sequences if there is interest in discussing base pair homology.
  
  > **Comments:**
  > **username_0**: The overlap is what the aligner labeled as the largest similar subsequence  
  > **username_0**: Maybe something along the lines of [how blast compute p-value](http://synbio.info/download/attachments/1835109/stat_scores.pdf?version=1&modificationDate=1466522518650&api=v2)  
  
  ---
  
  