gblanchard4 / qiime_to_lefse

Convert Qiime taxa tables and mapping files to a lefse formatted file
MIT License
7 stars 3 forks source link

ValueError: need more than 1 value to unpack??? Please help! #4

Open slvrshot opened 7 years ago

slvrshot commented 7 years ago

MacQIIME Todds-Mac-Pro:qiime_to_lefse-master $ python qiime_to_lefse.py -m map_soil_final3.txt -t soil_phyloseq_json_L6.txt -c Description -o converted_2lefse.txt --clean Traceback (most recent call last): File "qiime_to_lefse.py", line 126, in main() File "qiime_to_lefse.py", line 122, in main append_otu_info(taxafile, outfile, sample_dict, categories, clean) File "qiime_to_lefse.py", line 52, in append_otu_info taxa, abundance = line.rstrip('\n').split('\t', 1) ValueError: need more than 1 value to unpack

gblanchard4 commented 7 years ago

The problem looks like it's in the soil_phyloseq_json_L6.txt file. It looks like you are using the tab-separated version, not the JSON or HDF format, which is correct. Have you opened it in excel by chance? Sometimes excel will save it with funky line endings i.e. ^M vs /n.

Do you mind sending me a snipped of the file to inspect? Something like: head -n5 soil_phyloseq_json_L6.txt > test.file should work. You can email me or drag and drop it in here.

slvrshot commented 7 years ago

Can it take the .biom file directly from my pick_open_reference_otus.py step? Also when I get home I'll head the .txt file.

gblanchard4 commented 7 years ago

You need to convert it to a TSV based biom, generally after picking otus it's in JSON format (or HDF5 if you have that enabled).

You can tell what format the file is currently in by doing a less -S soil_phyloseq_json_L6.txt and looking at the output.

So if it doesn't look like a spreadsheet try to convert it like this: biom convert -i tsoil_phyloseq_json_L6.txt -o soil_phyloseq_json_L6.tsv --to-tsv --header-key taxonomy

slvrshot commented 7 years ago

test.file.zip

here you go! Thanks!

On Jan 28, 2017, at 4:39 PM, Gene Blanchard notifications@github.com wrote:

-n5 soil_phyloseq_json_L6.txt > test.file

gblanchard4 commented 7 years ago

OK, I figured it out. I think originally I was using the OTU files generated by the summarize_taxa_through_plots.py script. Those files have a different header on the file.

The taxa_summaries header looks like:

Taxon Samplename1 Samplename2...

Where a standard OTU file like yours starts with:

# Constructed from biom file
#OTU ID Samplename1    Samplename2...

I can update the code (and write some much needed documentation) to work with standard OTU files too.

In the meantime you can do this:

  1. Open the file in your favorite text editor
  2. Remove the # Constructed from biom file line
  3. Change #OTU ID to Taxon
  4. Profit 💸

Let me know if that works for you!

slvrshot commented 7 years ago

I think we're close. I get another error but its different from the previous one. It seems its having issues with sample names.

MacQIIME Todds-Mac-Pro:qiime_to_lefse-master $ python qiime_to_lefse.py -m map.txt -t soil_phyloseq_json_L6.txt -c Site -o converted_2lefse.txt --clean Traceback (most recent call last): File "qiime_to_lefse.py", line 126, in main() File "qiime_to_lefse.py", line 122, in main append_otu_info(taxafile, outfile, sample_dict, categories, clean) File "qiime_to_lefse.py", line 46, in append_otu_info category_line += "\t{}".format(sample_dict[sample_id][index]) KeyError: 'TB8S2' map.txt [Uploading soil_phyloseq_json_L6.txt…]()

Thanks!!!!

gblanchard4 commented 7 years ago

So I took a look at the error and it appears that your mapping file contains samples that your OTU table does not. I can't find TB8S2 in the header line of the OTU file you sent.

I am sorry about all the problems you are having. This was a quick script I put together for a collaborators specific file types. I really need to make it more general!

slvrshot commented 7 years ago

I think I posted the wrong mapping file. I tried it with the correct one and got a similar error. Anyway, I hope my issues end up making the software even better. Thanks for taking the time to look at my issue.

gblanchard4 commented 7 years ago

Is there any chance you can email me your full files to help me debug?

gblanchard4-at-gmail-dot-com

slvrshot commented 7 years ago

Which specific ones do you need?

slvrshot commented 7 years ago

Oops sorry yes I will!