ValueError: too many values to unpack (expected 4)
Opened this issue · 2 comments
Gitman0810 commented
Hi CellphoneDB Team!
Everytime I run the code, it always report an error like 'ValueError: too many values to unpack (expected 4)'. Could you please tell me the reason of the error? Thanks a lot in advance! The original code are presented as follows:
from cellphonedb.src.core.methods import cpdb_statistical_analysis_method
deconvoluted, means, pvalues, significant_means = cpdb_statistical_analysis_method.call(
cpdb_file_path = cpdb_file_path, # mandatory: CellPhoneDB database zip file.
meta_file_path = meta_file_path, # mandatory: tsv file defining barcodes to cell label.
counts_file_path = counts_file_path, # mandatory: normalized count matrix.
counts_data = 'hgnc_symbol', # defines the gene annotation in counts matrix.
# microenvs_file_path = microenvs_file_path, # optional (default: None): defines cells per microenvironment.
iterations = 1000, # denotes the number of shufflings performed in the analysis.
threshold = 0.1, # defines the min % of cells expressing a gene for this to be employed in the analysis.
threads = 8, # number of threads to use in the analysis.
debug_seed = 42, # debug randome seed. To disable >=0.
result_precision = 3, # Sets the rounding for the mean values in significan_means.
pvalue = 0.05, # P-value threshold to employ for significance.
subsampling = False, # To enable subsampling the data (geometri sketching).
subsampling_log = False, # (mandatory) enable subsampling log1p for non log-transformed data inputs.
subsampling_num_pc = 100, # Number of componets to subsample via geometric skectching (dafault: 100).
subsampling_num_cells = 1000, # Number of cells to subsample (integer) (default: 1/3 of the dataset).
separator = '|', # Sets the string to employ to separate cells in the results dataframes "cellA|CellB".
debug = False, # Saves all intermediate tables employed during the analysis in pkl format.
output_path = out_path, # Path to save results.
output_suffix = None # Replaces the timestamp in the output files by a user defined string in the (default: None).
)
Reading user files...
The following user files were loaded successfully:
/home/xddktz/project/Outdata/r_cpdb.h5ad
/home/xddktz/project/Tables/r_cpdb_meta.tsv
[ ][CORE][24/12/23-20:10:10][INFO] [Cluster Statistical Analysis] Threshold:0.1 Iterations:1000 Debug-seed:42 Threads:8 Precision:3
[ ][CORE][24/12/23-20:10:10][WARNING] Debug random seed enabled. Set to 42
[ ][CORE][24/12/23-20:10:22][INFO] Running Real Analysis
[ ][CORE][24/12/23-20:10:22][INFO] Running Statistical Analysis
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [41:55<00:00, 2.52s/it]
[ ][CORE][24/12/23-20:52:19][INFO] Building Pvalues result
[ ][CORE][24/12/23-20:52:20][INFO] Building results
Saved deconvoluted to /home/xddktz/project/cpdb/r/statistical_analysis_deconvoluted_12_24_2023_205220.txt
Saved deconvoluted_percents to /home/xddktz/project/cpdb/r/statistical_analysis_deconvoluted_percents_12_24_2023_205220.txt
Saved means to /home/xddktz/project/cpdb/r/statistical_analysis_means_12_24_2023_205220.txt
Saved pvalues to /home/xddktz/project/cpdb/r/statistical_analysis_pvalues_12_24_2023_205220.txt
Saved significant_means to /home/xddktz/project/cpdb/r/statistical_analysis_significant_means_12_24_2023_205220.txt
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[4], line 3
1 from cellphonedb.src.core.methods import cpdb_statistical_analysis_method
----> 3 deconvoluted, means, pvalues, significant_means = cpdb_statistical_analysis_method.call(
4 cpdb_file_path = cpdb_file_path, # mandatory: CellPhoneDB database zip file.
5 meta_file_path = meta_file_path, # mandatory: tsv file defining barcodes to cell label.
6 counts_file_path = counts_file_path, # mandatory: normalized count matrix.
7 counts_data = 'hgnc_symbol', # defines the gene annotation in counts matrix.
8 # microenvs_file_path = microenvs_file_path, # optional (default: None): defines cells per microenvironment.
9 iterations = 1000, # denotes the number of shufflings performed in the analysis.
10 threshold = 0.1, # defines the min % of cells expressing a gene for this to be employed in the analysis.
11 threads = 8, # number of threads to use in the analysis.
12 debug_seed = 42, # debug randome seed. To disable >=0.
13 result_precision = 3, # Sets the rounding for the mean values in significan_means.
14 pvalue = 0.05, # P-value threshold to employ for significance.
15 subsampling = False, # To enable subsampling the data (geometri sketching).
16 subsampling_log = False, # (mandatory) enable subsampling log1p for non log-transformed data inputs.
17 subsampling_num_pc = 100, # Number of componets to subsample via geometric skectching (dafault: 100).
18 subsampling_num_cells = 1000, # Number of cells to subsample (integer) (default: 1/3 of the dataset).
19 separator = '|', # Sets the string to employ to separate cells in the results dataframes "cellA|CellB".
20 debug = False, # Saves all intermediate tables employed during the analysis in pkl format.
21 output_path = out_path, # Path to save results.
22 output_suffix = None # Replaces the timestamp in the output files by a user defined string in the (default: None).
23 )
ValueError: too many values to unpack (expected 4)
qbly27 commented
Just use cpdb_results = cpdb_statistical_analysis_method.call(...)
to replace deconvoluted, means, pvalues, significant_means = cpdb_statistical_analysis_method.call(...)
In version 4 of CellPhoneDB, deconvoluted, means, pvalues, significant_means are used to store the results. In v5 results are save into the predefined file and as a dictionary in the one variable(cpdb_resuts
).
Gitman0810 commented
Thank you very much! It's finally worked out!