Skip to content

Saving plots results in a prefixed filename, regardless of sc.settings.figdir #1508

@rbpatt2019

Description

@rbpatt2019
  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of scanpy.
  • (optional) I have confirmed this bug exists on the master branch of scanpy.

As far as I can tell, sc.pl.violin always prepends the string "violin" to all save filed, regardless of sc.settings.figdir. This complicates programatically setting the filename for outputs. I've also confirmed this behaviour for sc.pl.scatter, and suspect it holds true for other sc.pl methods.

As an example: I keep all results from my analysis in a results/ directory, with each step having its own subdirectory. Currently, this doesn't seem possible. If I set sc.settings.figdir = ./results, then try to save to, say "qcmetrics/total_counts.png", the code fails as "violinqcmetrics/total_counts.png" does not exist.

A partial work around is to set sc.settings.figdir every time I want to save in a different directory, but this feels quite clunky to me. And it will still result in all my files being prepended with "violin" (or "scatter", etc.), which I'd like to avoid.

Is there any way to disable this prefix on save behaviour?

Minimal code sample (that we can copy&paste without having any data)

sc.settings.figdir = "./"
sc.pl.violin(adata, ["total_counts"], save="results/test_plot.png")
FileNotFoundError: [Errno 2] No such file or directory: 'violinresults/test_plot.png'

Versions


anndata 0.7.5
scanpy 1.6.0
sinfo 0.3.1

IPython 7.19.0
PIL 8.0.1
anndata 0.7.5
backcall 0.2.0
cffi 1.14.4
colorama 0.4.4
cycler 0.10.0
cython_runtime NA
dateutil 2.8.1
decorator 4.4.2
flufl NA
get_version 2.1
h5py 3.1.0
igraph 0.8.3
ipython_genutils 0.2.0
jedi 0.17.2
joblib 0.17.0
kiwisolver 1.3.1
legacy_api_wrap 1.2
leidenalg 0.8.3
llvmlite 0.35.0rc3
matplotlib 3.3.3
mpl_toolkits NA
natsort 7.1.0
numba 0.51.2
numexpr 2.7.1
numpy 1.19.4
packaging 20.4
pandas 1.1.4
parso 0.7.1
pexpect 4.8.0
pickleshare 0.7.5
pkg_resources NA
prompt_toolkit 3.0.8
ptyprocess 0.6.0
pygments 2.7.2
pyparsing 2.4.7
pytz 2020.4
ruamel NA
scanpy 1.6.0
scipy 1.5.4
setuptools_scm NA
sinfo 0.3.1
six 1.15.0
sklearn 0.23.2
storemagic NA
tables 3.6.1
texttable 1.6.3
traitlets 5.0.5
typing_extensions NA
wcwidth 0.2.5
yaml 5.3.1
zc NA

Python 3.8.4 (default, Jul 16 2020, 19:35:12) [GCC 9.3.0]
Linux-5.4.0-54-generic-x86_64-with-glibc2.29
8 logical CPU cores, x86_64

Session information updated at 2020-11-25 11:03

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions