Skip to content

Commit

Permalink
Merge pull request #85 from goeckslab/barplot-color-opts
Browse files Browse the repository at this point in the history
Expose colormap param for Galaxy scimap stacked_barplot wrapper
  • Loading branch information
alliecreason authored Jul 30, 2024
2 parents 5c324d0 + 3bf0caf commit c39cea5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion tools/scimap/main_macros.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<macros>
<token name="@TOOL_VERSION@">2.1.0</token>
<token name="@VERSION_SUFFIX@">1</token>
<token name="@VERSION_SUFFIX@">2</token>
<token name="@PROFILE@">20.01</token>

<xml name="scimap_requirements">
Expand Down
19 changes: 6 additions & 13 deletions tools/scimap/scimap_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import warnings

import matplotlib.pylab as plt
import matplotlib.pyplot as plt
import numpy as np
import scimap as sm
import seaborn as sns
Expand Down Expand Up @@ -37,9 +37,11 @@ def main(inputs, anndata, output):

# parse list text arguments
for o in options.copy():
opt_list = options.pop(o)
if opt_list:
options[o] = [x.strip() for x in opt_list.split(',')]
opt = options.pop(o)
if o == 'matplotlib_cmap':
matplotlib_cmap = opt
elif opt != "":
options[o] = [x.strip() for x in opt.split(',')]

# add base args into options dict to pass to tool
options['x_axis'] = params['analyses']['x_axis']
Expand All @@ -50,15 +52,6 @@ def main(inputs, anndata, output):

df = sm.pl.stacked_barplot(adata, **options)

# Pick cmap to use
num_phenotypes = len(df.columns) - 1
if num_phenotypes <= 9:
matplotlib_cmap = "Set1"
elif num_phenotypes > 9 and num_phenotypes <= 20:
matplotlib_cmap = plt.cm.tab20
else:
matplotlib_cmap = plt.cm.gist_ncar

# Plotting
sns.set_theme(style="white")
ax = df.plot.bar(stacked=True, cmap=matplotlib_cmap)
Expand Down
25 changes: 16 additions & 9 deletions tools/scimap/scimap_plotting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@
<param argument="subset_yaxis" type="text" value="" optional="true" label="Subset y-axis prior to plotting. Type in a list of categories to include on y-axis" help="Optional. Comma delimited. Default is all categories in y-axis variable" />
<param argument="order_xaxis" type="text" value="" optional="true" label="Type in a list of categories to order to x-axis" help="Optional. Comma delimited. Default ordering is alphabetical" />
<param argument="order_yaxis" type="text" value="" optional="true" label="Type in a list of categories to order to y-axis" help="Optional. Comma delimited. Default ordering is alphabetical" />
<param argument="matplotlib_cmap" type="select" label="Matplotlib colormap to use for y-axis categories" help="See link below for colormaps explanation">
<option value="Pastel1">Pastel1</option>
<option value="Pastel2">Pastel2</option>
<option value="Paired">Paired</option>
<option value="Accent">Accent</option>
<option value="Dark2">Dark2</option>
<option selected="true" value="Set1">Set1</option>
<option value="Set2">Set2</option>
<option value="Set3">Set3</option>
<option value="tab10">tab10</option>
<option value="tab20">tab20</option>
<option value="tab20b">tab20b</option>
<option value="tab20c">tab20c</option>
</param>
</section>
</when>
<when value="voronoi">
Expand Down Expand Up @@ -97,16 +111,9 @@
<![CDATA[
**What it does**
This tool does various single cell spatial analyses with Scimap.
**Input**
AnnData.
**Output**
Anndata with a corresponding key added.
This tool creates stacked barplots or Voronoi plots from single-cell spatial data using Scimap
For the stacked barplot tool, find colormap descriptions here: https://matplotlib.org/stable/users/explain/colors/colormaps.html
]]>
</help>
Expand Down

0 comments on commit c39cea5

Please sign in to comment.