function addAgeCorrelation2localityOut(filename, corrStruct, localityStruct, geneExpStruct)

[~,~, raw] = xlsread(filename);
raw(1,6) = {'R(Gene/Age)'};
raw(1,7) = {'p(Gene/Age)'};
raw(1,8) = {'log2(Old/Young)'};
raw(1,9) = {'p(Old/Young)'};
raw(1,10) = {'adj.p(Old/Young)'};
for i = 2:size(raw,1)
%     idx = find(strcmp(corrStruct.meta.geneName, raw{i,2}) == 1);
    idxTemp = find(localityStruct.geneIdxModel==raw{i,1});
    idx = localityStruct.geneIdxData(idxTemp);
    for j = 1:length(idx)
%         [~, idMin] = min(corrStruct.age.pGeneAgeSpearman(idx));
        raw{i,6} = corrStruct.age.rhoGeneAgeSpearman(idx);
        raw{i,7} = corrStruct.age.pGeneAgeSpearman(idx);
        raw{i,8} = geneExpStruct.logFC(idx);
        raw{i,9} = geneExpStruct.PValue(idx);
        raw{i,10} = geneExpStruct.adjPVal(idx);
    end
end

xlswrite(filename, raw, 'locality+AgeCorrelation');
end