Package org.bioinfo.ngs.qc.qualimap.beans

Examples of org.bioinfo.ngs.qc.qualimap.beans.PrincipleComponentAnalysis


    public void testPCA() {

        double[] x = {0.69, -1.310.39, 0.091.290.490.19, -0.81, -0.31, -0.71 };
        double[] y = {0.49, -1.210.99, 0.291.090.79, -0.31, -0.81, -0.31, -1.01 };

        PrincipleComponentAnalysis pca = new PrincipleComponentAnalysis();
        pca.setup(10, 2);

        for (int i = 0; i < 10; ++i) {
            double[] sample = {x[i],y[i]};
            pca.addSample( sample );
        }

        pca.computeBasis(2);
        double[] pc1 = pca.getBasisVector(0);
        assertTrue(pc1.length == 2);
        System.out.println(pc1[0]);
        System.out.println(pc1[1]);


        /*for (int i = 0; i < 10; ++i) {
            double[] sample = {x[i],y[i]};
            double[] cS = pca.sampleToEigenSpace(sample);
            System.out.println("(" + cS[0] + " " + cS[1] + ")");
        } */

        double[] s1 = {x[0],y[0]};
        double[] c1 = pca.sampleToEigenSpace(s1);

        // Expecting (-0.8279702,  0.1751153)
        double c1Len = c1[0]*c1[0] + c1[1]*c1[1];
        assertTrue( c1Len  - 0.7162 < 0.00001);

View Full Code Here

TOP

Related Classes of org.bioinfo.ngs.qc.qualimap.beans.PrincipleComponentAnalysis

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.