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
443 stars 182 forks source link

auc bug #520

Open AnjaliS1 opened 11 months ago

AnjaliS1 commented 11 months ago

Hi, I have used the CLI version of pyscenic. Everything appears to have run successfully but then I get this error with this code:

import json import zlib import base64

collect SCENIC AUCell output

lf = lp.connect( f_pyscenic_output, mode='r+', validate=False ) auc_mtx = pd.DataFrame( lf.ca.RegulonsAUC, index=lf.ca.CellID) lf.close()


KeyError Traceback (most recent call last) ~/.local/lib/python3.8/site-packages/loompy/attribute_manager.py in getattr(self, name) 114 try: --> 115 vals = self.dict["storage"][name] 116 if vals is None:

KeyError: 'RegulonsAUC'

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last) /tmp/ipykernel_20211/3487089691.py in 5 # collect SCENIC AUCell output 6 lf = lp.connect( f_pyscenic_output, mode='r+', validate=False ) ----> 7 auc_mtx = pd.DataFrame( lf.ca.RegulonsAUC, index=lf.ca.CellID) 8 lf.close()

~/.local/lib/python3.8/site-packages/loompy/attribute_manager.py in getattr(self, name) 121 return vals 122 except KeyError: --> 123 raise AttributeError(f"'{type(self)}' object has no attribute '{name}'") 124 125 def setitem(self, name: str, val: np.ndarray) -> None:

AttributeError: '<class 'loompy.attribute_manager.AttributeManager'>' object has no attribute 'RegulonsAUC'

Is this perhaps due to my file structure?: image

Code run in CLI in ubuntu on HPC.

Tripfantasy commented 11 months ago

This looks like the loom being produced by your aucell step isn't integrating the AUCell results correctly. I had something similar happen to me. If the goal is to integrate your pySCENIC data with Scanpy (Like mine was) I recommend looking at this Example provided by the authors.

They use add_scenic_metadata(adata, auc_mtx, regulons) to integrate them for downstream analysis. Of course, this workaround involves taking the GRN and CTX outputs and throwing them into something like jupyter notebook, and using them to do the aucell step. (Which makes it not fully CLI)

This method worked for me. Essentially adding the aucell matrix as a layer to an adata object, similar to how umap coordinates are stored. You can likely construct a loom file from this adata object after the fact. Hope this helps!