I am trying to use distruct.py of FastStructure, but the following instructions keep appearing after many attempts, but I can't find the problem, could someone help me?()
It is my code: distruct.py -K 3 --input=date --output=distruct.svg
The result is:
Traceback (most recent call last):
File "/opt/service/miniconda3/envs/faststructure_env/bin/distruct.py", line 166, in <module>
figure = plot_admixture(admixture, population_indices, population_labels, title)
File "/opt/service/miniconda3/envs/faststructure_env/bin/distruct.py", line 17, in plot_admixture
figure = plot.figure(figsize=(5,3))
File "/opt/service/miniconda3/envs/faststructure_env/lib/python2.7/site-packages/matplotlib/pyplot.py", line 533, in figure
**kwargs)
File "/opt/service/miniconda3/envs/faststructure_env/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 161, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
File "/opt/service/miniconda3/envs/faststructure_env/lib/python2.7/site-packages/matplotlib/backends/_backend_tk.py", line 1046, in new_figure_manager_given_figure
window = Tk.Tk(className="matplotlib")
File "/opt/service/miniconda3/envs/faststructure_env/lib/python2.7/lib-tk/Tkinter.py", line 1819, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
1 answer
I think the issue isn't with distruct.py but with your matplotlib and that maybe you are trying to run this remote (or headless?)? (Are you able to get other plots working in matplotlib where you are running this?) I think others have posted about a similar issue here and here. The latter one says the workaround is to edit your copy of distruct.py file following this:
"To work around this, the following two lines should be included prior to import matplotlib.pyplot as plot:"
import matplotlib as mpl
mpl.use('svg')
Zachary Kenneth Stewart posted a variation on this approach in 2018 in the very detailed post entitled Running fastStructure and associated difficulties.
Details of where you are running local vs. remote, personal machine, what type of machine, etc., are always best to include in such a technical post.
I'd also wonder if there are more modern software targeted at this use case?
This unmaintained project is written in Python 2 and hasn't been updated in roughly 8 years. (There was some move to update it to Python 3, see here and here; however, even those seem stalled for several years now.) Is this is no longer the preferred method in the field to do such analysis?
I note these:
- Summix: A method for detecting and adjusting for population structure in genetic summary data
- StructureSelector: A web-based software to select and visualize the optimal number of clusters using multiple methods
- smartsnp, an r package for fast multivariate analyses of big genomic data
- POPSICLE: A Software Suite to Study Population Structure and Ancestral Determinants of Phenotypes using Whole Genome Sequencing Data
- Fast and Effective Clustering Method for Ancestry Estimation
If fastStructure is to remain the current way, the field should be updating the software as 2 years has now passed since the sunsetting of Python 2 on January 1, 2020. Most pertinent take away from the sunsetting notice: Python 2 is no longer supported.
Log in to answer this question.
no display name and no $DISPLAY environment variable
are you runnning this over SSH ? you need to connect using
ssh -X remoteMachinecommand to use Xwindows.