How Can I Merge Intervals ?
I want to merge intervals using weighted means instead of sum or average. Thanks for taking your time to read this file.
My input data: data format: chrFileA startFileA endFile1 chrFile2 startFile2 endFile2 value TheLengthOfOverlap
chr1 12000 13000 chr1 12984 13164 3 16
chr1 13000 14000 chr1 12984 13164 3 164
My output data: data format: chrFileA startFileA WeightedMeanValues
chr1 12000 13000 16/(13164-12984)*3
chr1 13000 14000 164/(13164-12984)*3
Any help would be great grateful.
• 1,193 views
•
link
2 answers
I think pandas and numpy models are suit for our analysis.
• 0 views
•
link
I know how to calculate this one. Just using groupby function and pd object. df.groupby(col2 and col3).apply(lambda x: np.average(col7, weights=col8))
• 0 views
•
link
Log in to answer this question.