How Can I Merge Intervals ?
2
0
Entering edit mode
5.1 years ago
Ashley ▴ 90

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.

sequencing • 761 views
ADD COMMENT
0
Entering edit mode
5.1 years ago
Ashley ▴ 90

I think pandas and numpy models are suit for our analysis.

ADD COMMENT
0
Entering edit mode
5.1 years ago
Ashley ▴ 90

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))

ADD COMMENT

Login before adding your answer.

Traffic: 2102 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6