Make_plots.py problems

110 views
Skip to first unread message

chichi zhao

unread,
Sep 18, 2023, 2:43:34 AM9/18/23
to dadi-user
Hello, dadi-users. recent days, I got the problem when I try ploting the dadi 3d plots. The main question of this is the problems for using the matplotlib/color.py 

  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/matplotlib/colors.py", line 1724, in inverse
    raise ValueError("Invalid vmin or vmax")
ValueError: Invalid vmin or vmax

 The main command line that I used are the following 
"
Plotting_Functions.Plot_3D(fs, model_fit, prefix, "sim_split_sym_mig_all",vmin_val=None)
"
in my perspective, I think it may relative to some factors (python version)
IF YOU HAVE ANY IDEA ABOUT IT , APPRECIATE IT, THANKS FOR HELP

the following are the output informations.

"
============================================================================

Data for site frequency spectrum:

Projection: [80, 34, 72]
Sample sizes: [80 34 72]
Sum of SFS: 1082329.0

============================================================================

============================================================================
Fitting model 'refugia_adj_3' to empirical data...
============================================================================

Input parameters = [0.44700684, 0.38339181, 3.09443241, 2.76340481, 7.56458127, 0.16392666, 28.91735005, 0.1107808, 0.49203038, 8.86842841]

WARNING:Numerics:Extrapolation may have failed. Check resulting frequency spectrum for unexpected results.
1082326.0 1082329.0
WARNING:Inference:Model is masked in some entries where data is not.
WARNING:Inference:Number of affected entries is 104538. Sum of data in those entries is 1.08233e+06:
                        Likelihood = -23.9
                        AIC = 67.8
                        Theta = 9,657.73
                        Chi-Squared = 5,256.43

============================================================================
Creating plots
============================================================================


Plotting East_Middle_West_refugia_adj_3.pdf

NOTE - CLOSE PLOT TO ADVANCE.
Traceback (most recent call last):
  File "/home/chichi/data/china/china_old/easysfs/dadi_pipeline/Plotting2/Make_Plots.py", line 255, in <module>
    Plotting_Functions.Plot_3D(fs, model_fit, prefix, "refugia_adj_3",vmin_val=None)
  File "/home/chichi/data/china/china_old/easysfs/dadi_pipeline/Plotting2/Plotting_Functions.py", line 127, in Plot_3D
    dadi.Plotting.plot_3d_comp_multinom(model_fit, fs, resid_range = 3)
  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/dadi/Plotting.py", line 534, in plot_3d_comp_multinom
    plot_3d_comp_Poisson(model, data, vmin=vmin, vmax=vmax,
  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/dadi/Plotting.py", line 643, in plot_3d_comp_Poisson
    plot_single_2d_sfs(marg_data, vmin=vmin, vmax=vmax, pop_ids=curr_ids[0],
  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/dadi/Plotting.py", line 182, in plot_single_2d_sfs
    cb = ax.figure.colorbar(mappable, extend=extend, format=format)
  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/matplotlib/figure.py", line 1293, in colorbar
    cb = cbar.Colorbar(cax, mappable, **cb_kw)
  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/matplotlib/_api/deprecation.py", line 384, in wrapper
    return func(*inner_args, **inner_kwargs)
  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/matplotlib/colorbar.py", line 402, in __init__
    self._reset_locator_formatter_scale()
  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/matplotlib/colorbar.py", line 1173, in _reset_locator_formatter_scale
    self._process_values()
  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/matplotlib/colorbar.py", line 1111, in _process_values
    b = self.norm.inverse(b)
  File "/home/chichi/anaconda3/envs/bio/lib/python3.10/site-packages/matplotlib/colors.py", line 1724, in inverse
    raise ValueError("Invalid vmin or vmax")
ValueError: Invalid vmin or vmax
"

Ryan Gutenkunst

unread,
Sep 19, 2023, 5:36:35 PM9/19/23
to dadi...@googlegroups.com
Hello Chichi,

You’re using the Portik pipeline it appears, which I’m not familiar with all the details of. That said, my guess is that the method is failing due to passing vein_val=None. You likely need to pick a value for vmin.

Best,
Ryan
> --
> You received this message because you are subscribed to the Google Groups "dadi-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dadi-user+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dadi-user/766acded-e22d-4baf-8d26-d162464e5fb5n%40googlegroups.com.

Niloofar Alaei Kakhki

unread,
Aug 26, 2024, 12:31:25 PM8/26/24
to dadi-user
Hi all, I also have the same problem with plotting. 

I got his error message: 

Fitting model 'sym_mig' to empirical data...
============================================================================

Input parameters = [9.5185, 1.9965, 0.7604, 0.5057]

                        Likelihood = -171,473.62
                        AIC = 342,955.24
                        Theta = 94,929.83
                        Chi-Squared = 1,388,182.89

============================================================================
Creating plots
============================================================================


Plotting pop0_pop1_sym_mig.pdf


NOTE - CLOSE PLOT TO ADVANCE.
Traceback (most recent call last):
  File "Make_Plots_niloo.py", line 171, in <module>
    Plotting_Functions.Plot_2D(fs, model_fit, prefix, "sym_mig")
  File "/gpfs1/data/oenanthe/niloo_oenanthe/work_10-05-2024/bunting/dadi/dadi_pipeline/Plotting/Plotting_Functions.py", line 112, in Plot_2D
    dadi.Plotting.plot_2d_comp_multinom(model_fit, fs, resid_range = 3)
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/dadi/Plotting.py", line 308, in plot_2d_comp_multinom
    adjust=adjust,show=show)
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/dadi/Plotting.py", line 469, in plot_2d_comp_Poisson
    pop_ids=data_pop_ids, colorbar=False)
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/dadi/Plotting.py", line 180, in plot_single_2d_sfs

    cb = ax.figure.colorbar(mappable, extend=extend, format=format)
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/matplotlib/figure.py", line 2215, in colorbar
    cb = cbar.colorbar_factory(cax, mappable, **cb_kw)
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/matplotlib/colorbar.py", line 1640, in colorbar_factory
    cb = Colorbar(cax, mappable, **kwargs)
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/matplotlib/colorbar.py", line 1183, in __init__
    ColorbarBase.__init__(self, ax, **kw)
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/matplotlib/colorbar.py", line 460, in __init__
    self.draw_all()
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/matplotlib/colorbar.py", line 483, in draw_all
    self._process_values()
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/matplotlib/colorbar.py", line 932, in _process_values
    b = self.norm.inverse(self._uniform_y(self.cmap.N + 1))
  File "/home/alaeikak/anaconda3/lib/python3.7/site-packages/matplotlib/colors.py", line 1127, in inverse
    return vmin * np.ma.power((vmax / vmin), val)
ZeroDivisionError: float division by zero



Does some one have any idea why I got this error? 

The best and thanks for your help
Niloo 

Ryan Gutenkunst

unread,
Aug 28, 2024, 1:49:49 PM8/28/24
to dadi...@googlegroups.com
Hello Niloo,

It looks like you’re using some sort of external pipeline to drive dadi, so I can’t see exactly what’s causing this error. But the issues is in plotting, most likely with how the lower-bound on plotted allele counts is set (vmin). Since we’re plotting on a log scale, vmin cannot be set to zero. I don’t know if that’s something you can adjust within this pipeline, but doing that should fix the problem.

Best,
Ryan

Reply all
Reply to author
Forward
0 new messages