ValueError: not enough values to unpack (expected 2, got 1)
yr542 opened this issue · comments
I get the error ValueError: not enough values to unpack (expected 2, got 1)
but I do not know why as my metadata is tab separated. I have removed my paths as I am working on an HPC and they do not allow us to disclose any paths on the HPC.
My variables are
tsv_file
= /path/to/rmats_JCEC_results.tsvmeta_file
= /path/to/Timepoint_1_Case_Control_Samples.tsvp_value
=0.05q_value
=0.05Jutils_Cloned_Directory
= /path/to/Jutils/directoryjutils_script_path
="${Jutils_Cloned_Directory}/jutils.py"
The relevant section of my script:
python3 "$jutils_script_path" heatmap \
--tsv-file "$tsv_file" \
--meta-file "$meta_file" \
--p-value "$p_value" \
--q-value "$q_value"
My metadata:
C-01 Control
C-02 Control
C-03 Control
KO-01 Case
KO-02 Case
KO-03 Case
My full error:
Traceback (most recent call last):
File "/path/to/jutils.py", line 149, in <module>
main()
File "/path/to/jutils.py", line 142, in main
run_heatmap_module(args, parser_dict)
File "/path/to/jutils.py", line 108, in run_heatmap_module
plot_heatmap(Path(args.tsv_file), Path(args.meta_file), Path(args.out_dir), args.p_value,
File "/path/to/heatmap_utils.py", line 63, in plot_heatmap
sample, cond = line.strip().split('\t')
ValueError: not enough values to unpack (expected 2, got 1)
How do I get around this error. I ran rMats from fastq files and used a Refseq gtf and rMats ran well. Therefore, I believe is an issue here with the heat map. The conversion to tsv script ran without error.
Thanks for reporting this! Based on the error message, I believe it is due to the meta file not being tab-separated. My guess is your "tab" became two spaces, please let me know if this is not the case.
Applying Your Suggestion/Solution:
To get around this issue I wrote it out in Excel and saves as a a tab separated file.
The new error:
Traceback (most recent call last):
File "/path/to/jutils.py", line 149, in <module>
main()
File "/path/to/jutils.py", line 142, in main
run_heatmap_module(args, parser_dict)
File "/path/to/jutils.py", line 108, in run_heatmap_module
plot_heatmap(Path(args.tsv_file), Path(args.meta_file), Path(args.out_dir), args.p_value,
File "/path/to/heatmap_utils.py", line 72, in plot_heatmap
data_df['GeneName'] = data_df['GeneName'].apply(truncate_gene_name)
File "/path/to/pandas/series.py", line 4630, in apply
return SeriesApply(self, func, convert_dtype, args, kwargs).apply()
File "/path/tp/pandas/apply.py", line 1025, in apply
return self.apply_standard()
File "/path/to/pandas/apply.py", line 1076, in apply_standard
mapped = lib.map_infer(
File "pandas/_libs/lib.pyx", line 2834, in pandas._libs.lib.map_infer
File "/path/to/heatmap_utils.py", line 92, in truncate_gene_name
gene_names = string.split(',')
AttributeError: 'float' object has no attribute 'split'
How would I resolve this error?
Thanks for catching this error, it is due to the 'GeneName' column being read as numbers instead of strings.
I have specified 'GeneName' to be strings only, please kindly git pull
to update the code and try again. Let me know if there are any issues.
When I run this I still get the same error. I have deleted the cloned directory and then re-cloned using git clone
why is this not working?
Hello - unfortunately with the information we have so far we cannot reproduce the error. Would you be able to send us a portion of your TSV file (the first 10-20 lines would suffice) and the metadata file? You can email them to florea@jhu.edu if you prefer. Thank you.