pySCENIC
pySCENIC copied to clipboard
multiple output of cli pyscenic ctx
From the cli, the pyscenic ctx could only take one argument of -o, so one has to run twice to get the enriched motif and regulon, while each run is very time consuming. Could it be possible to output enriched motif and regulon simultaneously?Thanks!
Dear,
Good suggestion. A workaround, for now, could be to convert the motif file into regulons via a Python code snippet:
import pickle
from pyscenic.utils import load_motifs
from pyscenic.prune import df2regulons
MOTIFS_FNAME = "" # To be completed.
REGULONS_FNAME = ""# To be completed.
df = load_motifs(MOTIFS_FNAME)
regulons = df2regulons(df)
with open(REGULONS_FNAME, 'wb') as f:
pickle.dump(regulons, f)
Kindest regards, Bram
Thanks the quick help. I just found another minor issue: the output argument with gmt/dat(pickle?) don't work. As above I used the latest version (0.9.18)
gmt output:
pyscenic ctx -o test2.gmt --annotations_fname $motifanno --expression_mtx_fname $inmtx -t grnresults_lite.csv $regdb
(base) 01_cli $ pyscenic ctx -o test2.gmt --annotations_fname $motifanno --expression_mtx_fname $inmtx -t grnresults_lite.csv $regdb /home/shao/miniconda3/lib/python3.7/site-packages/dask/config.py:161: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. data = yaml.load(f.read()) or {}
2019-10-09 09:18:13,909 - pyscenic.cli.pyscenic - INFO - Creating modules.
2019-10-09 09:18:13,921 - pyscenic.cli.pyscenic - INFO - Loading expression matrix.
2019-10-09 09:18:19,910 - pyscenic.utils - INFO - Calculating Pearson correlations.
2019-10-09 09:18:19,910 - pyscenic.utils - WARNING ... Dropout masking is currently set to [False].
2019-10-09 09:18:21,623 - pyscenic.utils - INFO - Creating modules.
2019-10-09 09:18:43,545 - pyscenic.cli.pyscenic - INFO - Loading databases. .... 2019-10-09 09:20:28,286 - pyscenic.cli.pyscenic - INFO - Writing results to file. Traceback (most recent call last): File "/home/shao/miniconda3/bin/pyscenic", line 10, in
sys.exit(main()) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/cli/pyscenic.py", line 408, in main args.func(args) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/cli/pyscenic.py", line 165, in prune_targets_command save_enriched_motifs(df_motifs, args.output.name) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/cli/utils.py", line 177, in save_enriched_motifs GeneSignature.to_gmt(fname, regulons) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/genesig.py", line 94, in to_gmt signature.metadata(gene_separator), field_separator, TypeError: 'str' object is not callable
Similar errorr for dat output with command:
pyscenic ctx -o test2.dat --annotations_fname $motifanno --expression_mtx_fname $inmtx -t grnresults_lite.csv $regdb
2019-10-09 09:28:02,682 - pyscenic.cli.pyscenic - INFO - Writing results to file. Traceback (most recent call last): File "/home/shao/miniconda3/bin/pyscenic", line 10, in
sys.exit(main()) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/cli/pyscenic.py", line 408, in main args.func(args) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/cli/pyscenic.py", line 165, in prune_targets_command save_enriched_motifs(df_motifs, args.output.name) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/cli/utils.py", line 175, in save_enriched_motifs pickle.dump(regulons, fname) TypeError: file must have a 'write' attribute
I tried pickl:
(base) 01_cli $ pyscenic ctx -o test2.pickle --annotations_fname $motifanno --expression_mtx_fname $inmtx -t grnresults_lite.csv $regdb
provides error:
Traceback (most recent call last): File "/home/shao/miniconda3/bin/pyscenic", line 10, in
sys.exit(main()) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/cli/pyscenic.py", line 408, in main args.func(args) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/cli/pyscenic.py", line 165, in prune_targets_command save_enriched_motifs(df_motifs, args.output.name) File "/home/shao/miniconda3/lib/python3.7/site-packages/pyscenic/cli/utils.py", line 181, in save_enriched_motifs raise ValueError("Unknown file format "{}".".format(fname)) ValueError: Unknown file format "test2.pickle".
YAML and json work fine,
pyscenic ctx -o regulons.json --annotations_fname $motifanno --expression_mtx_fname $inmtx -t grnresults_lite.csv $regdb
pyscenic ctx -o regulons2.yaml --annotations_fname $motifanno --expression_mtx_fname $inmtx -t grnresults_lite.csv $regdb
These bugs should be fixed in release 0.9.19.
Good to know these.