function out = corrMetGeneExp_skinAging(fe, geneStruct)
%% get met/gene name and datasetName of metabolite and gene expression stuct
metDsName = regexprep(fe.dsSampleName, ' - 01','');
geneDsName = geneStruct.intensities.donor;

metName = fe.merged.metaboliteName;
metMz = fe.merged.ionMz;
geneName = geneStruct.GeneName;
%% search for the overlap between met and geneexp data and reduce data
%matrices
[intDsName, ia, ib] = intersect(metDsName, geneDsName);
metData = fe.merged.mat(:,ia)';
geneDataLog2 = geneStruct.intensities.log2_mat(:,ib)';
geneData = 2.^geneDataLog2;

%% correlate metabolite and gene expression data
[out.rhoMetGeneSpearman, out.pMetGeneSpearman] = corr(metData, geneData,'type', 'Spearman');


%% correlate metabolite and age
out.age.metAge = fe.dsAge(ia)';
[out.age.rhoMetAgePearson, out.age.pMetAgePearson] = corr(metData, out.age.metAge,'type', 'Pearson');
[out.age.rhoMetAgeSpearman, out.age.pMetAgeSpearman] = corr(metData, out.age.metAge,'type', 'Spearman');


%% correlate gene expression and age
out.age.geneAge = geneStruct.intensities.age(ib);
[out.age.rhoGeneAgePearson, out.age.pGeneAgePearson] = corr(geneData, out.age.geneAge,'type', 'Pearson');
[out.age.rhoGeneAgeSpearman, out.age.pGeneAgeSpearman] = corr(geneData, out.age.geneAge,'type', 'Spearman');


%% index metabolites and genes for sorting of reshaped p-value matrix
out.metIdx = repmat([1:length(metMz)]', size(out.rhoMetGeneSpearman,2),1);
out.geneIdx = reshape(repmat(1:length(geneName), size(out.rhoMetGeneSpearman,1),1),...
    size(out.rhoMetGeneSpearman,2)*size(out.rhoMetGeneSpearman,1),1);
out.meta.metName = metName;
out.meta.metMz = metMz;
out.meta.metAnnotation = fe.merged.annotation;
out.meta.geneName = geneName;
out.meta.geneDescription = geneStruct.Description;

end