(* LISCA, Linear Scale Cell-Cycle Analysis by Fujikawa-Yamamoto (2005)*)

(* Create list mode data by FCS to ASCII. Put the data into Mathematica folder. Parm = {0,0,0,1,0} means that FL2A is the 4th.*)

(* Read data *)
filename=InputString["File Name ??"];
Totaldata=ReadList[filename,Table[Number,{5}]];
Parm={0,0,0,1,0};
FL2Alist=Totaldata.Parm;
HT1024=Table[0,{t,1,1024}];
Do[If[FL2Alist[[i]]>0,HT1024[[FL2Alist[[i]]]]+=1,HT1024[[FL2Alist[[i]]]]+=0],{i,10000}];
data=HT1024

(* Experimental *)
MaxHeight=Max[Take[data,{10,1023}]];
AxOrigine=AxesOrigin -> {0,0};
PRange=PlotRange ->{0,MaxHeight*1.2};
PJoined=PlotJoined->True;
PStyle=PlotStyle ->{AbsoluteThickness[1], GrayLevel[0]};
GLines=GridLines->{Automatic,None};
dataPlot=ListPlot[data, AxOrigine, PRange, PJoined, PStyle, GLines];

(* Total Cell Number Z*)
Z=Apply[Plus,Take[data,{10,1023}]];

(* G1G2 position *)
For[i=50, Max[Take[data,{i, i}]] < MaxHeight, i += 1, i=i ];
Print["G1Maximum peak position = ", i];
mG1=Input["G1 Channel Number = "];Print["G1 Channel Number = ",mG1]
mG2=Input["G2/M Channel Number = "];Print[" G2/M Channel Number = ",mG2]

(* Center *)
md=(mG2-mG1)/10; md=Round[md];
{m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10}=Table[t=mG1+(md*i), {i,0,10,1}];
M={m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10};

(* CV *)
MaxHeight=Max[Take[data,{m0-10,m0+10}]];
For[i=m0, Max[Take[data,{i, i}]] > MaxHeight/2, i -= 1, i=i];i=i+1;
CV = 0.84932*(m0 - i)/m0; Print["Calculated CV = ",CV]
CV=Input["CV = "];Print["CV = ",CV]

(* Normalization factor *)
B=(CV (2 Pi)^0.5);
{A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10}=1/(B*M);

(* Gaus *)
T0=Table[A0 Exp[-((x-(m0))^2)/(2 (m0 CV)^2)],{x,1,1024}];
T1=Table[A1 Exp[-((x-(m1))^2)/(2 (m1 CV)^2)],{x,1,1024}];
T2=Table[A2 Exp[-((x-(m2))^2)/(2 (m2 CV)^2)],{x,1,1024}];
T3=Table[A3 Exp[-((x-(m3))^2)/(2 (m3 CV)^2)],{x,1,1024}];
T4=Table[A4 Exp[-((x-(m4))^2)/(2 (m4 CV)^2)],{x,1,1024}];
T5=Table[A5 Exp[-((x-(m5))^2)/(2 (m5 CV)^2)],{x,1,1024}];
T6=Table[A6 Exp[-((x-(m6))^2)/(2 (m6 CV)^2)],{x,1,1024}];
T7=Table[A7 Exp[-((x-(m7))^2)/(2 (m7 CV)^2)],{x,1,1024}];
T8=Table[A8 Exp[-((x-(m8))^2)/(2 (m8 CV)^2)],{x,1,1024}];
T9=Table[A9 Exp[-((x-(m9))^2)/(2 (m9 CV)^2)],{x,1,1024}];
T10=Table[A10 Exp[-((x-(m10))^2)/(2 (m10 CV)^2)],{x,1,1024}];
T={T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10};

(* Fit *)
K=0; ZT = Z*T; F = Table[K,{i,11}];
FZ= Sum[(F[[i]]*ZT[[i]]),{i,11}];
Do[Do[If[FZ[[M[[i]]]]<data[[M[[i]]]],F[[i]]+=0.1,F[[i]]=F[[i]]-0.1],{i,11}];
FZ= Sum[(F[[i]] ZT[[i]]),{i,11}];,{10}];
Do[Do[If[FZ[[M[[i]]]]<data[[M[[i]]]],F[[i]]+=0.01,F[[i]]=F[[i]]-0.01],{i,11}];
FZ= Sum[(F[[i]] ZT[[i]]),{i,11}];,{10}];
Do[Do[If[FZ[[M[[i]]]]<data[[M[[i]]]],F[[i]]+=0.001,F[[i]]=F[[i]]-0.001],{i,11}];
FZ= Sum[(F[[i]] ZT[[i]]),{i,11}];,{10}];
Do[Do[If[FZ[[M[[i]]]]<data[[M[[i]]]],F[[i]]+=0.0001,F[[i]]=F[[i]]-0.0001],{i,11}];
FZ= Sum[(F[[i]] ZT[[i]]),{i,11}];,{10}];
Do[If[F[[i]]<0,F[[i]]=0,F[[i]]=F[[i]]],{i,11}];
{F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11}=F;

(* Output *)
PStyle = PlotStyle ->{AbsoluteThickness[1], RGBColor[1,0,0]};
APlot = ListPlot[FZ, AxOrigine, PRange, PJoined, PStyle];
Show[APlot, dataPlot];

FTot=F1+F2+F3+F4+F5+F6+F7+F8+F9+F10+F11;
SFract=(F2+F3+F4+F5+F6+F7+F8+F9+F10)/FTot;
Print["CV = ",CV];Print["Cell Number = ",Z];
Print["G1 Fraction = ",F1/FTot];Print["S Fraction = ",SFract];
Print["G2/M Fraction = ",F11/FTot];Print["S1 Fraction = ",F2/FTot];
Print["S2 Fraction = ",F3/FTot];Print["S3 Fraction = ",F4/FTot];
Print["S4 Fraction = ",F5/FTot];Print["S5 Fraction = ",F6/FTot];
Print["S6 Fraction = ",F7/FTot];Print["S7 Fraction = ",F8/FTot];
Print["S8 Fraction = ",F9/FTot];Print["S9 Fraction = ",F10/FTot];

                

もとに戻る