Hi,


I have a large file of each chromosome for sequence data and I want to get the average score in 1kb bins?
Is there an easy way to  do to this?

    chr1 123 127 1890
    chr1 208 210 90
    chr1 215 220 50
    chr1 225 230 100
    chr1 250 300 800

I have tried bedtools, it will create the windows but then how do I get the average of the fourth value in that window? It also seems to be quite slow.

    bedtools makewindows -w 1000 -g chromosome.txt > windows.txt

Any help would be much appreciated.

for fun, using awk+sqlite3, window size=100:


     rm -f tmp.db && awk 'BEGIN {printf("create table T(C TEXT,S INT,E INT,V INT); BEGIN TRANSACTION;\n");}{printf("INSERT INTO T(C,S,E,V) VALUES(\"%s\",%s,%d,%s);\n",$1,$2,$3,$4);} END {printf("COMMIT; SELECT C,(S/100)*100 as G,((S/100)+1)*100,AVG(V) FROM T GROUP BY C,G;");}' input.bed | sqlite3 -separator $'\t' tmp.db && rm -f tmp.db
    
    chr1	100	200	1890.0
    chr1	200	300	260.0

