PCA.m 758 B

1234567891011121314151617181920212223242526
  1. %% PCA analysis script written by Laura Ylä-Outinen
  2. %Data organisation
  3. X1=readtable('PCA_table.xlsx');
  4. X1(1:36,1)=table({'hPSC_20517_MEA1and2'}); %merging MEA1 and MEA2 data as belonging to the same experiment
  5. X2=X1(:,4:end);
  6. X3=table2array(X2);
  7. Xstandard=zscore(X3);
  8. expressions=Xstandard;
  9. %% subtipes selection
  10. subtypes=X1(:,1);
  11. subtypes= table2array(subtypes);
  12. subtypes3=categorical(subtypes);
  13. %% PCA calculation
  14. [coeff, score, latent, tsquared, explained,mu] = pca(expressions); %if matrix do not contain blanks
  15. X=score(:,1);
  16. Y=score(:,2);
  17. Z=score(:,3);
  18. %% 3D Visualisation with "gscatter3b" function
  19. 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]) ;