pybedtools.featurefuncs.normalized_to_length

pybedtools.featurefuncs.normalized_to_length(feature, idx=4, scalar=0.001)

Normalizes the value at feature[idx] to the feature’s length, in kb.

idx, by default, is the score field for a BED file, but specify any integer.

The value at idx will be replaced with its scaled value.

scalar will be multiplied by the value at idx, by default this is 0.001, or per kb.

Useful for calculating RPKM after running intersect with counts