Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple output of cli pyscenic ctx #100

Open
ccshao opened this issue Oct 8, 2019 · 4 comments
Open

multiple output of cli pyscenic ctx #100

ccshao opened this issue Oct 8, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@ccshao
Copy link

ccshao commented Oct 8, 2019

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!

@bramvds
Copy link
Contributor

bramvds commented Oct 9, 2019

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

@bramvds bramvds self-assigned this Oct 9, 2019
@bramvds bramvds added the enhancement New feature or request label Oct 9, 2019
@ccshao
Copy link
Author

ccshao commented Oct 9, 2019

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

bramvds added a commit that referenced this issue Oct 9, 2019
@bramvds
Copy link
Contributor

bramvds commented Oct 9, 2019

These bugs should be fixed in release 0.9.19.

@ccshao
Copy link
Author

ccshao commented Oct 10, 2019

Good to know these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants