Previous changeset 12:3bd31820d63e (2018-07-01) Next changeset 14:6bbf5cb20652 (2018-07-10) |
Commit message:
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5d71c93a3dd804b1469852240a86021ab9130364 |
modified:
main_macros.xml numeric_clustering.xml |
b |
diff -r 3bd31820d63e -r 40f3318b61c2 main_macros.xml --- a/main_macros.xml Sun Jul 01 03:19:41 2018 -0400 +++ b/main_macros.xml Mon Jul 09 14:32:01 2018 -0400 |
[ |
@@ -64,6 +64,45 @@ return new_selector </token> + <token name="@GET_X_y_FUNCTION@"> +def get_X_y(params, file1, file2): + input_type = params["selected_tasks"]["selected_algorithms"]["input_options"]["selected_input"] + if input_type=="tabular": + header = 'infer' if params["selected_tasks"]["selected_algorithms"]["input_options"]["header1"] else None + column_option = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_1"]["selected_column_selector_option"] + if column_option in ["by_index_number", "all_but_by_index_number", "by_header_name", "all_but_by_header_name"]: + c = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_1"]["col1"] + else: + c = None + X = read_columns( + file1, + c = c, + c_option = column_option, + sep='\t', + header=header, + parse_dates=True + ) + else: + X = mmread(open(file1, 'r')) + + header = 'infer' if params["selected_tasks"]["selected_algorithms"]["input_options"]["header2"] else None + column_option = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_2"]["selected_column_selector_option2"] + if column_option in ["by_index_number", "all_but_by_index_number", "by_header_name", "all_but_by_header_name"]: + c = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_2"]["col2"] + else: + c = None + y = read_columns( + file2, + c = c, + c_option = column_option, + sep='\t', + header=header, + parse_dates=True + ) + y=y.ravel() + return X, y + </token> + <xml name="python_requirements"> <requirements> <requirement type="package" version="2.7">python</requirement> @@ -81,34 +120,6 @@ <!--Generic interface--> - <xml name="train_loadConditional" token_train="tabular" token_data="tabular" token_model="txt"> - <conditional name="selected_tasks"> - <param name="selected_task" type="select" label="Select a Classification Task"> - <option value="train" selected="true">Train a model</option> - <option value="load">Load a model and predict</option> - </param> - <when value="load"> - <param name="infile_model" type="data" format="@MODEL@" label="Models" help="Select a model file."/> - <param name="infile_data" type="data" format="@DATA@" label="Data (tabular)" help="Select the dataset you want to classify."/> - <conditional name="prediction_options"> - <param name="prediction_option" type="select" label="Select the type of prediction"> - <option value="predict">Predict class labels</option> - <option value="advanced">Include advanced options</option> - </param> - <when value="predict"> - </when> - <when value="advanced"> - </when> - </conditional> - </when> - <when value="train"> - <param name="infile_train" type="data" format="@TRAIN@" label="Training samples (tabular)"/> - <conditional name="selected_algorithms"> - <yield /> - </conditional> - </when> - </conditional> - </xml> <xml name="sl_Conditional" token_train="tabular" token_data="tabular" token_model="txt"> <conditional name="selected_tasks"> |
b |
diff -r 3bd31820d63e -r 40f3318b61c2 numeric_clustering.xml --- a/numeric_clustering.xml Sun Jul 01 03:19:41 2018 -0400 +++ b/numeric_clustering.xml Mon Jul 09 14:32:01 2018 -0400 |
[ |
b'@@ -22,6 +22,8 @@\n from sklearn import metrics\n from scipy.io import mmread\n \n+@COLUMNS_FUNCTION@\n+\n input_json_path = sys.argv[1]\n params = json.load(open(input_json_path, "r"))\n \n@@ -37,17 +39,22 @@\n data_matrix = mmread(open("$infile", \'r\'))\n #else:\n data = pandas.read_csv("$infile", sep=\'\\t\', header=0, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False )\n-\n-start_column = $input_types.start_column\n-end_column = $input_types.end_column\n-\n-if end_column and start_column:\n- if end_column >= start_column:\n- data_matrix = data.values[:, start_column-1:end_column]\n- else:\n- data_matrix = data.values\n+header = \'infer\' if params["input_types"]["header"] else None\n+column_option = params["input_types"]["column_selector_options"]["selected_column_selector_option"]\n+if column_option in ["by_index_number", "all_but_by_index_number", "by_header_name", "all_but_by_header_name"]:\n+ c = params["input_types"]["column_selector_options"]["col"]\n else:\n- data_matrix = data.values\n+ c = None\n+data_matrix = read_columns(\n+ "$infile",\n+ c = c,\n+ c_option = column_option,\n+ sep=\'\\t\',\n+ header=header,\n+ parse_dates=True,\n+ encoding=None,\n+ tupleize_cols=False\n+)\n #end if\n \n prediction = cluster_object.fit_predict( data_matrix )\n@@ -82,8 +89,10 @@\n </when>\n <when value="tabular">\n <param name="infile" type="data" format="tabular" label="Data file with numeric values"/>\n- <param name="start_column" type="data_column" data_ref="infile" optional="True" label="Select a subset of data. Start column:" />\n- <param name="end_column" type="data_column" data_ref="infile" optional="True" label="End column:" />\n+ <param name="header" type="boolean" optional="true" truevalue="booltrue" falsevalue="boolfalse" checked="True" label="Does the dataset contain header:" />\n+ <conditional name="column_selector_options">\n+ <expand macro="samples_column_selector_options" col_name="col" multiple="true" infile="infile"/>\n+ </conditional>\n <!--expand macro="clustering_algorithms_options"-->\n <conditional name="algorithm_options">\n <param name="selected_algorithm" type="select" label="Clustering Algorithm">\n@@ -168,8 +177,7 @@\n <param name="infile" value="numeric_values.tabular" ftype="tabular"/>\n <param name="selected_input_type" value="tabular"/>\n <param name="selected_algorithm" value="KMeans"/>\n- <param name="start_column" value="2" />\n- <param name="end_column" value="4" />\n+ <param name="col" value="2,3,4" />\n <param name="n_clusters" value="4" />\n <param name="init" value="k-means++" />\n <param name="random_state" value="100"/>\n@@ -179,8 +187,7 @@\n <param name="infile" value="numeric_values.tabular" ftype="tabular"/>\n <param name="selected_algorithm" value="KMeans"/>\n <param name="selected_input_type" value="tabular"/>\n- <param name="start_column" value="2" />\n- <param name="end_column" value="4" />\n+ <param name="col" value="2,3,4" />\n <param name="n_clusters" value="4" />\n <param name="init" value="random" />\n <param name="random_state" value="100"/>\n@@ -190,8 +197,7 @@\n <param name="infile" value="numeric_values.tabular" ftype="tabular"/>\n <param name="selected_algorithm" value="DBSCAN"/>\n <param name="selected_input_type" value="tabular"/>\n- <param name="start_column" value="2" />\n- <param name="end_column" value="4" />\n+ <param name="col" value="2,3,4" />\n <param name="algorithm" value="kd_tree"/>\n <param name="leaf_size" value="10"/>\n <param name="eps" value="1.0"/>\n@@ -201,8 +207,7 @@\n '..b' />\n <param name="cluster_all" value="False"/>\n <output name="outfile" file="cluster_result09.txt"/>\n </test>\n@@ -257,8 +257,7 @@\n <param name="infile" value="numeric_values.tabular" ftype="tabular"/>\n <param name="selected_algorithm" value="AgglomerativeClustering"/>\n <param name="selected_input_type" value="tabular"/>\n- <param name="start_column" value="2" />\n- <param name="end_column" value="4" />\n+ <param name="col" value="2,3,4" />\n <param name="affinity" value="euclidean"/>\n <param name="linkage" value="average"/>\n <param name="n_clusters" value="4"/>\n@@ -268,8 +267,7 @@\n <param name="infile" value="numeric_values.tabular" ftype="tabular"/>\n <param name="selected_algorithm" value="AgglomerativeClustering"/>\n <param name="selected_input_type" value="tabular"/>\n- <param name="start_column" value="2" />\n- <param name="end_column" value="4" />\n+ <param name="col" value="2,3,4" />\n <param name="linkage" value="complete"/>\n <param name="n_clusters" value="4"/>\n <output name="outfile" file="cluster_result11.txt"/>\n@@ -278,8 +276,7 @@\n <param name="infile" value="numeric_values.tabular" ftype="tabular"/>\n <param name="selected_algorithm" value="SpectralClustering"/>\n <param name="selected_input_type" value="tabular"/>\n- <param name="start_column" value="2" />\n- <param name="end_column" value="4" />\n+ <param name="col" value="2,3,4" />\n <param name="eigen_solver" value="arpack"/>\n <param name="n_neighbors" value="12"/>\n <param name="n_clusters" value="4"/>\n@@ -291,8 +288,7 @@\n <param name="infile" value="numeric_values.tabular" ftype="tabular"/>\n <param name="selected_algorithm" value="SpectralClustering"/>\n <param name="selected_input_type" value="tabular"/>\n- <param name="start_column" value="2" />\n- <param name="end_column" value="4" />\n+ <param name="col" value="2,3,4" />\n <param name="assign_labels" value="discretize"/>\n <param name="random_state" value="100"/>\n <param name="degree" value="2"/>\n@@ -302,8 +298,7 @@\n <param name="infile" value="numeric_values.tabular" ftype="tabular"/>\n <param name="selected_algorithm" value="MiniBatchKMeans"/>\n <param name="selected_input_type" value="tabular"/>\n- <param name="start_column" value="2" />\n- <param name="end_column" value="4" />\n+ <param name="col" value="2,3,4" />\n <param name="tol" value="0.5"/>\n <param name="random_state" value="100"/>\n <output name="outfile" file="cluster_result14.txt"/>\n@@ -313,8 +308,7 @@\n <param name="selected_algorithm" value="MiniBatchKMeans"/>\n <param name="selected_input_type" value="tabular"/>\n <param name="n_init" value="5"/>\n- <param name="start_column" value="2" />\n- <param name="end_column" value="4" />\n+ <param name="col" value="2,3,4" />\n <param name="batch_size" value="10"/>\n <param name="n_clusters" value="4"/>\n <param name="random_state" value="100"/>\n@@ -325,8 +319,7 @@\n <param name="infile" value="numeric_values.tabular" ftype="tabular"/>\n <param name="selected_algorithm" value="KMeans"/>\n <param name="selected_input_type" value="tabular"/>\n- <param name="start_column" value="1" />\n- <param name="end_column" value="1" />\n+ <param name="col" value="1" />\n <param name="n_clusters" value="4" />\n <param name="random_state" value="100"/>\n <output name="outfile" file="cluster_result16.txt"/>\n' |