2D PCoA plot - Different colors for different samples

160 views
Skip to first unread message

Maria Vittoria Marra

unread,
Mar 24, 2017, 4:55:16 PM3/24/17
to Qiime 1 Forum
Dear all,

I am trying to modify the colours of my samples on a 2D PCoA plot that I produced running the script make_2d_plots.py in MacQIIME 1.9.1. To do that I have used the attached prefs file, but I have got the error 'EOL while scanning string literal'. More precisely, the error is shown in the screenshot that is also attached. Can you please help me to understand why this happened?

Thank you very much,

Maria Vittoria
Prefs_out.txt
Screen Shot 2017-03-15 at 16.51.25.png

abir...@gmail.com

unread,
Mar 25, 2017, 10:33:11 PM3/25/17
to qiime...@googlegroups.com
Hi, Maria--
This is a tricky problem until you know what to look for, but after that it is a quick fix :)  Is it possible you edited this file in a program like Word, or at least something more "sophisticated" than a simple text editor?  The reason I ask is that at some point, non-standard ("smart", angled) single quote marks got introduced into the file. I've uploaded a picture of how this file looks in a basic text editor (TextEdit on Mac); this picture shows showing a little snippet of a line that starts with a "real" quote mark but then has several non-standard ones after it.  

Although we as humans see these different-shaped quote marks as interchangeable, the computer does NOT, so the software gets very upset because it thinks that some opening single quote, somewhere in the file, wasn't correctly paired with a closing one.  The easy solution is just to replace every angled quote with a "regular" single quote, which I've done for you in the uploaded "Prefs_out_fixed_quotes.txt" file; I can confirm this file no longer produces the "EOL" error you saw.

If you need to do more editing of such prefs files in the future, I suggest you use the simplest text editor you can get your hands on so it doesn't cause you problems by silently replacing what you actually type with "smart" quotes (or, similarly, "smart" dashes, which often get inserted when one is just trying to type a hyphen, and cause similar problems in files read by software).

Best,
Amanda
ScreenShot2017-03-25.png
Prefs_out_fixed_quotes.txt

Maria Vittoria Marra

unread,
Apr 4, 2017, 1:36:06 PM4/4/17
to Qiime 1 Forum
Hi Amanda,

thank you very much for your very informative answer and for editing the file! It is true, the file no longer produces the "EOL" error, but now it is giving me a new one, i.e. NameError: name 'MIIG0966a' is not defined. Do you know what is producing now this further issue?

All the best,

Maria Vittoria

Evan Bolyen

unread,
Apr 4, 2017, 6:38:47 PM4/4/17
to Qiime 1 Forum
Hi Maria,

There was just one small thing missing in your prefs file. The sample names need to be quoted, which I've done in the attached prefs file.

Thanks!
-Evan
prefs_revised.txt

Maria Vittoria Marra

unread,
Apr 5, 2017, 11:52:13 AM4/5/17
to Qiime 1 Forum
Hi Evan,

thank you very much for your help! Unfortunately it looks like there is still a problem because with the file that you kindly edited for me now I get the following error: 

Traceback (most recent call last):

  File "/macqiime/anaconda/bin/make_2d_plots.py", line 242, in <module>

    main()

  File "/macqiime/anaconda/bin/make_2d_plots.py", line 238, in main

    label_color, opts.scree, opts.pct_variation_below_one)

  File "/macqiime/anaconda/lib/python2.7/site-packages/qiime/make_2d_plots.py", line 551, in generate_2d_plots

    groups_and_colors = list(groups_and_colors)

  File "/macqiime/anaconda/lib/python2.7/site-packages/qiime/colors.py", line 220, in iter_color_groups

    get_group_colors(groups, colors)

  File "/macqiime/anaconda/lib/python2.7/site-packages/qiime/colors.py", line 308, in get_group_colors

    start_color, end_color = map(get_color, colors)

ValueError: too many values to unpack


Do you know what is causing this further error now?

Evan Bolyen

unread,
Apr 5, 2017, 7:10:59 PM4/5/17
to Qiime 1 Forum
Hi Maria,

It seems the structure of the prefs file is wrong (I think you have sample-ids where RGB values go, I'm sorry I'm not very familiar with the format itself).

At this point it is probably a better idea to regenerate your prefs file with `make_prefs_file.py` and use that prefs file with `make_2d_plots.py`.

If the available options for that do not suit your needs, please let us know a little more about what you are looking to see generated by `make_2d_plots.py`

Thanks
-Evan

Maria Vittoria Marra

unread,
Apr 24, 2017, 1:51:02 PM4/24/17
to Qiime 1 Forum
Hi Evan,

thank you very much again for your help and sorry for my late answer. Actually I had produced the prefs file that I have been using since the beginning of my analyses (and you guys kindly edited) using the script make_prefs_file.py. More precisely, to get the prefs file I ran the script make_prefs_file.py -m $PWD/mapping_file.txt -b "host_subject_id" -k white -o $PWD/prefs_out.txt. Do you think there is anything in the script that could be modified to fix the issues I get generating the 2d plots?

Greg Caporaso

unread,
Apr 25, 2017, 6:15:39 PM4/25/17
to Qiime 1 Forum
Hi Maria,
Would you be able to send us the mapping file that you provided as -m to make_prefs_file.py? I'd like to try to reproduce the issue you're experiencing. 

Thanks,
Greg

Maria Vittoria Marra

unread,
Apr 26, 2017, 2:37:48 PM4/26/17
to Qiime 1 Forum
Hi Greg,

absolutely, thank you very much for your help! Please find the prep file attached.

Best regards,

Maria Vittoria
mapping_file.txt

Jai Ram Rideout

unread,
Apr 26, 2017, 8:09:13 PM4/26/17
to Qiime 1 Forum
Hi Maria,

I ran the make_prefs_file.py command you posted with your mapping file and received a different file than the one you're having problems with. Here's the command I ran:

make_prefs_file.py -m mapping_file.txt -b "host_subject_id" -k white -o prefs_out.txt

I've attached the prefs file. Does it work for you?

Best,
Jai
prefs_out.txt

Maria Vittoria Marra

unread,
Apr 27, 2017, 2:03:18 PM4/27/17
to Qiime 1 Forum
Hi Jai,

many thanks also for your contribution! Actually yes, the pref file that I get running that script is the one you posted, but originally, when I opened the thread, I posted the pref file that I had edited trying to follow the suggestions in the threads https://groups.google.com/forum/#!searchin/qiime-forum/2d$20plot$20colors%7Csort:relevance/qiime-forum/qVvVd-lRL14/x0LF46r663cJ and https://groups.google.com/forum/#!topic/qiime-forum/etu0pN4ckEU. It is true what Evan was suggesting, i.e. the pref file as I edited misses the HSV(?) codes, but I am not very sure how I could modify the pref file to get the result I need.

Jai Ram Rideout

unread,
Apr 28, 2017, 8:24:54 PM4/28/17
to Qiime 1 Forum
Hi Maria,

Glad that file worked for you. Can you please send me your distance matrix, and describe exactly what you're wanting to customize in the 2D plots? Then I can try to write a prefs file that accomplishes your goals and send it your way.

Best,
Jai

Jai Ram Rideout

unread,
Apr 28, 2017, 8:26:56 PM4/28/17
to Qiime 1 Forum
Also, can you send me the output from running print_qiime_config.py -t ?
Reply all
Reply to author
Forward
0 new messages