Answers.Body: <p>As Iakov Davydov points out above mathematical calculation is very difficult. Particularly if you do not have uniform nucleotide, dinucleotide etc. frequencies. Thus I'd recommend using a method based on randomisation. </p>
  
  <p>You'd want to randomise only within genes since the likelihood of getting an editing island is likely to be dependent on expression level of the RNA. </p>
  
  <p>You might like to look at what people analysing CLIP data do for these sorts of analyses. See for example <a href="https://www.ncbi.nlm.nih.gov/pubmed/21048981" rel="nofollow noreferrer">Wang et al</a>. Or I have code for this sort of thing in my <a href="https://github.com/sudlab/iCLIPlib" rel="nofollow noreferrer"><code>iCLIPlib</code></a>. See the module <a href="https://github.com/sudlab/iCLIPlib/blob/master/iCLIP/kmers.py" rel="nofollow noreferrer"><code>kmer.py</code></a>. (WARNING: this code is still in development, and is not "released" yet, so I offer no promises about bugs or how easy it would be for your to get working). However, these approaches generally only <em>rank</em> the significance of kmers rather than giving absolute significance values. </p>
  
  <p><a href="http://gat.readthedocs.io/en/latest/contents.html" rel="nofollow noreferrer">Genome Annotation Tester (GAT)</a> might be of use here. You would define genes as your workspace, islands as your annotations, and motif matches as your segments of interest. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-08T12:08:47.270Z
Answers.LastActivityDate: 2018-03-08T12:08:47.270Z
Answers.UserDisplayName: Ian Sudbery
Answers.Body: <p>As far as I remember the exact probability computation is an open problem. The reason is that potential motifs can overlap, which makes probability computations for an arbitrary string non-trivial, and depends on the motif.</p>
  
  <p>For example if he have a binary string of four digits, the probability of "01" will be 11/16, while the probability of "11" will be 8/16=1/2.</p>
  
  <p>The simplest approximation is to assume that probability of the motif on every position of the sequence is equal and independent. In <a href="https://stepik.org/lesson/Some-Hidden-Messages-are-More-Surprising-than-Others-3/step/5?course=Bioinformatics-Algorithms&amp;unit=7" rel="nofollow noreferrer">such case</a> (this comes from <a href="https://stepik.org/course/Bioinformatics-Algorithms-2" rel="nofollow noreferrer">this course</a>):</p>
  
  <p><a href="https://i.sstatic.net/WZH86.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/WZH86.png" alt="Pr(N,A,Pattern,t)"></a></p>
  
  <p>(Probability of text of length N having at least t occurrences of a k-mer Pattern, A is the number of letters in the alphabet, n = N – t * k)</p>
  
  <p>This approximation is very rough, there are better <a href="https://doi.org/10.1016/0097-3165(81)90005-4" rel="nofollow noreferrer">here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-01T08:22:35.933Z
Answers.LastActivityDate: 2017-06-01T08:22:35.933Z
Answers.UserDisplayName: Iakov Davydov
Body: <p>I would like to show that certain types of RBP motifs are enriched in RNA editing islands (i.e. clusters of RNA editing). However, I am unsure about how to think about sequence motifs with respect to their occurrence in other genomic features.</p>
  
  <p>I understand how to find the probability of a motif at a location. i.e.</p>
  
  <p>P(sequence is at position i) = P(A)^[A] * P(C)^[C] * P(G)^[G] * P(T)^[T]</p>
  
  <p>where (.) is the base pair and [.] is the number of bps. </p>
  
  <p>Instead what I would like to find is: </p>
  
  <p>P(sequence S is contained in a feature type T) = ???</p>
  
  <p>where feature type T is an gene, intron, editing island, etc. I think I should incorporate length since I will mainly be comparing genes or introns vs. editing islands. Also, I am not sure what to do about the editing islands being located within genes. How can I keep from counting the same motif twice?</p>
  
  <p>Any ideas would be greatly appreciated. Thank you for your time. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-01T06:51:45.030Z
Comments.Text: It's a bit unclear if you really just want enrichment in editing islands (use Fisher's exact test) or instead want to argue that there's increased enrichment in editing islands versus other features. Please clarify that.
Comments.UserDisplayName: Devon Ryan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-02T13:31:08.363Z
Comments.Text: Mainly I just want to show enrichment in the islands. I am familiar with Fisher's Exact Test, however, I wasn't sure how applicable it woudl be in this case as it is difficult to define groups i.e. in/not in editing island. Also the lengths of editing islands vary.
Comments.UserDisplayName: tweirick
Tags: <r><motifs>
Title: How to calculate statistical significance of sequence motifs
ThreadText: # How to calculate statistical significance of sequence motifs
  
  (Asked by: username_0 on 2017-06-01)
  
  I would like to show that certain types of RBP motifs are enriched in RNA editing islands (i.e. clusters of RNA editing). However, I am unsure about how to think about sequence motifs with respect to their occurrence in other genomic features.
  
  I understand how to find the probability of a motif at a location. i.e.
  
  P(sequence is at position i) = P(A)^[A] \* P(C)^[C] \* P(G)^[G] \* P(T)^[T]
  
  where (.) is the base pair and [.] is the number of bps.
  
  Instead what I would like to find is:
  
  P(sequence S is contained in a feature type T) = ???
  
  where feature type T is an gene, intron, editing island, etc. I think I should incorporate length since I will mainly be comparing genes or introns vs. editing islands. Also, I am not sure what to do about the editing islands being located within genes. How can I keep from counting the same motif twice?
  
  Any ideas would be greatly appreciated. Thank you for your time.
  
  **Tags:** r, motifs
  
  > **Comments:**
  > **username_1**: It's a bit unclear if you really just want enrichment in editing islands (use Fisher's exact test) or instead want to argue that there's increased enrichment in editing islands versus other features. Please clarify that.  
  > **username_0**: Mainly I just want to show enrichment in the islands. I am familiar with Fisher's Exact Test, however, I wasn't sure how applicable it woudl be in this case as it is difficult to define groups i.e. in/not in editing island. Also the lengths of editing islands vary.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2017-06-01. Score: 4 | Accepted answer
  
  As far as I remember the exact probability computation is an open problem. The reason is that potential motifs can overlap, which makes probability computations for an arbitrary string non-trivial, and depends on the motif.
  
  For example if he have a binary string of four digits, the probability of "01" will be 11/16, while the probability of "11" will be 8/16=1/2.
  
  The simplest approximation is to assume that probability of the motif on every position of the sequence is equal and independent. In [such case](https://stepik.org/lesson/Some-Hidden-Messages-are-More-Surprising-than-Others-3/step/5?course=Bioinformatics-Algorithms&unit=7) (this comes from [this course](https://stepik.org/course/Bioinformatics-Algorithms-2)):
  
  [![Pr(N,A,Pattern,t)](https://i.sstatic.net/WZH86.png)](https://i.sstatic.net/WZH86.png)
  
  (Probability of text of length N having at least t occurrences of a k-mer Pattern, A is the number of letters in the alphabet, n = N – t \* k)
  
  This approximation is very rough, there are better [here](https://doi.org/10.1016/0097-3165(81)90005-4).
  
  
  ---
  
  ### Answer by username_2 on 2018-03-08. Score: 1
  
  As username_3 username_3 points out above mathematical calculation is very difficult. Particularly if you do not have uniform nucleotide, dinucleotide etc. frequencies. Thus I'd recommend using a method based on randomisation.
  
  You'd want to randomise only within genes since the likelihood of getting an editing island is likely to be dependent on expression level of the RNA.
  
  You might like to look at what people analysing CLIP data do for these sorts of analyses. See for example [Wang et al](https://www.ncbi.nlm.nih.gov/pubmed/21048981). Or I have code for this sort of thing in my [`iCLIPlib`](https://github.com/sudlab/iCLIPlib). See the module [`kmer.py`](https://github.com/sudlab/iCLIPlib/blob/master/iCLIP/kmers.py). (WARNING: this code is still in development, and is not "released" yet, so I offer no promises about bugs or how easy it would be for your to get working). However, these approaches generally only *rank* the significance of kmers rather than giving absolute significance values.
  
  [Genome Annotation Tester (GAT)](http://gat.readthedocs.io/en/latest/contents.html) might be of use here. You would define genes as your workspace, islands as your annotations, and motif matches as your segments of interest.
  
  
  ---
  
  