# HG changeset patch
# User bgruening
# Date 1537703518 14400
# Node ID 2da0fddf2bdbe8191a23c01b8bb30587ac280d90
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/plotly_parallel_coordinates_plot commit 93fcfe0fa6a64246d13e0fb7e35a357985b02465
diff -r 000000000000 -r 2da0fddf2bdb paracords_plot.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paracords_plot.py	Sun Sep 23 07:51:58 2018 -0400
@@ -0,0 +1,83 @@
+import sys
+import argparse
+import plotly
+import plotly.graph_objs as go
+import pandas as pd
+
+def main(infile, col_dimensions, col_color):
+    """
+    Produce an interactive paracords plotting html
+    Args:
+        infile: str, tabular file
+        col_dimensions: str, comma separated index numbers. For example: "3,4,5"
+        col_color: str, index number
+    """
+    df = pd.read_csv(infile, sep='\t', parse_dates=True)
+
+    dimensions = []
+    col_dimensions = [int(x)-1 for x in col_dimensions.split(',')]
+    for col in col_dimensions:
+        values = df[df.columns[col]]
+        if all(type(e) is int for e in values ):
+            dimensions.append(
+                dict(   values = values,
+                        tickformat = ",.2r",
+                        label = df.columns[col])
+            )
+        elif all(type(e) is float for e in values ):
+            dimensions.append(
+                dict(   values = values,
+                        tickformat = "g",
+                        label = df.columns[col])
+            )
+        else:
+            unique_values = list(set(values))
+            dimensions.append(
+                dict(   range = [0, len(unique_values)-1],
+                        tickvals = list(range(len(unique_values))),
+                        ticktext = [str(e) for e in unique_values],
+                        values = list(map(lambda e: unique_values.index(e), values )),
+                        label = df.columns[col])
+            )
+
+    col_color = int(col_color) - 1
+    colors = df[df.columns[col_color]]
+    if all(type(e) is int for e in colors ):
+        tickformat = ",.2r"
+    elif all(type(e) is float for e in colors ):
+        tickformat = "g"
+    else:
+        sys.exit("Error: the column for coloring must contain all numerical values!")
+
+    dimensions.append(
+        dict(
+                values = colors,
+                tickformat = tickformat,
+                label = df.columns[col_color]
+        )
+    )
+
+    line = dict(
+                color = colors,
+                colorscale = 'Jet',
+                showscale = True,
+                reversescale = True
+    )
+
+    data = [
+            go.Parcoords(
+                line = line,
+                dimensions = dimensions
+            )
+    ]
+
+    plotly.offline.plot(data, filename = "output.html", auto_open=False)
+
+if __name__ == "__main__":
+    aparser = argparse.ArgumentParser()
+    aparser.add_argument( "-i", "--input", dest="infile", required=True)
+    aparser.add_argument( "-d", "--col_dimensions", dest="col_dimensions")
+    aparser.add_argument( "-c", "--col_color", dest="col_color")
+    args = aparser.parse_args()
+
+    main(args.infile, args.col_dimensions, args.col_color)
\ No newline at end of file
diff -r 000000000000 -r 2da0fddf2bdb paracords_plot.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paracords_plot.xml	Sun Sep 23 07:51:58 2018 -0400
@@ -0,0 +1,50 @@
+
+    of tabular data
+    
+        python
+        pandas
+        plotly
+    
+    echo $version
+    
+    
+    
+        
+        
+        
+    
+
+    
+        
+    
+    
+        
+            
+            
+            
+            
+        
+        
+            
+            
+            
+            
+        
+    
+    `_ from a tabular file.
+Multiple columns are chosen for dimensions and a single column for coloring. The plot is buried in a html file which
+provides rich interactive features. Image can be saved in various format, such as 'png', 'svg', 'jpeg' and so on.
+
+
+    ]]>
+    
+
diff -r 000000000000 -r 2da0fddf2bdb test-data/parcoords01.tabular
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/parcoords01.tabular	Sun Sep 23 07:51:58 2018 -0400
@@ -0,0 +1,21 @@
+mean_fit_time	mean_score_time	mean_test_score	param_estimator__C	param_preprocessing_2__k	params	rank_test_score	split0_test_score	split1_test_score	split2_test_score	std_fit_time	std_score_time	std_test_score
+0.0008893807729085287	0.0	0.0	1	-1	{u'estimator__C': 1, u'preprocessing_2__k': -1}	17	0.0	0.0	0.0	0.0002001698111627413	0.0	0.0
+0.005897998809814453	0.0006273587544759115	0.7104173862063515	1	3	{u'estimator__C': 1, u'preprocessing_2__k': 3}	13	0.7343996871246798	0.7417527475529206	0.655099723941454	0.0011778246691045516	0.000130497581592697	0.0392305127271727
+0.0043866634368896484	0.0007084210713704427	0.7727810607699421	1	5	{u'estimator__C': 1, u'preprocessing_2__k': 5}	9	0.771515656506971	0.7527052831977578	0.7941222426050976	0.0002401647992627138	0.00024091292632273708	0.01693206165038913
+0.0042876402537028	0.000507354736328125	0.7884200773575789	1	7	{u'estimator__C': 1, u'preprocessing_2__k': 7}	3	0.8337293212274764	0.7482926039856558	0.7832383068596044	0.0002709806131418131	2.436617660189741e-05	0.03507131992939495
+0.004957675933837891	0.0005903244018554688	0.7938837807353147	1	9	{u'estimator__C': 1, u'preprocessing_2__k': 9}	1	0.8426657572705988	0.7542580823607264	0.784727502574619	0.00020288510531872486	2.4974464706042437e-05	0.03666839982018526
+0.0009076595306396484	0.0	0.0	10	-1	{u'estimator__C': 10, u'preprocessing_2__k': -1}	17	0.0	0.0	0.0	8.050432012007906e-05	0.0	0.0
+0.008490721384684244	0.0007415612538655599	0.6964967631489266	10	3	{u'estimator__C': 10, u'preprocessing_2__k': 3}	14	0.7446910527620116	0.6904780454148434	0.6543211912699249	0.001563277277825898	0.0001715582888325998	0.03713800110306298
+0.005631049474080403	0.000587622324625651	0.7548120191889218	10	5	{u'estimator__C': 10, u'preprocessing_2__k': 5}	10	0.7716860817215373	0.6864563697215776	0.8062936061236508	0.0003878558746535774	0.0001247907126998644	0.05035733178586511
+0.004897356033325195	0.0005120436350504557	0.7816262883430569	10	7	{u'estimator__C': 10, u'preprocessing_2__k': 7}	6	0.8502810525482809	0.695034968349346	0.7995628441315439	0.00010891963452719922	4.032274655021451e-05	0.06463552526766699
+0.006504058837890625	0.0006016095479329427	0.7892707238057951	10	9	{u'estimator__C': 10, u'preprocessing_2__k': 9}	2	0.8566443610793398	0.7030451244270151	0.8081226859110302	0.000614871577463233	4.3557942685511835e-05	0.06410787123516704
+0.0016646385192871094	0.0	0.0	100	-1	{u'estimator__C': 100, u'preprocessing_2__k': -1}	17	0.0	0.0	0.0	0.0007425448564300234	0.0	0.0
+0.01219940185546875	0.0010093053181966145	0.6936822719445683	100	3	{u'estimator__C': 100, u'preprocessing_2__k': 3}	15	0.7477066644894652	0.6812918848407985	0.6520482665034413	0.005464220817015395	0.00042272585996138215	0.04002310620753206
+0.011892954508463541	0.0010009606679280598	0.751406681938562	100	5	{u'estimator__C': 100, u'preprocessing_2__k': 5}	12	0.768624772882289	0.6797852691816515	0.8058100037517455	0.0007243971607516297	0.00022965706673197417	0.052870315695895634
+0.015247027079264322	0.001065651575724284	0.780353600621928	100	7	{u'estimator__C': 100, u'preprocessing_2__k': 7}	7	0.8501332206882686	0.6869532193186081	0.8039743618589076	0.0016621871966479448	0.00041067567761326383	0.0686798538282826
+0.024774789810180664	0.000926971435546875	0.7862118205161561	100	9	{u'estimator__C': 100, u'preprocessing_2__k': 9}	4	0.8575095848829983	0.693096967262038	0.8080289094034317	0.007803944173115239	0.00019574615459401132	0.06887121427650549
+0.0009613037109375	0.0	0.0	1000	-1	{u'estimator__C': 1000, u'preprocessing_2__k': -1}	17	0.0	0.0	0.0	0.0002434119417931474	0.0	0.0
+0.025811036427815754	0.0009682973225911459	0.6926668993618743	1000	3	{u'estimator__C': 1000, u'preprocessing_2__k': 3}	16	0.7494954690157997	0.677124152164965	0.6513810769048582	0.006503047963414654	0.0002558118647454582	0.041535456561393944
+0.08626842498779297	0.0014065901438395183	0.7514165183827944	1000	5	{u'estimator__C': 1000, u'preprocessing_2__k': 5}	11	0.7684665422059135	0.6797430247352857	0.806039988207184	0.035840170189150804	0.00041956478276977655	0.052951287235421717
+0.21045462290445963	0.0009483496348063151	0.7800159337722933	1000	7	{u'estimator__C': 1000, u'preprocessing_2__k': 7}	8	0.8495071574714655	0.6864874567307644	0.8040531871146499	0.17032759330924754	0.0004962102711314027	0.06868865927055896
+0.18308266003926596	0.0009226799011230469	0.7854772046965829	1000	9	{u'estimator__C': 1000, u'preprocessing_2__k': 9}	5	0.8569025232106273	0.6903587533500763	0.8091703375290451	0.12143508018264616	0.00022723913124792145	0.07002490141563245
diff -r 000000000000 -r 2da0fddf2bdb test-data/parcoords02.tabular
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/parcoords02.tabular	Sun Sep 23 07:51:58 2018 -0400
@@ -0,0 +1,3 @@
+mean_fit_time	mean_score_time	mean_test_score	param_estimator__dual	param_estimator__penalty	params	rank_test_score	split0_test_score	split1_test_score	split2_test_score	std_fit_time	std_score_time	std_test_score
+0.6255233287811279	0.0008620421091715494	0.968186638388123	False	l1	{u'estimator__dual': False, u'estimator__penalty': 'l1'}	2	0.9697933227344993	0.9697933227344993	0.964968152866242	0.011841861534965003	0.00024772262760403203	0.0022740031457860075
+0.05705531438191732	0.0006122589111328125	0.9684517497348887	False	l2	{u'estimator__dual': False, u'estimator__penalty': 'l2'}	1	0.9697933227344993	0.9705882352941176	0.964968152866242	0.008102407793155115	2.7493704443217997e-05	0.00248262907456837
diff -r 000000000000 -r 2da0fddf2bdb test-data/parcoords_plot01.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/parcoords_plot01.html	Sun Sep 23 07:51:58 2018 -0400
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff -r 000000000000 -r 2da0fddf2bdb test-data/parcoords_plot02.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/parcoords_plot02.html	Sun Sep 23 07:51:58 2018 -0400
@@ -0,0 +1,7 @@
+
\ No newline at end of file