function c_i=chromosome_defect_interdependence(readingz,numindeparms,numdeparms)
%description: reads an array of cases (rows) with presence or absence of defect on each chromosome arm (column), tabulates the abnormalities
    %the input array should have 1p and 19q removed
%called by: command line
%calls: no custom functions
%notes:
%code confirmed date:

tic

c_i=nan(numindeparms,numdeparms);
    
for indeparm=1:numindeparms
    if any(readingz(:,indeparm))
       a=find(readingz(:,indeparm));lengtha=length(a);
       subreadingz=readingz(a,:);
       for deparm=1:numdeparms
           if indeparm~=deparm && any(subreadingz(:,deparm))
               b=find(subreadingz(:,deparm));lengthb=length(b);
               c_i(indeparm,deparm)=round(100*lengthb/lengtha);
           end
       end
    end
end

toc

%s=warning('off','MATLAB:pie:NonPositiveData');close all, hold on, clrz=['b' 'm' 'c' 'y'];
%                 holder=[0 0 0 0];
%                 for i=1:lengthb
%                     c=sum(subreadingz(b(i),:))-2; %subtract 2 b/c we already know the independent arm and the dependent arm are defective in this case
%                     if c<cutoffz(1),holder(1)=holder(1)+1;
%                     elseif c<cutoffz(2),holder(2)=holder(2)+1;
%                     elseif c<cutoffz(3),holder(3)=holder(3)+1;
%                     else holder(4)=holder(4)+1;
%                     end
%                 end
                %currentsubplot=((indeparm-1)*numdeparms)+deparm;
                %subplot(numindeparms,numdeparms,currentsubplot);
                %if currentsubplot==36,error('t'),end
%                 if indeparm>deparm
%                     hpie=pie(holder);
%                     lholder=logical(holder);
%                     if all(lholder==[1 1 1 1])
%                         set(hpie(1),'facecolor',clrz(1)), set(hpie(3),'facecolor',clrz(2)), set(hpie(5),'facecolor',clrz(3)),set(hpie(7),'facecolor',clrz(4))
%                     elseif all(lholder==[1 1 1 0])
%                         set(hpie(1),'facecolor',clrz(1)), set(hpie(3),'facecolor',clrz(2)), set(hpie(5),'facecolor',clrz(3))
%                     elseif all(lholder==[1 1 0 1])
%                         set(hpie(1),'facecolor',clrz(1)), set(hpie(3),'facecolor',clrz(2)), set(hpie(5),'facecolor',clrz(4))
%                     elseif all(lholder==[1 1 0 0])
%                         set(hpie(1),'facecolor',clrz(1)), set(hpie(3),'facecolor',clrz(2))
%                     elseif all(lholder==[1 0 1 1])
%                         set(hpie(1),'facecolor',clrz(1)), set(hpie(3),'facecolor',clrz(3)), set(hpie(5),'facecolor',clrz(4))
%                     elseif all(lholder==[1 0 1 0])
%                         set(hpie(1),'facecolor',clrz(1)),set(hpie(3),'facecolor',clrz(3))
%                     elseif all(lholder==[1 0 0 1])
%                         set(hpie(1),'facecolor',clrz(1)),set(hpie(3),'facecolor',clrz(4))
%                     elseif all(lholder==[1 0 0 0])
%                         set(hpie(1),'facecolor',clrz(1))
% 
%                     elseif all(lholder==[0 1 1 1])
%                         set(hpie(1),'facecolor',clrz(2)),set(hpie(3),'facecolor',clrz(3)),set(hpie(5),'facecolor',clrz(4))
%                     elseif all(lholder==[0 1 1 0])
%                         set(hpie(1),'facecolor',clrz(2)),set(hpie(3),'facecolor',clrz(3))
%                     elseif all(lholder==[0 1 0 1])
%                         set(hpie(1),'facecolor',clrz(2)),set(hpie(3),'facecolor',clrz(4))
%                     elseif all(lholder==[0 1 0 0])
%                         set(hpie(1),'facecolor',clrz(2))
%                     elseif all(lholder==[0 0 1 1])
%                         set(hpie(1),'facecolor',clrz(3)),set(hpie(3),'facecolor',clrz(4))
%                     elseif all(lholder==[0 0 1 0])
%                         set(hpie(1),'facecolor',clrz(3))
%                     elseif all(lholder==[0 0 0 1])
%                         set(hpie(1),'facecolor',clrz(4))
%                     elseif all(lholder==[0 0 0 0])
%                         error('howja get here?')
%                     end
%                     set(hpie(1:2:end),'edgealpha',0)
%                     set(hpie(2:2:end),'visible','off')
%                 elseif indeparm<deparm
                    %text(0.5,0.5,num2str(round(100*lengthb/lengtha))),axis off
                   
%                 end
%,warning(s),