/********************************************************************************/ /* FILENAME: samplepls.txt */ /* */ /* DATE/LAST MODIFIED: 03.05.02/03.05.02/02.14.08 */ /* */ /* AUTHOR: Danh V. Nguyen, Biostatistics, UC Davis. */ /* */ /* DESCRIPTION: */ /* This file contains some sample SAS codes to run partial least squares (PLS). */ /* The codes below */ /* 1. read in a matrix of gene expression values of size nxp (here p=3846) */ /* and a vector of class indicator (0 or 1) and */ /* 2. run PROC PLS. */ /* The expression matrix here is SPACE delimited. If your expression matrix is */ /* TAB delimited (or another type), change the the line: delimiter=' ' (space) */ /* to delimitor=' ' (tab), etc. */ /* */ /* NOTES: */ /* Comments can be found below along with the codes. For details on PLS see */ /* the SAS documentation for PROC PLS (pp.2691-2734), SAS/STAT User's Guide, */ /* Version 8, NC, SAS Institute Inc. (1999). Many examples are given there. */ /* */ /* OUTPUT: */ /* The data set OUTPLS includes the variables xscr1-xscr&lv, which are the PLS */ /* gene components. You can run your favorite classification routine in SAS, */ /* such as PROC LOGISTIC or PROC DISCRIM, or you can save the PLS gene */ /* components and input it into your favorite program. */ /* */ /* Have fun. Cheers. Danh */ /********************************************************************************/ options ls=80 ps=60; /*------------------------------------------------------------------------------*/ /* Change these input parameters to suit your data set. */ /*------------------------------------------------------------------------------*/ %let p=3051; %let Xfilename=Xcomplete.txt; %let Yfilename=Ycomplete.txt; /* Load complete gene expression matrix, X. */ data Xcomp; infile "&Xfilename" delimiter=' ' lrecl=200000; input x1-x&p; run; /* Load response vector (matrix), Y. */ data Ycomp; infile "&Yfilename" delimiter=' ' lrecl=20000; input y; run; data comb; merge Xcomp Ycomp; run; %macro RUNPLS(dsxin, dsyin, p, lv); proc pls data=&dsxin method=pls outmodel=EST1 lv=&lv; model &dsyin = x1-x&p; output out=OUTPLS p=yhat1 yresidual=yres1 xresidual=xres1-xres&p xscore=xscr yscore=yscr stdy=stdy stdx=stdx h=h press=press t2=t2 xqres=xqres yqres=yqres; run; %mend; /* The input lv is the number of PLS components, which should be specified. */ %RUNPLS(dsxin=comb, dsyin=y, p=3051, lv=2); /* lv=2 PLS components */ %RUNPLS(dsxin=comb, dsyin=y, p=3051, lv=5); /* lv=5 PLS components */