Estimating periodic signals

Section author: Gavin Huttley, Julien Epps, Hua Ying

We consider two different scenarios:

  • estimating the periods in a signal

  • estimating the power for a given period

  • measuring statistical significance for the latter case

Estimating the periods in a signal

For numerical (continuous) data

We first make some sample data. A periodic signal and some noise.

Discrete Fourier transform

We now use the discrete Fourier transform to estimate periodicity in this signal. Given we set the period to equal 10, we expect the maximum power for that index.

The power (pwr) is returned as an array of complex numbers, so we convert into real numbers using abs. We then zip the power and corresponding periods and sort to identify the period with maximum signal.

Auto-correlation

We now use auto-correlation.

We then zip the power and corresponding periods and sort to identify the period with maximum signal.

For symbolic data

We create a sequence as just a string

We then specify the motifs whose occurrences will be converted into 1, with all other motifs converted into 0. As we might want to do this in batches for many sequences we use a factory function.

We then estimate the integer discrete Fourier transform for the full data. To do this, we need to pass in the symbols from full conversion of the sequence. The returned values are the powers and periods.

We can also compute the auto-correlation statistic, and the hybrid (which combines IPDFT and auto-correlation).

Estimating power for specified period

For numerical (continuous) data

We just use sig created above. The Goertzel algorithm gives the same result as the dft.

For symbolic data

We use the symbols from the above example. For the ipdft, auto_corr and hybrid functions we just need to identify the array index containing the period of interest and slice the corresponding value from the returned powers. The reported periods start at llim, which defaults to 2, but indexes start at 0, the index for a period-5 is simply 5-llim.

For Fourier techniques, we can compute the power for a specific period more efficiently using Goertzel algorithm.

It’s also possible to specify a period to the stand-alone functions. As per the goertzel function, just the power is returned.

Measuring statistical significance of periodic signals

For numerical (continuous data)

We use the signal provided above. Because significance testing is being done using a resampling approach, we define a calculator which precomputes some values to improve compute performance. For a continuous signal, we’ll use the Goertzel algorithm.

Having defined this, we then just pass this calculator to the blockwise_bootstrap function. The other critical settings are the block_size which specifies the size of segments of contiguous sequence positions to use for sampling and num_reps which is the number of permuted replicate sequences to generate.

For symbolic data

Permutation testing

The very notion of permutation testing for periods, applied to a genome, requires the compute performance be as quick as possible. This means providing as much information up front as possible. We have made the implementation flexible by not assuming how the user will convert sequences to symbols. It’s also the case that numerous windows of exactly the same size are being assessed. Accordingly, we use a class to construct a fixed signal length evaluator. We do this for the hybrid metric first.

Note

We defined the period length of interest in defining this calculator because we’re interested in dinucleotide motifs.

We then construct a seq-to-symbol convertor.

The rest is as per the analysis using Goertzel above.