function out=handMetaGxEVarAnalysis(in,varOfInterest)

eval(['data=in.' varOfInterest ';']);
minN=70;

potatoIndices=strcmp('potato',in.expCond);
agarIndices=strcmp('agar',in.expCond);
amwpotato20Indices=strcmp('amwpotato20',in.expCond);
htpagar50Indices=strcmp('5htpagar50',in.expCond);
ctrlaapotatoIndices=strcmp('ctrlaapotato',in.expCond);
htppotato50Indices=strcmp('5htppotato50',in.expCond);
allIndices=potatoIndices+agarIndices+amwpotato20Indices+htpagar50Indices+ctrlaapotatoIndices+htppotato50Indices;
allIndices=allIndices==1;

genotypes=unique(in.genotype);

out.gxeVars=[];
out.gxeNs=[];

for i=1:length(genotypes)
    genoIndices=strcmp(genotypes{i},in.genotype);
    
    if isequal(genotypes{i}(1:min([4 length(genotypes{i})])),'dgrp')
        vec=[];
        vec=[vec nanstd(data(ctrlaapotatoIndices.*genoIndices==1))/...
            nanmean(data(ctrlaapotatoIndices.*genoIndices==1))];
        vec=[vec nanstd(data(amwpotato20Indices.*genoIndices==1))/...
            nanmean(data(amwpotato20Indices.*genoIndices==1))];
        
        vec=[vec nanstd(data(potatoIndices.*genoIndices==1))/...
            nanmean(data(potatoIndices.*genoIndices==1))];
        vec=[vec nanstd(data(htppotato50Indices.*genoIndices==1))/...
            nanmean(data(htppotato50Indices.*genoIndices==1))];
        
        vec=[vec nanstd(data(agarIndices.*genoIndices==1))/...
            nanmean(data(agarIndices.*genoIndices==1))];
        vec=[vec nanstd(data(htpagar50Indices.*genoIndices==1))/...
            nanmean(data(htpagar50Indices.*genoIndices==1))];

        out.gxeVars=[out.gxeVars;vec];
        
        vec=[];
        vec=[vec sum(ctrlaapotatoIndices.*genoIndices==1)];
        vec=[vec sum(amwpotato20Indices.*genoIndices==1)];
        
        vec=[vec sum(potatoIndices.*genoIndices==1)];
        vec=[vec sum(htppotato50Indices.*genoIndices==1)];
        
        vec=[vec sum(agarIndices.*genoIndices==1)];
        vec=[vec sum(htpagar50Indices.*genoIndices==1)];

        out.gxeNs=[out.gxeNs;vec];
    end
end

out.gxeVars=out.gxeVars;
out.gxeNs=out.gxeNs;
out.allIndices=allIndices;

% out.lm=fitlm(in(allIndices==1,:),['lev_' varOfInterest '~genotype+expCond']);
% disp(out.lm.Coefficients);

figure;
hold on;

for i=1:length(out.gxeVars)
    plot([1 2],[out.gxeVars(i,1) out.gxeVars(i,2)],'k.-');
    plot([3 4],[out.gxeVars(i,3) out.gxeVars(i,4)],'k.-');
    plot([5 6],[out.gxeVars(i,5) out.gxeVars(i,6)],'k.-');
end
xlim([0 7])