
Circadian analysis using FFT()
조회 수: 3 (최근 30일)
이전 댓글 표시
I need to get the power spectrum of gene expression data that were sampled every 4 hours for a 48 hour period (13 samples, including zero point). I did an initial analysis based on a sound recording example but I think I'm missing something.
This is the code I'm using:
signal = load('data.txt')
N = length(signal);
fs = 1/(4*60*60); %Samples per second
fnyquist = fs/2; %Nyquist frequency
X_mags = abs(fft(signal));
bin_vals = [0 : N-1];
fax_Hz = bin_vals*fs/N;
N_2 = ceil(N/2);
plot(fax_Hz(1:N_2), X_mags(1:N_2))
I want to know if there are frequencies associated with the period of the signals. This data should have a period around 24 hours.
Mike
댓글 수: 0
채택된 답변
Star Strider
2014년 10월 19일
편집: Star Strider
2014년 10월 19일
I would do it slightly differently, and use your 4-hour sampling time directly:
GE = dlmread('Circadian analysis using FFT_data.txt');
T = [0:length(GE)-1]*4; % Sampling Times (Hours)
Ts = 4; % Sampling Interval (Hours)
Fs = 1/Ts; % Sampling Frequency (1/Hour)
Fn = Fs/2; % Nyquist Frequency (1/Hour)
FGE = fft(GE)/length(GE);
Fv = linspace(0,1,length(FGE)/2+1)*Fn;
Iv = 1:length(Fv);
figure(1)
% plot(Fv, abs(FGE(Iv))) % Frequency = 1/Hour
plot(Fv*24, abs(FGE(Iv))) % Frequency = 1/Day
grid
xlabel('Frequency (D^{-1})')
% xlabel('Frequency (H^{-1})')
ylabel('Amplitude')
The commented lines in the plot are in frequencies of 1/Hour. The uncommented lines are in frequencies of 1/Day, or (obviously) 1/(24 Hours).
EDIT to add plot:

댓글 수: 6
Star Strider
2014년 10월 20일
My pleasure!
Signal processing techniques do not care what sampling times or time base you use so long as you are consistent. If you are acquiring your data in terms of hours rather than seconds, it makes sense to do the analysis in units of hours. (One day is 86400 seconds, so that would create some extremely inconvenient units if you defined your frequencies in Hz.)
You can probably do many calculations in MATLAB that you can do in R, although they may require Toolboxes that are not part of core MATLAB. I will help as much as I can with them if you want to expand your use of MATLAB.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!