# How to compute a p-value for the similarity measurement of two DNA sequences/contigs?

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 .

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$$?

• 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.
– gringer
Jun 4, 2021 at 11:22
• What is basis of your denominator ? How will you calculate ? what does , comma here, stand for? How is it better measure ? Feb 4, 2022 at 3:49

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.

• The overlap is what the aligner labeled as the largest similar subsequence
– 0x90
Jun 7, 2021 at 2:06
• Maybe something along the lines of how blast compute p-value
– 0x90
Jun 7, 2021 at 2:24