aertslab / pySCENIC

pySCENIC is a lightning-fast python implementation of the SCENIC pipeline (Single-Cell rEgulatory Network Inference and Clustering) which enables biologists to infer transcription factors, gene regulatory networks and cell types from single-cell RNA-seq data.
http://scenic.aertslab.org
GNU General Public License v3.0
397 stars 176 forks source link

[BUG] run in pyscenic grn #559

Open zhangdong360 opened 5 days ago

zhangdong360 commented 5 days ago

Describe the bug When I run pySCENIC, I often encounter disturbing warnings. I checked the problem may be associated with me this question. https://github.com/aertslab/pySCENIC/issues/482 But I'm not using port 8787. On the other hand, I don't often encounter this warning on the HPC where I have Rstudio server installed, and I don't think it has anything to do with it. I think the problem might be with dask, but I'm not well versed in it. On the other hand, the lack of output, which makes me cannot judge whether I need to run the program. As mentioned above, re-running the program will most likely encounter warning again. In addition, I have tried arboreto_with_multiprocessing.py, but it was too inefficient, I tested it on small samples, and it was nearly twice as slow as pySCENIC for the same number of CPU cores. I don't think that's acceptable in a large sample. It took me too much energy in to run the program, I have to sample cut to my data size, but I don't think this is a long-term solution.

(scanpy) [zhangdong_2@jupyterlab-md-npeer5o1 pySCENIC]$ cat step1.out 

2024-07-02 15:30:29,526 - pyscenic.cli.pyscenic - INFO - Loading expression matrix.

2024-07-02 15:32:35,579 - pyscenic.cli.pyscenic - INFO - Inferring regulatory networks.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
2024-07-02 15:34:13,518 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:46641', 'tcp://127.0.0.1:43849', 'tcp://127.0.0.1:44125', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:37827']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:46641', 'tcp://127.0.0.1:43849', 'tcp://127.0.0.1:44125', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:37827']})
2024-07-02 15:34:13,518 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:46641', 'tcp://127.0.0.1:43849', 'tcp://127.0.0.1:44125', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:37827']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:46641', 'tcp://127.0.0.1:43849', 'tcp://127.0.0.1:44125', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:37827']})
2024-07-02 15:34:13,519 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:33897 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:46641', 'tcp://127.0.0.1:43849', 'tcp://127.0.0.1:44125', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:37827')}
2024-07-02 15:34:13,520 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:33279 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:46641', 'tcp://127.0.0.1:43849', 'tcp://127.0.0.1:44125', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:37827')}
2024-07-02 15:34:13,530 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:46641', 'tcp://127.0.0.1:43849', 'tcp://127.0.0.1:44125', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:37827']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:46641', 'tcp://127.0.0.1:43849', 'tcp://127.0.0.1:44125', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:37827']})
2024-07-02 15:34:13,531 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:33285 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:46641', 'tcp://127.0.0.1:43849', 'tcp://127.0.0.1:44125', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:37827')}
2024-07-02 15:34:28,077 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:32855', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:45323', 'tcp://127.0.0.1:46849']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:32855', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:45323', 'tcp://127.0.0.1:46849']})
2024-07-02 15:34:28,079 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:46641 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:32843', 'tcp://127.0.0.1:32855', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:45323', 'tcp://127.0.0.1:46849')}
2024-07-02 15:34:28,086 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:32855', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:45323', 'tcp://127.0.0.1:46849']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:32855', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:45323', 'tcp://127.0.0.1:46849']})
2024-07-02 15:34:28,088 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:33285 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:32843', 'tcp://127.0.0.1:32855', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:45323', 'tcp://127.0.0.1:46849')}
2024-07-02 15:37:24,939 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849']})
2024-07-02 15:37:24,942 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849']})
2024-07-02 15:37:24,943 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:32843', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849']})
2024-07-02 15:37:24,972 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:44125 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:32843', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849')}
2024-07-02 15:37:24,973 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:43849 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:32843', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849')}
2024-07-02 15:37:24,973 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:42931 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:32843', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:42003', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849')}
2024-07-02 15:37:40,544 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:45323', 'tcp://127.0.0.1:44201', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33285']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:45323', 'tcp://127.0.0.1:44201', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33285']})
2024-07-02 15:37:40,545 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:42931 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:45323', 'tcp://127.0.0.1:44201', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33285')}
2024-07-02 15:37:40,562 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:45323', 'tcp://127.0.0.1:44201', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33285']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:45323', 'tcp://127.0.0.1:44201', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33285']})
2024-07-02 15:37:40,564 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:45323', 'tcp://127.0.0.1:44201', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33285']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:45323', 'tcp://127.0.0.1:44201', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33285']})
2024-07-02 15:37:40,564 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:44125 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:45323', 'tcp://127.0.0.1:44201', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33285')}
2024-07-02 15:37:40,565 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:37827 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:45323', 'tcp://127.0.0.1:44201', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33285')}
2024-07-02 15:39:52,768 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:46641', 'tcp://127.0.0.1:33285', 'tcp://127.0.0.1:37827', 'tcp://127.0.0.1:46849', 'tcp://127.0.0.1:42931']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:46641', 'tcp://127.0.0.1:33285', 'tcp://127.0.0.1:37827', 'tcp://127.0.0.1:46849', 'tcp://127.0.0.1:42931']})
2024-07-02 15:39:52,816 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:32855 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:46641', 'tcp://127.0.0.1:33285', 'tcp://127.0.0.1:37827', 'tcp://127.0.0.1:46849', 'tcp://127.0.0.1:42931')}
2024-07-02 15:40:37,290 - distributed.worker - WARNING - Could not find data: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33897', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849']} on workers: [] (who_has: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ['tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33897', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849']})
2024-07-02 15:40:37,291 - distributed.scheduler - WARNING - Worker tcp://127.0.0.1:44201 failed to acquire keys: {'ndarray-a612cf0abd06497fa68e9db39636fedb': ('tcp://127.0.0.1:35067', 'tcp://127.0.0.1:33897', 'tcp://127.0.0.1:33279', 'tcp://127.0.0.1:46641', 'tcp://127.0.0.1:44847', 'tcp://127.0.0.1:46849')}

Expected behavior I didn't find a clear reproduction. But I find it often will appear in my after a run.

zhangdong360 commented 4 days ago

My code:

#!/bin/bash
#SBATCH -o output/pyscenic_hsc_sev.out
#SBATCH -e output/pyscenic_hsc_sev.err
#SBATCH --partition=compute
#SBATCH -J scenic_HSC_SEV
#SBATCH --nodes=1               
#SBATCH -n 30
# This is for fastp protocol

#conda activate scanpy
# human
#f_db_names="/share/home/zhangd/tools/database/cistarget/cisTarget_databases/homo_sapiens/hg38/refseq_r80/mc_v10_clust/gene_based/hg38_500bp_up_100bp_down_full_tx_v10_clust.genes_vs_motifs.rankings.feather"
#f_motif_path="/share/home/zhangd/tools/database/cistarget/Motif2TF/motifs-v10nr_clust-nr.hgnc-m0.001-o0.0.tbl"
#f_tf_list="/share/home/zhangd/project/python_project/pySCENIC/allTFs_hg38.txt"
# mouse
f_db_names="/home/zhangdong_2/database/cistarget/cisTarget_databases/mus_musculus/mm10/refseq_r80/mc_v10_clust/mm10_500bp_up_100bp_down_full_tx_v10_clust.genes_vs_motifs.rankings.feather"
f_motif_path="/home/zhangdong_2/database/cistarget/Motif2TF/motifs-v10nr_clust-nr.mgi-m0.001-o0.0.tbl"
f_tf_list="/home/zhangdong_2/database/cistarget/TF_lists/allTFs_mm.txt"
# data input

dir_result="/home/zhangdong_2/project/pySCENIC/03_result/HSC_SEV/"
input_loom="/home/zhangdong_2/project/pySCENIC/01_data/HSC_SEV.loom"

# step1
echo "Step 1 pyscenic grn start"
nohup pyscenic grn ${input_loom}  ${f_tf_list} \
              --seed 21 \
              --num_workers 16 \
              --method grnboost2 \
              --output ${dir_result}/step_1_fibo_grn.tsv >step1.out 2>&1 &
echo "Step 1 pyscenic grn finish"
echo "Step 2 pyscenic ctx start"
nohup pyscenic ctx ${dir_result}/step_1_fibo_grn.tsv  \
     ${f_db_names} \
     --annotations_fname ${f_motif_path} \
     --expression_mtx_fname ${input_loom} \
     --output ${dir_result}/step_2_reg.csv \
     --mask_dropouts \
     --num_workers 16 >step2.out 2>&1 &
echo "Step 2 pyscenic ctx finish"
echo "Step 3 pyscenic aucell start"
pyscenic aucell \
    ${input_loom} \
    ${dir_result}/step_2_reg.csv \
    --seed 21 \
    --output ${dir_result}/step_3_aucell.csv \
    --num_workers 16 >step_3.out 2>&1 &
echo "All finish"

I tried to use slurm distribution to compute nodes and directly in local bash operation, the result is the same. At the same time I run this code on the other operation platform, I found warning almost consistent, all point to the ndarray - a612cf0abd06497fa68e9db39636fedb. May be some help to found the problem?

zhangdong360 commented 4 days ago

My code:

#!/bin/bash
#SBATCH -o output/pyscenic_hsc_sev.out
#SBATCH -e output/pyscenic_hsc_sev.err
#SBATCH --partition=compute
#SBATCH -J scenic_HSC_SEV
#SBATCH --nodes=1               
#SBATCH -n 30
# This is for fastp protocol

#conda activate scanpy
# human
#f_db_names="/share/home/zhangd/tools/database/cistarget/cisTarget_databases/homo_sapiens/hg38/refseq_r80/mc_v10_clust/gene_based/hg38_500bp_up_100bp_down_full_tx_v10_clust.genes_vs_motifs.rankings.feather"
#f_motif_path="/share/home/zhangd/tools/database/cistarget/Motif2TF/motifs-v10nr_clust-nr.hgnc-m0.001-o0.0.tbl"
#f_tf_list="/share/home/zhangd/project/python_project/pySCENIC/allTFs_hg38.txt"
# mouse
f_db_names="/home/zhangdong_2/database/cistarget/cisTarget_databases/mus_musculus/mm10/refseq_r80/mc_v10_clust/mm10_500bp_up_100bp_down_full_tx_v10_clust.genes_vs_motifs.rankings.feather"
f_motif_path="/home/zhangdong_2/database/cistarget/Motif2TF/motifs-v10nr_clust-nr.mgi-m0.001-o0.0.tbl"
f_tf_list="/home/zhangdong_2/database/cistarget/TF_lists/allTFs_mm.txt"
# data input

dir_result="/home/zhangdong_2/project/pySCENIC/03_result/HSC_SEV/"
input_loom="/home/zhangdong_2/project/pySCENIC/01_data/HSC_SEV.loom"

# step1
echo "Step 1 pyscenic grn start"
nohup pyscenic grn ${input_loom}  ${f_tf_list} \
              --seed 21 \
              --num_workers 16 \
              --method grnboost2 \
              --output ${dir_result}/step_1_fibo_grn.tsv >step1.out 2>&1 &
echo "Step 1 pyscenic grn finish"
echo "Step 2 pyscenic ctx start"
nohup pyscenic ctx ${dir_result}/step_1_fibo_grn.tsv  \
     ${f_db_names} \
     --annotations_fname ${f_motif_path} \
     --expression_mtx_fname ${input_loom} \
     --output ${dir_result}/step_2_reg.csv \
     --mask_dropouts \
     --num_workers 16 >step2.out 2>&1 &
echo "Step 2 pyscenic ctx finish"
echo "Step 3 pyscenic aucell start"
pyscenic aucell \
    ${input_loom} \
    ${dir_result}/step_2_reg.csv \
    --seed 21 \
    --output ${dir_result}/step_3_aucell.csv \
    --num_workers 16 >step_3.out 2>&1 &
echo "All finish"

I tried to use slurm distribution to compute nodes and directly in local bash operation, the result is the same. At the same time I run this code on the other operation platform, I found warning almost consistent, all point to the ndarray - a612cf0abd06497fa68e9db39636fedb. May be some help to found the problem?

NOTE:It is worth mentioning that this is a different data on different platforms have been the same warning…And my sample book set can be successful operation.This doubt has been gnawed at me for a long time.

ghuls commented 3 days ago

Can you with try with the Docker/Podman/Singularity/Apptainer images instead? https://pyscenic.readthedocs.io/en/latest/installation.html#docker-podman-and-singularity-apptainer-images