function organoid_growth(ageDivH,Nneigh,maxRad) % -- to remember random number seed=randi(5000); rng(seed); % -- showing images and saving the data: ShowImages = 1; % 0=dont show images; 1=show images HowOftenShow = 672; % choose an iteration step for drawing SaveData = 1; % 0=dont show images; 1=show images % -- cell & microenvironment characteristics cellLine = 3; StiffRep = 0.45; StiffAdh = 0.03; microEnv = 1; drug = 1; concDrug = 0; nu=10; % viscosity of the media pathsave=['cell',num2str(cellLine),'-mE',num2str(microEnv)]; % -- domain boundary: xmin=-200; xmax=-xmin; ymin=xmin; ymax= xmax; zmin=xmin; zmax=xmax; % -- time progression: Ndays = 14; % simulation time [days] dt = 30; % interval for diffusion in minutes Niter = floor(Ndays*24*60/dt); % number of iterations corresponing % to 14 days % -- initial cell and its coordinates: Ncell = 1; % 1 initial cell cell = [0,0,0]; % cell coordinates [x,y,z]; neigh = 0; % number of neighbors % -- define cell size (originally 8 for #4 cell line and 9.5 for others) rad(Ncell,1)=maxRad; % -- other parameters associated with cell lifespan ageDiv=ageDivH*60; age = [ageDiv/2,ageDiv]; % age [current,mature] cell_phase = [0,0]; % phase of cell cycle ([age-based,numeric-value]) cellhist = 0; % % -- variables needed to calculate area of the projection of the spheroid maxd = 2*maxRad; maxdiam = 1.5*maxRad; %% ------ drawing figure if (ShowImages==1) ff=figure('Position',[150,150,1000,550]); set(ff,'PaperPositionMode','auto') set(ff,'InvertHardcopy','off'); set(gca,'color','white') set(gcf,'color','white') clf colordef white end %% ------ experimetnal data & fitting time=[0,144,336,480,672]; aver=[2*maxRad,53.5104430000000,149.4803700000000,... 219.0245300000000,247.1622400000000]; std =[0,17.824574999999999,37.986648000000002,... 55.869179000000003,60.979132000000000]; datafit=polyfit(time,aver,3); timefit=0:671; valfit =polyval(datafit,timefit); %% ======= MAIN LOOP ====== iter=0; stopcond=0; while ((iter=age(icell,2)) &&... (neigh(icell,1)<= Nneigh) Ncell = Ncell+1; % new cell index thet = pi*rand; % random angle for location of daughter cells phi = 2*pi*rand; % random angle for location of daughter cells newrad = rad(icell,1); % radius of a mother cell cell(Ncell,1:3)=cell(icell,1:3)+0.5*newrad*... % cell location [sin(thet)*cos(phi),sin(thet)*sin(phi),cos(thet)]; cell(icell,1:3)=cell(icell,1:3)-0.5*newrad*... [sin(thet)*cos(phi),sin(thet)*sin(phi),cos(thet)]; rad(icell,1) = 0.65*newrad; % radius of two newborn cells rad(Ncell,1) = 0.65*newrad; age(icell,1) = 0; % age of new daughter cells age(Ncell,1) = 0; agemem = age(icell,2); % mother maturation age age(icell,2) = ageDiv+0.1*(0.5-rand)*ageDiv; % maturation age of new age(Ncell,2) = ageDiv+0.1*(0.5-rand)*ageDiv; % daughter cells +/- 5% neigh(icell,1) = 0; % number of neighbors for daughters neigh(Ncell,1) = 0; end % if end % for % --- phases of cell cycle: G0, G1, S, G2, M; % of time --- for icell=1:Ncell cell_phase(icell,1)=100*age(icell,1)/age(icell,2); if (cell_phase(icell,1) >=0) && (cell_phase(icell,1) < 5) cell_phase(icell,2) = 0; elseif (cell_phase(icell,1) >=5) && (cell_phase(icell,1) < 45) cell_phase(icell,2) = 1; elseif (cell_phase(icell,1) >=45) && (cell_phase(icell,1) < 80) cell_phase(icell,2) = 2; elseif (cell_phase(icell,1) >=80) && (cell_phase(icell,1) < 95) cell_phase(icell,2) = 3; else cell_phase(icell,2) = 4; end end % --- cell-cell physical interactions --- [forceR,forceA,neigh] = DefineForce(rad,cell,StiffRep,StiffAdh,Ncell,maxRad); % --- cell relocation due to forces --- cell(1:Ncell,1:3)=cell(1:Ncell,1:3)+dt*(forceR(1:Ncell,1:3)+forceA(1:Ncell,1:3))/nu; % --- cell growth and size increase --- for icell=1:Ncell if (cell_phase(icell,2)<4) && (rad(icell,1)0)&&(dxyz<(rad(jj,1)+rad(ii,1))) forceR(ii,1:3)=forceR(ii,1:3)+(StiffRep*(dxyz-(rad(ii,1)+... rad(jj,1)))/dxyz)*[dx,dy,dz]; forceR(jj,1:3)=forceR(jj,1:3)-(StiffRep*(dxyz-(rad(ii,1)+... rad(jj,1)))/dxyz)*[dx,dy,dz]; end if (dxyz<2.25*maxRad)&&(dxyz>2*maxRad) forceA(ii,1:3)=forceA(ii,1:3)+(StiffAdh*(dxyz-2*maxRad)/dxyz)*[dx,dy,dz]; forceA(jj,1:3)=forceA(jj,1:3)-(StiffAdh*(dxyz-2*maxRad)/dxyz)*[dx,dy,dz]; end if (dxyz>0)&&(dxyz<4*maxRad) neigh(ii,1)=neigh(ii,1)+1; neigh(jj,1)=neigh(jj,1)+1; end end % for jj end % for ii end % end of function DefineForce % ---------------------------------------------------------------------- function [maxar,maxd]=maxDiameter(cell,maxRad,maxd_old) distanceMxy=pdist2(cell(:,1:2),cell(:,1:2),'euclidean'); distanceMyz=pdist2(cell(:,2:3),cell(:,2:3),'euclidean'); distanceMxz=pdist2(cell(:,1:2:3),cell(:,1:2:3),'euclidean'); uniqueMxy=unique(distanceMxy); uniqueMyz=unique(distanceMyz); uniqueMxz=unique(distanceMxz); maxd1=uniqueMxy(end,end); % diameter from xy plane maxd2=uniqueMyz(end,end); % diameter from yz plane maxd3=uniqueMxz(end,end); % diameter from xz plane maxd=mean([maxd1,maxd2])+2*maxRad; if maxd1; error 'Too many input arguments'; elseif ~islogical(varargin{1}); error 'C must be logical (TRUE||FALSE)' else c = varargin{1}; end % Compare inputs if ~all(size(y)==size(f)); error 'Y and F must be the same size'; end % Check for NaN tmp = ~or(isnan(y),isnan(f)); y = y(tmp); f = f(tmp); n=length(y); sx=sum(y); sy=sum(f); % elements of corr coef calculations sxy=sum(y.*f); sxx=sum(y.*y); syy=sum(f.*f); r=(sxy-sx*sy/n) / sqrt((sxx-(sx*sx)/n)*(syy-(sy*sy)/n) ); r2=r*r; end % =======================================================================