text: user235: This question pertains to iCLIP, but it could just as easily be ChIP-seq or ATAC-seq or mutation frequencies. 
  I have iCLIP read counts across the transcriptome and I wish to know if the signals are correlated - that is, where one of them is high, is the other likely to be high.
  Often when dealing with such data (e.g. iCLIP data) we know that the data is generally sparse - that is at most positions both signals are zero and this is correct, and also zero-inflated - that is many bases that "should" have a signal are missing that data. So just calculating the Spearman's correlation is likely to give an artificially low value.
  What might be a way to asses the association? I should add that the aim is the assess association of binding patterns within genes, rather than (or as well as) between genes.
  Things I have thought of:
  
  Apply some sort of smoothing to the data (eg a rolling mean). Remove any bases with 0 in both samples. Compute the spearmans. 
  Calculate the average pairwise distance between every read in sample one and every read in sample two. Compare this to data where the reads have been randomised within genes. 
  
  In the first case removing all bases with 0 in both samples seems wrong. But if 99.99% of all bases have zero in both samples, then this seems like its necessary for Spearman. 
  In the second case, the result seems like it would be non-intuitive to interpret. And also calculating this would be massively computationally intensive. 
  
  user318: It is one of my favorite stories. 
  Drop a glance to StereoGene software, it for genomic track correlation, it described in a preprint.
  You also can run MACS or another peak caller and estimate the correlation of two interval sets using the GenomtriCorr package.
  
  user161: Rather than working on the base level, you could probably work on say gene level counts. Kendall's tau, an ordinal association metric, can then be used as an appropriate correlation measure.
  If $X$ and $Y$ are your iCLIP replicates, $i$ represents gene index and $(x_i, y_i)$ represents the number of RBP binding sites in $X$ and $Y$ respectively for the $i^{th}$ gene, Kendall's tau is defined as :
  $$
  \frac{\text{#(concordant pairs)} - \text{#(discordant pairs)}}{n(n-1)/2}
  $$
  Where any two pairs $(x_i, y_i)$ and $(x_j, y_j)$ are concordant if:
  
  $x_i > x_j$ AND $y_i > y_j$
  
  OR
  
  $x_i < x_j$ AND $y_i < y_j$
  
  Correspondingly they are discordant if:
  
  $x_i < x_j$ AND $y_i > y_j$
  
  OR
  
  $x_i > x_j$ AND $y_i < y_j$
  
  
  user177: It depends whether you want to treat the peak intensities as binary (comparing presence/absence of peaks in the sets) or continuous (comparing the relative magnitudes of the peaks).
  Binary
  For starting out, a simple binary comparison may be appropriate. You can use a peak caller of your choosing to identify peaks in each sample according to your desired criteria. Then you can use a similarity metric such as the Jaccard index to quantify the level of agreement among the peaks in the two samples.
  One potential obstacle is that defining the boundaries of your peaks won't be totally straightforward. For example, a peak in one sample might have 2 overlapping peaks in the other sample, one on each end. A rough solution for this is to divide the genome into bins (maybe around 100-1000 bp, depending on your desired resolution). You can treat a peak as present in a bin if more than half of the peak lies in the bin. That way, bins in one sample can be directly compared to the corresponding bins in the other sample. Obviously, this isn't the only way to do this; other appropriate methods exist too.
  Continuous
  If you want to treat the peak intensities as continuous, you could apply a similar binning method, taking the "score" of a bin to be the average peak intensity at positions within that bin. You could then throw away all bins with no peaks or only low-intensity peaks throughout the genome. Then you could compute the Spearman's correlation for the remaining bins. I'm guessing it will be harder to find a strong correlation for continuous intensities, because of the amount of experimental variability that is inherently present.
  If, after following these steps, the Spearman's correlation is still "artificially low" as you suggested, then this is likely a problem with the underlying data, not the overall analysis; maybe your two datasets actually don't agree that well.
  
  user77: Honestly I'd just use multiBigwigSummary and then plotCorrelation from deepTools for this, but I'm a bit biased. There, the idea would be to consider each gene as a unit (you could instead use bins, but I don't think that would as nicely do what you want), namely by giving the tools a BED or GTF file input. It would then calculate the average signal in each gene/transcript and you could do your spearman's correlation. Features with 0 in all samples could optionally be removed (plotCorrelation --skipZeros).
  While you certainly could go the whole 9 yards and use per-base comparisons, that seems a bit overkill and I suspect that it won't really yield appreciably more information (especially when one considers the additional time overhead).
  
original_text: 235: <p>This question pertains to iCLIP, but it could just as easily be ChIP-seq or ATAC-seq or mutation frequencies. </p>
  
  <p>I have iCLIP read counts across the transcriptome and I wish to know if the signals are correlated - that is, where one of them is high, is the other likely to be high.</p>
  
  <p>Often when dealing with such data (e.g. iCLIP data) we know that the data is generally sparse - that is at most positions both signals are zero and this is correct, and also zero-inflated - that is many bases that "should" have a signal are missing that data. So just calculating the Spearman's correlation is likely to give an artificially low value.</p>
  
  <p><strong>What might be a way to asses the association? I should add that the aim is the assess association of binding patterns within genes, rather than (or as well as) between genes.</strong></p>
  
  <p>Things I have thought of:</p>
  
  <ul>
  <li>Apply some sort of smoothing to the data (eg a rolling mean). Remove any bases with 0 in both samples. Compute the spearmans. </li>
  <li>Calculate the average pairwise distance between every read in sample one and every read in sample two. Compare this to data where the reads have been randomised within genes. </li>
  </ul>
  
  <p>In the first case removing all bases with 0 in both samples seems wrong. But if 99.99% of all bases have zero in both samples, then this seems like its necessary for Spearman. </p>
  
  <p>In the second case, the result seems like it would be non-intuitive to interpret. And also calculating this would be massively computationally intensive. </p>
   318: <p>It is one of my favorite stories. </p>
  
  <p>Drop a glance to <a href="http://stereogene.bioinf.fbb.msu.ru/" rel="nofollow noreferrer">StereoGene software</a>, it for genomic track correlation, it described in a <a href="http://biorxiv.org/content/early/2017/05/25/059584" rel="nofollow noreferrer">preprint</a>.</p>
  
  <p>You also can run MACS or another peak caller and estimate the correlation of two interval sets using the <a href="http://genometricorr.sourceforge.net/" rel="nofollow noreferrer">GenomtriCorr</a> package.</p>
   161: <p>Rather than working on the base level, you could probably work on say gene level counts. <a href="https://en.wikipedia.org/wiki/Kendall_rank_correlation_coefficient" rel="nofollow noreferrer">Kendall's tau</a>, an ordinal association metric, can then be used as an appropriate correlation measure.</p>
  
  <p>If $X$ and $Y$ are your iCLIP replicates, $i$ represents gene index and $(x_i, y_i)$ represents the number of RBP binding sites in $X$ and $Y$ respectively for the $i^{th}$ gene, Kendall's tau is defined as :</p>
  
  <p>$$
  \frac{\text{#(concordant pairs)} - \text{#(discordant pairs)}}{n(n-1)/2}
  $$</p>
  
  <p>Where any two pairs $(x_i, y_i)$ and $(x_j, y_j)$ are concordant if:</p>
  
  <ul>
  <li>$x_i &gt; x_j$ AND $y_i &gt; y_j$</li>
  </ul>
  
  <p>OR</p>
  
  <ul>
  <li>$x_i &lt; x_j$ AND $y_i &lt; y_j$</li>
  </ul>
  
  <p>Correspondingly they are discordant if:</p>
  
  <ul>
  <li>$x_i &lt; x_j$ AND $y_i &gt; y_j$</li>
  </ul>
  
  <p>OR</p>
  
  <ul>
  <li>$x_i &gt; x_j$ AND $y_i &lt; y_j$</li>
  </ul>
   177: <p>It depends whether you want to treat the peak intensities as binary (comparing presence/absence of peaks in the sets) or continuous (comparing the relative magnitudes of the peaks).</p>
  
  <p><strong>Binary</strong></p>
  
  <p>For starting out, a simple binary comparison may be appropriate. You can use a <a href="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0096303" rel="nofollow noreferrer">peak caller</a> of your choosing to identify peaks in each sample according to your desired criteria. Then you can use a similarity metric such as the <a href="https://en.wikipedia.org/wiki/Jaccard_index" rel="nofollow noreferrer">Jaccard index</a> to quantify the level of agreement among the peaks in the two samples.</p>
  
  <p>One potential obstacle is that defining the boundaries of your peaks won't be totally straightforward. For example, a peak in one sample might have 2 overlapping peaks in the other sample, one on each end. A rough solution for this is to divide the genome into bins (maybe around 100-1000 bp, depending on your desired resolution). You can treat a peak as present in a bin if more than half of the peak lies in the bin. That way, bins in one sample can be directly compared to the corresponding bins in the other sample. Obviously, this isn't the only way to do this; other appropriate methods exist too.</p>
  
  <p><strong>Continuous</strong></p>
  
  <p>If you want to treat the peak intensities as continuous, you could apply a similar binning method, taking the "score" of a bin to be the average peak intensity at positions within that bin. You could then throw away all bins with no peaks or only low-intensity peaks throughout the genome. Then you could compute the Spearman's correlation for the remaining bins. I'm guessing it will be harder to find a strong correlation for continuous intensities, because of the amount of experimental variability that is inherently present.</p>
  
  <p>If, after following these steps, the Spearman's correlation is still "artificially low" as you suggested, then this is likely a problem with the underlying data, not the overall analysis; maybe your two datasets actually don't agree that well.</p>
   77: <p>Honestly I'd just use <code>multiBigwigSummary</code> and then <code>plotCorrelation</code> from deepTools for this, but I'm a bit biased. There, the idea would be to consider each gene as a unit (you could instead use bins, but I don't think that would as nicely do what you want), namely by giving the tools a BED or GTF file input. It would then calculate the average signal in each gene/transcript and you could do your spearman's correlation. Features with 0 in all samples could optionally be removed (<code>plotCorrelation --skipZeros</code>).</p>
  
  <p>While you certainly could go the whole 9 yards and use per-base comparisons, that seems a bit overkill and I suspect that it won't really yield appreciably more information (especially when one considers the additional time overhead).</p>
  