jokergoo / EnrichedHeatmap

make enriched heatmap which visualizes the enrichment of genomic signals to specific target regions.
http://jokergoo.github.io/EnrichedHeatmap/
Other
186 stars 25 forks source link

Correct calculation of enrich score #80

Open stkmrc opened 1 year ago

stkmrc commented 1 year ago

Hi Zuguang,

I made two commits. Please have a look at the explanations below. If I missed something why this is not the case please let me know!

The first one: Correct me when I got it wrong, but as far as I understand currently the formula will calculate a weight of zero for the last window of the target (and also slightly too low for the upper half of the target. The error is small for a large number of target windows, but increases with a smaller number of target windows.

The second one (on top): In the current version, the if-statements don't seem to fit for me. First, I think instead of checking the target section n2, it looks like n3 should be checked when I look at what is calculated in each case. Second, checking the length of n, which is calculated above as the length of x doesn't make sense since this will always give an integer > 0 and therefore will always be true. In fact, since x1, x2 and x3 are set to an empty matrix anyway in the normalizeToMatrix function you can also instead of correcting the points above just always calculate the whole formula and if up/downstream or target vector is empty it will be zero in the sum and thus not change the result.