function [h,p,SIC_rel_reps] = plotBtBarGraphComparison(idx2plot, legend2plot, SIC_idx, L_taxonomy, ASV_relative_abundance_filt_forexp, cmap) 

n = length(SIC_idx);
SIC_rel_reps = [];
SIC_rel_mean = [];
SIC_rel_std = [];
% rows: SICS
% columns: replicates
for i=1:n
    % create vectors for relative abundance
    % do 4 replicates for now
    SIC_rel_reps(i,:) = ASV_relative_abundance_filt_forexp([SIC_idx(i):SIC_idx(i)+3], idx2plot)';
    SIC_rel_mean(i) = mean(SIC_rel_reps(i,:));
    SIC_rel_std(i) = std(SIC_rel_reps(i,:));
end

% plot relative abundance
b = bar(SIC_rel_mean, 'FaceColor','flat'); hold all;

% change color of bars
for i = 1:n
    b.CData(i,:) = cmap(i,:);
end

set(gca,'xticklabel',legend2plot)
xtickangle(45)

% Plot the errorbars
errorbar(SIC_rel_mean,SIC_rel_std,'k','linestyle','none', 'HandleVisibility','off'); hold all;
for i = 1:n
    scatter(repelem(i,4),SIC_rel_reps(i,:), [],'black', 'HandleVisibility','off'); hold all;
end

%xlim([0.3 3.5])
    
h = zeros(n,n);
p = zeros(n,n);
for i = 1:n
    for j = i:n
        [h(i,j), p(i,j)] = ttest2(SIC_rel_reps(i,1:4), SIC_rel_reps(j,1:4));
    end
end
    
% add significance bars
for i = 1:n
    if p(1,i) <= 0.05
        sigstar([1,i], [p(1,i)])
    end
end


% plot all bars
%sigstar({[1,2],[1,3],[1,4],[1,5],[1,6],[1,7],[1,8]}, ...
%    [p(1,2), p(1,3), p(1,4) p(1,5), p(1,6), p(1,7), p(1,8)])

