Thank you for the reply, however I think this will only work on small bedGraph files. I got the following error when I tried on my base-pair resolution bedGraph file:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
/home/s1437643/conda/bin/groupBy: line 2: 12111 Aborted ${0%/*}/bedtools groupby "$@"
awk?