plotting

299 views
Skip to first unread message

Krystyna

unread,
Nov 2, 2011, 11:15:06 AM11/2/11
to dadi-user
Hi,

Dadi and python are very new for me so perhaps this is a very basic
question but i got stuck...

To learn how dadi works i created small fs from SNP data.
I used commands:

dd = Misc.make_data_dict('dadi_S00001-S00003_withoutmRNA.input')
fs = Spectrum.from_data_dict(dd, pop_ids=['COLL', 'PIED'],
projections=[10,10],polarized=False)
spectrum_03 = ()
fs.to_file("spectrum_03")

and it gave me this output

11 11 folded "COLL" "PIED"
11363.36485168657 1383.00956316389 1273.917831664825 1291.745248309472
1273.646575843563 1227.015933750037 1160.733814404221
1064.351691270872 971.2290736476829 997.7928727352081
5098.427559522997 24336.11874029847 3188.843936921223
2933.741525889687 3013.994766410395 3002.5308162724 2914.380091626793
2774.963980406293 2570.819070531817 2396.29863021146 1266.168045490141
0 22050.28059303236 3209.181849601457 2896.886519808334
2985.756010671401 3031.273285332345 2989.535330370694
2885.062093040783 2742.491554240418 1311.860440867486 0 0
19776.88017451061 3089.126256193222 2735.665145575374
2801.040089723188 2859.760247604921 2850.38004434188 2790.82006958377
1341.76571690912 0 0 0 17439.11431348866 3019.176437134291
2638.594983242655 2704.650329041093 2774.558823088856
2793.256528087453 1377.563104564294 0 0 0 0 15173.77033979751
2978.157123816738 2604.26239000266 2670.793439144936 2748.767855455936
1390.523706195035 0 0 0 0 0 12994.60816874209 2935.585696780826
2591.213478243646 2661.85423680071 1377.563104564294 0 0 0 0 0 0
11046.27148093794 2908.161571250678 2599.184280733276 1341.76571690912
0 0 0 0 0 0 0 9561.193663295295 2881.952004283973 1311.860440867486 0
0 0 0 0 0 0 0 8338.141137066508 1266.168045490141 0 0 0 0 0 0 0 0 0
5098.427559522998 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0
0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1
1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1

and then i wanted to plot it

writing:
from dadi import Plotting
import matplotlib
import pylab

dadi.Plotting.plot_single_2d_sfs("spectrum_03", vmin=1, vmax=20000)

But it gave me this error

File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line
6459, in pcolor
X, Y, C = self._pcolorargs('pcolor', *args)
File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line
6304, in _pcolorargs
numRows, numCols = C.shape
ValueError: need more than 0 values to unpack

Am i doing something completely wrong?
Is my spectrum incorrectly prepared?
Or there is problem with the dadi installation?

Will be grateful for any hint,

Krystyna
Department of Evolutionary Biology
Evolutionary Biology Centre
Uppsala University

Gutenkunst, Ryan N - (rgutenk)

unread,
Nov 2, 2011, 11:39:01 AM11/2/11
to dadi...@googlegroups.com
Hello Krystna,

The dadi plotting functions take in a spectrum object, not a reference to
a saved file.

So you can do:
dd = Misc.make_data_dict('dadi_S00001-S00003_withoutmRNA.input')
fs = Spectrum.from_data_dict(dd, pop_ids=['COLL', 'PIED'],
projections=[10,10],polarized=False)
dadi.Plotting.plot_single_2d_sfs(fs, vmin=1, vmax=20000)


If you have a spectrum saved to a file, you can load it back with
fs = dadi.Spectrum.from_file("spectrum_03")

Does this answer your question?

Best,
Ryan
>--
>You received this message because you are subscribed to the Google Groups
>"dadi-user" group.
>To post to this group, send email to dadi...@googlegroups.com.
>To unsubscribe from this group, send email to
>dadi-user+...@googlegroups.com.
>For more options, visit this group at
>http://groups.google.com/group/dadi-user?hl=en.
>
>
>


--
Ryan Gutenkunst
Assistant Professor
Molecular and Cellular Biology
University of Arizona
phone: (520) 626-0569
http://gutengroup.mcb.arizona.edu




Krystyna

unread,
Nov 3, 2011, 7:14:24 AM11/3/11
to dadi-user
Thanks!


On Nov 2, 4:39 pm, "Gutenkunst, Ryan N - (rgutenk)"
<rgut...@email.arizona.edu> wrote:
> Hello Krystna,
>
> The dadi plotting functions take in a spectrum object, not a reference to
> a saved file.
>
> So you can do:
> dd = Misc.make_data_dict('dadi_S00001-S00003_withoutmRNA.input')
> fs = Spectrum.from_data_dict(dd, pop_ids=['COLL', 'PIED'],
> projections=[10,10],polarized=False)
> dadi.Plotting.plot_single_2d_sfs(fs, vmin=1, vmax=20000)
>
> If you have a spectrum saved to a file, you can load it back with
> fs = dadi.Spectrum.from_file("spectrum_03")
>
> Does this answer your question?
>
> Best,
> Ryan
>
> phone:(520) 626-0569begin_of_the_skype_highlighting            (520) 626-0569      http://gutengroup.mcb.arizona.edu
Reply all
Reply to author
Forward
0 new messages