I have used a python script to identify target sequences in a DNA sequence file. There are two classes of sequence: coding and non-coding.

I have identified 728 sequences of interest. 597 of these fall into the coding regions and 131 of these fall into the non-coding regions. This is the equivalent of 18% non-coding. The total non-coding region in the sequence file is 13%.

Is there a statistical tool to demonstrate the python script identified target sequences in a non-random fashion? If the script identified sequences that were randomly distributed then 13% of them would have been found in the non-coding region, from a total of 728 this seems like it should be reliable.


1 Answer 1


You can model this as a binomial process.

A genomic region can be either coding or non-coding. Drawing 100 samples from a distribution where 90% of the regions are non-coding, you would expect that you draw around 90 non-coding and 10 coding samples. The farther away you are from this expected ratio, the less likely it is that the 100 samples are drawn by (uniform) random from the 90/10 distribution.

Therefore, given the fraction of coding/non-coding regions, the total number of regions and the number of regions identified as non-coding by your script, you can calculate a p-value and reject the assumption that your script identified non-coding regions in a random fashion if the p-value is small enough.

You can do this in R like this:

binom.test(x, n, p)

where x is the number of non-coding regions identified by your script, n the total number of regions and p the fraction of non-coding regions.

  • $\begingroup$ Excellent, this makes perfect sense and sounds just exactly like what I was looking for. $\endgroup$ Jan 8, 2019 at 16:58
  • $\begingroup$ Could I just check I have done this correctly. My reference ([doi.org/10.1186/s13068-017-0742-z] - Table 1, Row 1) shows there are 3871 coding regions to get total regions (n) I have multiplied this by 2 as every coding region is separated by a non coding which produces a total of 7742. The fraction of non-coding is 13.04% which I have expressed as 0.1304 $\endgroup$ Jan 8, 2019 at 17:40
  • $\begingroup$ Exact binomial test data: 131 and 7742 number of successes = 131, number of trials = 7742, p-value < 2.2e-16 alternative hypothesis: true probability of success is not equal to 0.1304 95 percent confidence interval: 0.01416616 0.02004698 sample estimates: probability of success 0.01692069 $\endgroup$ Jan 8, 2019 at 17:58
  • $\begingroup$ It doesn't look weird. That p-value is just zero for all practical purposes. $\endgroup$
    – Pere
    Jan 8, 2019 at 19:09
  • $\begingroup$ @Ryan_J_Hope as Pere said, the p-value is just very small ($<10^{-16}$), which look reasonable considering your data. $\endgroup$
    – Scholar
    Jan 8, 2019 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.