Mercurial > repos > bgruening > sklearn_discriminant_classifier
annotate pca.py @ 34:2d032cff49eb draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
| author | bgruening | 
|---|---|
| date | Thu, 01 Oct 2020 20:44:13 +0000 | 
| parents | |
| children | eeaf989f1024 | 
| rev | line source | 
|---|---|
| 34 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 1 import argparse | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 2 import numpy as np | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 3 from sklearn.decomposition import PCA, IncrementalPCA, KernelPCA | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 4 from galaxy_ml.utils import read_columns | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 5 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 6 def main(): | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 7 parser = argparse.ArgumentParser(description='RDKit screen') | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 8 parser.add_argument('-i', '--infile', | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 9 help="Input file") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 10 parser.add_argument('--header', action='store_true', help="Include the header row or skip it") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 11 parser.add_argument('-c', '--columns', type=str.lower, default='all', choices=['by_index_number', 'all_but_by_index_number',\ | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 12 'by_header_name', 'all_but_by_header_name', 'all_columns'], | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 13 help="Choose to select all columns, or exclude/include some") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 14 parser.add_argument('-ci', '--column_indices', type=str.lower, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 15 help="Choose to select all columns, or exclude/include some") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 16 parser.add_argument('-n', '--number', nargs='?', type=int, default=None,\ | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 17 help="Number of components to keep. If not set, all components are kept") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 18 parser.add_argument('--whiten', action='store_true', help="Whiten the components") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 19 parser.add_argument('-t', '--pca_type', type=str.lower, default='classical', choices=['classical', 'incremental', 'kernel'], | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 20 help="Choose which flavour of PCA to use") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 21 parser.add_argument('-s', '--svd_solver', type=str.lower, default='auto', choices=['auto', 'full', 'arpack', 'randomized'], | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 22 help="Choose the type of svd solver.") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 23 parser.add_argument('-b', '--batch_size', nargs='?', type=int, default=None,\ | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 24 help="The number of samples to use for each batch") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 25 parser.add_argument('-k', '--kernel', type=str.lower, default='linear',\ | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 26 choices=['linear', 'poly', 'rbf', 'sigmoid', 'cosine', 'precomputed'], | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 27 help="Choose the type of kernel.") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 28 parser.add_argument('-g', '--gamma', nargs='?', type=float, default=None, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 29 help='Kernel coefficient for rbf, poly and sigmoid kernels. Ignored by other kernels') | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 30 parser.add_argument('-tol', '--tolerance', type=float, default=0.0, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 31 help='Convergence tolerance for arpack. If 0, optimal value will be chosen by arpack') | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 32 parser.add_argument('-mi', '--max_iter', nargs='?', type=int, default=None,\ | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 33 help="Maximum number of iterations for arpack") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 34 parser.add_argument('-d', '--degree', type=int, default=3,\ | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 35 help="Degree for poly kernels. Ignored by other kernels") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 36 parser.add_argument('-cf', '--coef0', type=float, default=1.0, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 37 help='Independent term in poly and sigmoid kernels') | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 38 parser.add_argument('-e', '--eigen_solver', type=str.lower, default='auto', choices=['auto', 'dense', 'arpack'], | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 39 help="Choose the type of eigen solver.") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 40 parser.add_argument('-o', '--outfile', | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 41 help="Base name for output file (no extension).") | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 42 args = parser.parse_args() | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 43 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 44 usecols = None | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 45 cols = [] | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 46 pca_params = {} | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 47 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 48 if args.columns == 'by_index_number' or args.columns == 'all_but_by_index_number': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 49 usecols = [int(i) for i in args.column_indices.split(',')] | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 50 elif args.columns == 'by_header_name' or args.columns == 'all_but_by_header_name': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 51 usecols = args.column_indices | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 52 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 53 header = 'infer' if args.header else None | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 54 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 55 pca_input = read_columns( | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 56 f=args.infile, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 57 c=usecols, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 58 c_option=args.columns, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 59 sep='\t', | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 60 header=header, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 61 parse_dates=True, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 62 encoding=None, | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 63 index_col=None) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 64 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 65 pca_params.update({'n_components': args.number}) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 66 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 67 if args.pca_type == 'classical': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 68 pca_params.update({'svd_solver': args.svd_solver, 'whiten': args.whiten}) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 69 if args.svd_solver == 'arpack': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 70 pca_params.update({'tol': args.tolerance}) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 71 pca = PCA() | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 72 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 73 elif args.pca_type == 'incremental': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 74 pca_params.update({'batch_size': args.batch_size, 'whiten': args.whiten}) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 75 pca = IncrementalPCA() | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 76 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 77 elif args.pca_type == 'kernel': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 78 pca_params.update({'kernel': args.kernel, 'eigen_solver': args.eigen_solver, 'gamma': args.gamma}) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 79 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 80 if args.kernel == 'poly': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 81 pca_params.update({'degree': args.degree, 'coef0': args.coef0}) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 82 elif args.kernel == 'sigmoid': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 83 pca_params.update({'coef0': args.coef0}) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 84 elif args.kernel == 'precomputed': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 85 pca_input = np.dot(pca_input, pca_input.T) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 86 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 87 if args.eigen_solver == 'arpack': | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 88 pca_params.update({'tol': args.tolerance, 'max_iter': args.max_iter}) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 89 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 90 pca = KernelPCA() | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 91 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 92 print(pca_params) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 93 pca.set_params(**pca_params) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 94 pca_output = pca.fit_transform(pca_input) | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 95 np.savetxt(fname=args.outfile, X=pca_output, fmt='%.4f', delimiter='\t') | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 96 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 97 | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 98 if __name__ == "__main__": | 
| 
2d032cff49eb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2afb24f3c81d625312186750a714d702363012b5"
 bgruening parents: diff
changeset | 99 main() | 
