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
420 stars 179 forks source link

Output regulons to gmt file so that can import to R #126

Closed ShaowenJ closed 4 years ago

ShaowenJ commented 4 years ago

Hi, I have a quick question, So in this step, I use the tutorial code to write down the regulon file to "regulon.p" But it might be a better idea to output it to gmt file so that it can be imported into R. Could anyone kindly tell me how to do that?

REGULONS_FNAME = os.path.join(SCENIC_FOLDER, "regulons.p")

Calculate a list of enriched motifs and the corresponding target genes for all modules.

with ProgressBar(): df = prune2df(dbs, modules, MOTIF_ANNOTATIONS_FNAME)

Create regulons from this table of enriched motifs.

regulons = df2regulons(df)

Save the enriched motifs and the discovered regulons to disk.

df.to_csv(MOTIFS_FNAME) with open(REGULONS_FNAME, "wb") as f: pickle.dump(regulons, f)

cflerin commented 4 years ago

Hi,

You can save the regulons to gmt using the save_enriched_motifs function in pySCENIC. Set the output file to have the gmt extension:

save_enriched_motifs(regulons, 'regulons.gmt')

This also supports csv, tsv, pickle, json, and yaml.

ShaowenJ commented 4 years ago

Hi,

Thanks for the quick response. but why I cannot import this function? ImportError: cannot import name 'save_enriched_motifs' from 'pyscenic.utils' (/Users/levylabmini2/opt/anaconda3/lib/python3.7/site-packages/pyscenic/utils.py)

Thanks,

cflerin commented 4 years ago

It should be:

from pyscenic.cli.utils import save_enriched_motifs