%% PCA analysis script written by Laura Ylä-Outinen %Data organisation X1=readtable('PCA_table.xlsx'); X1(1:36,1)=table({'hPSC_20517_MEA1and2'}); %merging MEA1 and MEA2 data as belonging to the same experiment X2=X1(:,4:end); X3=table2array(X2); Xstandard=zscore(X3); expressions=Xstandard; %% subtipes selection subtypes=X1(:,1); subtypes= table2array(subtypes); subtypes3=categorical(subtypes); %% PCA calculation [coeff, score, latent, tsquared, explained,mu] = pca(expressions); %if matrix do not contain blanks X=score(:,1); Y=score(:,2); Z=score(:,3); %% 3D Visualisation with "gscatter3b" function gscatter3b(X,Y,Z, subtypes3, [0.82 0.3 0.1; 0.82 0.3 0.1; 0.82 0.3 0.1; 0 0.48 0.83; 0 0.48 0.83; 0 0.48 0.83;] ,'ox.ox.',[10,10,15,10,10,15]) ;