cellphonedb v5注意事项

  1. 安装时出现报错:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: macs2 in /usr/local/python3/lib/python3.9/site-packages (2.2.7.1)
error: invalid-installed-package

× Cannot process installed package MACS2 2.2.7.1 in '/usr/local/python3/lib/python3.9/site-packages' because it has an invalid requirement:
│ Expected matching RIGHT_PARENTHESIS for LEFT_PARENTHESIS, after version specifier
│     numpy (>=>=1.17)
│           ~^
╰─> Starting with pip 24.1, packages with invalid requirements can not be processed.

hint: To proceed this package must be uninstalled

原因: MACS2 2.2.7.1的requirement写错了
解决;去/usr/local/python3/lib/python3.9/site-packages/MACS2-2.2.7.1.dist-info/里面的METADATA文件里面,将Requires-Dist: numpy (>=>=1.17)改为Requires-Dist: numpy (>=1.17)

  1. cpdb_file_path的路径是下载的v5 cellphone database里面的cellphonedb.zip,而不是v5整体那个压缩包

  2. 运行报错:

File ~/.local/lib/python3.9/site-packages/cellphonedb/src/core/methods/cpdb_analysis_method.py:180, in call(cpdb_file_path, meta_file_path, counts_file_path, counts_data, output_path, microenvs_file_path, separator, threshold, result_precision, debug, output_suffix, score_interactions, threads)
    177 analysis_result['deconvoluted_percents'] = deconvoluted_percents
    179 if score_interactions:
--> 180     interaction_scores = scoring_utils.score_interactions_based_on_participant_expressions_product(
    181         cpdb_file_path, counts, means_result.copy(), separator, meta, threshold, "cell_type", threads)
    182     analysis_result['interaction_scores'] = interaction_scores
    184 file_utils.save_dfs_as_tsv(output_path, output_suffix, "simple_analysis", analysis_result)

File ~/.local/lib/python3.9/site-packages/cellphonedb/utils/scoring_utils.py:347, in score_interactions_based_on_participant_expressions_product(cpdb_file_path, counts, means, separator, metadata, threshold, cell_type_col_name, threads)
    343 cpdb_fms = scale_expression(cpdb_fmsh,
    344                             upper_range=10)
    346 # Step 5: calculate the ligand-receptor score.
--> 347 interaction_scores = score_product(matrix=cpdb_fms,
    348                                    means=means,
    349                                    separator=separator,
    350                                    interactions=interactions,
    351                                    id2name=id2name,
    352                                    threads=threads)
    353 return interaction_scores

File ~/.local/lib/python3.9/site-packages/cellphonedb/utils/scoring_utils.py:293, in score_product(matrix, interactions, means, separator, id2name, threads)
    291 for ct_pair, lr_scores_filtered in results:
    292     interacting_pair2score = dict(zip(lr_scores_filtered['interacting_pair'], lr_scores_filtered['score']))
--> 293     interaction_scores[ct_pair] = [interacting_pair2score[id] for id in interaction_scores['interacting_pair']]
    295 return interaction_scores

File ~/.local/lib/python3.9/site-packages/cellphonedb/utils/scoring_utils.py:293, in <listcomp>(.0)
    291 for ct_pair, lr_scores_filtered in results:
    292     interacting_pair2score = dict(zip(lr_scores_filtered['interacting_pair'], lr_scores_filtered['score']))
--> 293     interaction_scores[ct_pair] = [interacting_pair2score[id] for id in interaction_scores['interacting_pair']]
    295 return interaction_scores

KeyError: 'LeukotrieneC4_byLTC4S_CYSLTR1'

有点类似https://github.com/ventolab/CellphoneDB/issues/190

解决:修改scoring_utils.py,重启Jupyter后再跑。另外注意,adata.X需要时Normalized数据,注意不要z-scale

interaction_scores[ct_pair] = [
    interacting_pair2score.get(id, None)  # 如果键不存在,则填充 None
    for id in interaction_scores['interacting_pair']
]
  1. 如果需要计算p值,参考https://github.com/ventolab/CellphoneDB/blob/master/notebooks/T1_Method2.ipynb
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。