Mercurial > repos > fubar > plotly_tabular_tool
annotate plotly_tabular_tool/plotlytabular.xml @ 3:51a0c2e0fbdf draft
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
author | fubar |
---|---|
date | Fri, 04 Aug 2023 02:00:28 +0000 |
parents | 08cc7a481af8 |
children | e2d2b080bae3 |
rev | line source |
---|---|
0 | 1 <tool name="plotlytabular" id="plotlytabular" version="3.0"> |
2 <!--Source in git at: https://github.com/fubar2/galaxy_tf_overlay--> | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
3 <!--Created by toolfactory@galaxy.org at 04/08/2023 10:38:13 using the Galaxy Tool Factory.--> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
4 <description>Plotly plot generator for Galaxy tabular data.</description> |
0 | 5 <requirements> |
6 <requirement version="1.5.3" type="package">pandas</requirement> | |
7 <requirement version="5.9.0" type="package">plotly</requirement> | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
8 <requirement version="0.2.1" type="package">python-kaleido</requirement> |
0 | 9 </requirements> |
10 <stdio> | |
11 <exit_code range="1:" level="fatal"/> | |
12 </stdio> | |
13 <version_command><![CDATA[echo "3.0"]]></version_command> | |
14 <command><![CDATA[python | |
15 $runme | |
16 --input_tab | |
17 $input_tab | |
18 --htmlout | |
19 $htmlout | |
20 --xcol | |
21 "$xcol" | |
22 --ycol | |
23 "$ycol" | |
24 --colourcol | |
25 "$colourcol" | |
26 --hovercol | |
27 "$hovercol" | |
28 --title | |
29 "$title" | |
30 --header | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
31 "$header" |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
32 --image_type |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
33 "$outputimagetype"]]></command> |
0 | 34 <configfiles> |
35 <configfile name="runme"><![CDATA[#raw | |
36 | |
37 import argparse | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
38 import shutil |
0 | 39 import sys |
40 import math | |
41 import plotly.express as px | |
42 import pandas as pd | |
43 # Ross Lazarus July 2023 | |
44 # based on various plotly tutorials | |
45 parser = argparse.ArgumentParser() | |
46 a = parser.add_argument | |
47 a('--input_tab',default='') | |
48 a('--header',default='') | |
49 a('--htmlout',default="test_run.html") | |
50 a('--xcol',default='') | |
51 a('--ycol',default='') | |
52 a('--colourcol',default='') | |
53 a('--hovercol',default='') | |
54 a('--title',default='Default plot title') | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
55 a('--image_type',default='short_html') |
0 | 56 args = parser.parse_args() |
1 | 57 isColour = False |
58 isHover = False | |
59 if len(args.colourcol.strip()) > 0: | |
60 isColour = True | |
61 if len(args.hovercol.strip()) > 0: | |
62 isHover = True | |
0 | 63 df = pd.read_csv(args.input_tab, sep='\t') |
64 MAXLEN=35 | |
65 NCOLS = df.columns.size | |
66 defaultcols = ['col%d' % (x+1) for x in range(NCOLS)] | |
1 | 67 testcols = df.columns |
0 | 68 if len(args.header.strip()) > 0: |
69 newcols = args.header.split(',') | |
70 if len(newcols) == NCOLS: | |
71 df.columns = newcols | |
72 else: | |
73 sys.stderr.write('#### Supplied header %s has %d comma delimited header names - does not match the input tabular file %d columns - using col1,...coln' % (args.header, len(newcols), NCOLS)) | |
74 df.columns = defaultcols | |
1 | 75 else: # no header supplied - check for a real one that matches the x and y axis column names |
76 colsok = (args.xcol in testcols) and (args.ycol in testcols) # if they match, probably ok...should use more code and logic.. | |
77 if not colsok: | |
2 | 78 sys.stderr.write('replacing first row of data derived header %s with %s' % (testcols, defaultcols)) |
1 | 79 df.columns = defaultcols |
0 | 80 #df['col11'] = [-math.log(x) for x in df['col11']] # convert so large values reflect statistical surprise |
81 if isHover and isColour: | |
82 fig = px.scatter(df, x=args.xcol, y=args.ycol, color=args.colourcol, hover_name=args.hovercol) | |
83 elif isHover: | |
84 fig = px.scatter(df, x=args.xcol, y=args.ycol, hover_name=args.hovercol) | |
85 elif isColour: | |
86 fig = px.scatter(df, x=args.xcol, y=args.ycol, color=args.colourcol) | |
87 else: | |
88 fig = px.scatter(df, x=args.xcol, y=args.ycol) | |
89 if args.title: | |
90 ftitle=dict(text=args.title, font=dict(size=50)) | |
91 fig.update_layout(title=ftitle) | |
92 for scatter in fig.data: | |
93 scatter['x'] = [str(x)[:MAXLEN] + '..' if len(str(x)) > MAXLEN else x for x in scatter['x']] | |
94 scatter['y'] = [str(x)[:MAXLEN] + '..' if len(str(x)) > MAXLEN else x for x in scatter['y']] | |
95 if len(args.colourcol.strip()) == 0: | |
96 sl = str(scatter['legendgroup']) | |
97 if len(sl) > MAXLEN: | |
98 scatter['legendgroup'] = sl[:MAXLEN] | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
99 if args.image_type == "short_html": |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
100 fig.write_html(args.htmlout, full_html=False, include_plotlyjs='cdn') |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
101 elif args.image_type == "long_html": |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
102 fig.write_html(args.htmlout) |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
103 elif args.image_type == "small_png": |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
104 ht = 768 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
105 wdth = 1024 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
106 fig.write_image('plotly.png', height=ht, width=wdth) |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
107 shutil.copyfile('plotly.png', args.htmlout) |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
108 else: |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
109 ht = 1200 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
110 wdth = 1920 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
111 fig.write_image('plotly.png', height=ht, width=wdth) |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
112 shutil.copyfile('plotly.png', args.htmlout) |
0 | 113 |
114 | |
115 #end raw]]></configfile> | |
116 </configfiles> | |
117 <inputs> | |
118 <param name="input_tab" type="data" optional="false" label="Tabular input file to plot" help="" format="tabular" multiple="false"/> | |
2 | 119 <param name="xcol" type="text" value="sepal_length" label="x axis for plot" help="Use a column name from the header if the file has one, or use one from the list supplied below, or use col1....colN otherwise to select the correct column"/> |
120 <param name="ycol" type="text" value="sepal_width" label="y axis for plot" help="Use a column name from the header if the file has one, or use one from the list supplied below, or use col1....colN otherwise to select the correct column"/> | |
1 | 121 <param name="colourcol" type="text" value="petal_width" label="column containing a groupable variable for colour. Default none." help="Adds a legend so choose wisely "/> |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
122 <param name="hovercol" type="text" value="species" label="columname for hover string" help="Use a column name from the header if the file has one, or use one from the list supplied below, or use col1....colN otherwise to select the correct column"/> |
2 | 123 <param name="title" type="text" value="Iris data" label="Title for the plot" help="Special characters will probably be escaped so do not use them"/> |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
124 <param name="header" type="text" value="" label="Use this comma delimited list of column header names for this tabular file. Default is None when col1...coln will be used" help="The column names supplied for xcol, ycol, hover and colour MUST match either this supplied list, or if none, col1...coln."/> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
125 <param name="outputimagetype" type="select" label="Select the output format for this plot image" help="Small and large png are not interactive but best for many (__gt__10k) points. Stand-alone HTML includes 3MB of javascript. Short form HTML gets it the usual way so can be cut and paste into documents."> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
126 <option value="short_html">Short HTML interactive format</option> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
127 <option value="long_html">Long HTML for stand-alone viewing where network access to libraries is not available.</option> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
128 <option value="large_png">Large (1920x1200) png image - not interactive so hover column ignored</option> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
129 <option value="small_png">small (1024x768) png image - not interactive so hover column ignored</option> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
130 </param> |
0 | 131 </inputs> |
132 <outputs> | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
133 <data name="htmlout" format="html" label="Plotlytabular $title on $input_tab.element_identifier" hidden="false"> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
134 <change_format> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
135 <when input="outputimagetype" format="png" value="small_png"/> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
136 <when input="outputimagetype" format="png" value="large_png"/> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
137 </change_format> |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
138 </data> |
0 | 139 </outputs> |
140 <tests> | |
141 <test> | |
142 <output name="htmlout" value="htmlout_sample" compare="sim_size" delta="5000"/> | |
143 <param name="input_tab" value="input_tab_sample"/> | |
1 | 144 <param name="xcol" value="sepal_length"/> |
145 <param name="ycol" value="sepal_width"/> | |
146 <param name="colourcol" value="petal_width"/> | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
147 <param name="hovercol" value="species"/> |
2 | 148 <param name="title" value="Iris data"/> |
0 | 149 <param name="header" value=""/> |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
150 <param name="outputimagetype" value="short_html"/> |
0 | 151 </test> |
152 </tests> | |
153 <help><![CDATA[ | |
154 | |
2 | 155 This is a generic version of the plotlyblast specific blastn Galaxy search output file plotter. |
0 | 156 |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
157 PNG images are not interactive but best for very large numbers of data points. Hover column will be ignored. |
0 | 158 |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
159 HTML interactive plots are best for a few thousand data points at most because |
0 | 160 |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
161 the hover information becomes uncontrollable with very dense points. |
0 | 162 |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
163 Using the shorter format HTML relies on internet access when viewed, and saves 3MB of javascript being embedded. |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
164 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
165 The long format is useful if potentially viewed offline. |
0 | 166 |
167 | |
168 | |
169 .. class:: warningmark | |
170 | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
171 Long strings in x and y tickmarks WILL BE TRUNCATED if they are too long - ".." is added to indicate truncation - otherwise some plots are squished. |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
172 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
173 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
174 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
175 .. class:: warningmark |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
176 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
177 Columns with very small scientific notation floats will need to be pre-scaled in a way that doesn't confuse plotly.express with their values. |
0 | 178 |
179 | |
180 | |
181 ---- | |
182 | |
183 | |
184 | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
185 This tool can plot an interactive scatter plot with a hover text column specified, that appears when hovering over each data point, to supply useful additional information. |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
186 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
187 It is only useful with a relatively small number of points when they can be distinguished. If many thousands, the density makes them relatively useless so use png output and |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
188 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
189 forget the hover text. |
0 | 190 |
191 | |
192 | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
193 Column names are auto-generated as col1,...coln *unless* a comma separated list of column names is supplied as the header parameter, *or* pandas can |
0 | 194 |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
195 find the values supplied as parameters by the user in the first row of data. This sounds more complex than it is. |
0 | 196 |
197 | |
198 | |
199 For example, using a Galaxy blastn output with 25 columns, the following comma delimited string supplied as the "header" parameter will match the names of each column. | |
200 | |
201 qaccver,saccver,piden,length,mismatch,gapopen,qstart,qend,sstart,send,evalue,bitscore,sallseqid,score,nident,positive,gaps,ppos,qframe,sframe,qseq,sseq,qlen,slen,salltitles | |
202 | |
203 | |
204 | |
205 When a header is supplied, the xcol and other column names must match one of those supplied column names. | |
206 | |
207 So for example, xcol = "qaccver" for the blastn header example rather than xcol = "col1" when no header is supplied. | |
208 | |
209 | |
210 | |
211 Relies on Plotly python code released under the MIT licence: https://github.com/plotly/plotly.py/blob/master/LICENSE.txt | |
212 | |
213 | |
214 | |
215 | |
216 | |
217 ------ | |
218 | |
219 | |
220 Script:: | |
221 | |
222 import argparse | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
223 import shutil |
0 | 224 import sys |
225 import math | |
226 import plotly.express as px | |
227 import pandas as pd | |
228 # Ross Lazarus July 2023 | |
229 # based on various plotly tutorials | |
230 parser = argparse.ArgumentParser() | |
231 a = parser.add_argument | |
232 a('--input_tab',default='') | |
233 a('--header',default='') | |
234 a('--htmlout',default="test_run.html") | |
235 a('--xcol',default='') | |
236 a('--ycol',default='') | |
237 a('--colourcol',default='') | |
238 a('--hovercol',default='') | |
239 a('--title',default='Default plot title') | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
240 a('--image_type',default='short_html') |
0 | 241 args = parser.parse_args() |
1 | 242 isColour = False |
243 isHover = False | |
244 if len(args.colourcol.strip()) > 0: | |
245 isColour = True | |
246 if len(args.hovercol.strip()) > 0: | |
247 isHover = True | |
0 | 248 df = pd.read_csv(args.input_tab, sep='\t') |
249 MAXLEN=35 | |
250 NCOLS = df.columns.size | |
251 defaultcols = ['col%d' % (x+1) for x in range(NCOLS)] | |
1 | 252 testcols = df.columns |
0 | 253 if len(args.header.strip()) > 0: |
254 newcols = args.header.split(',') | |
255 if len(newcols) == NCOLS: | |
256 df.columns = newcols | |
257 else: | |
258 sys.stderr.write('#### Supplied header %s has %d comma delimited header names - does not match the input tabular file %d columns - using col1,...coln' % (args.header, len(newcols), NCOLS)) | |
259 df.columns = defaultcols | |
1 | 260 else: # no header supplied - check for a real one that matches the x and y axis column names |
261 colsok = (args.xcol in testcols) and (args.ycol in testcols) # if they match, probably ok...should use more code and logic.. | |
262 if not colsok: | |
2 | 263 sys.stderr.write('replacing first row of data derived header %s with %s' % (testcols, defaultcols)) |
1 | 264 df.columns = defaultcols |
0 | 265 #df['col11'] = [-math.log(x) for x in df['col11']] # convert so large values reflect statistical surprise |
266 if isHover and isColour: | |
267 fig = px.scatter(df, x=args.xcol, y=args.ycol, color=args.colourcol, hover_name=args.hovercol) | |
268 elif isHover: | |
269 fig = px.scatter(df, x=args.xcol, y=args.ycol, hover_name=args.hovercol) | |
270 elif isColour: | |
271 fig = px.scatter(df, x=args.xcol, y=args.ycol, color=args.colourcol) | |
272 else: | |
273 fig = px.scatter(df, x=args.xcol, y=args.ycol) | |
274 if args.title: | |
275 ftitle=dict(text=args.title, font=dict(size=50)) | |
276 fig.update_layout(title=ftitle) | |
277 for scatter in fig.data: | |
278 scatter['x'] = [str(x)[:MAXLEN] + '..' if len(str(x)) > MAXLEN else x for x in scatter['x']] | |
279 scatter['y'] = [str(x)[:MAXLEN] + '..' if len(str(x)) > MAXLEN else x for x in scatter['y']] | |
280 if len(args.colourcol.strip()) == 0: | |
281 sl = str(scatter['legendgroup']) | |
282 if len(sl) > MAXLEN: | |
283 scatter['legendgroup'] = sl[:MAXLEN] | |
3
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
284 if args.image_type == "short_html": |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
285 fig.write_html(args.htmlout, full_html=False, include_plotlyjs='cdn') |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
286 elif args.image_type == "long_html": |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
287 fig.write_html(args.htmlout) |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
288 elif args.image_type == "small_png": |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
289 ht = 768 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
290 wdth = 1024 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
291 fig.write_image('plotly.png', height=ht, width=wdth) |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
292 shutil.copyfile('plotly.png', args.htmlout) |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
293 else: |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
294 ht = 1200 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
295 wdth = 1920 |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
296 fig.write_image('plotly.png', height=ht, width=wdth) |
51a0c2e0fbdf
Updated with latest ToolFactory with change_format for outputs so can make a png or html and it has an informative label since on $foo can be used.
fubar
parents:
2
diff
changeset
|
297 shutil.copyfile('plotly.png', args.htmlout) |
0 | 298 |
299 ]]></help> | |
300 <citations> | |
301 <citation type="doi">10.1093/bioinformatics/bts573</citation> | |
302 </citations> | |
303 </tool> | |
304 |