scverse / squidpy

Spatial Single Cell Analysis in Python
https://squidpy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
440 stars 81 forks source link

ModuleNotFoundError: No module named 'skmisc.loess._loess' and `pip install --user scikit-misc` did not help. Please help! #669

Closed yingsun-ucsd closed 4 months ago

yingsun-ucsd commented 1 year ago

I use Jupiter Notebook for squidgy nanoString analysis, it works fine until I got the last comment I attached below. I also attached the error message after that. I tried several things as well as google the solutions but it seems not work as expected. Please help. Thanks.

------ Here is my code in Jupiter Notebook ------

import scanpy as sc
import squidpy as sq
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from pathlib import Path
nanostring_dir = Path() / "/home" / "ysun" / "SMI-0039_UCSD"
sample_dir = nanostring_dir / "combNanastring_data"
adata = sq.read.nanostring(
    path = sample_dir,
    counts_file = "pancreas_exprMat_file.csv",
    meta_file = "pancreas_metadata_file.csv",
    fov_file = "pancreas_fov_positions_file.csv",
)
adata.var_names_make_unique()
adata.var["mt"] = adata.var_names.str.startswith("mt-")
sc.pp.calculate_qc_metrics(adata, qc_vars = ["mt"], inplace = True)
sc.pp.filter_cells(adata, min_counts = 100)
sc.pp.filter_genes(adata, min_cells = 300)
adata.layers["counts"] = adata.X.copy()

**sc.pp.highly_variable_genes(adata, flavor="seurat_v3", n_top_genes = 4000 ) <=== error happened here**

------ Here is the error message ------

ModuleNotFoundError                       Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/scanpy/preprocessing/_highly_variable_genes.py in _highly_variable_genes_seurat_v3(adata, layer, n_top_genes, batch_key, check_values, span, subset, inplace)
     52     try:
---> 53         from skmisc.loess import loess
     54     except ImportError:

~/miniconda3/lib/python3.9/site-packages/skmisc/loess/__init__.py in <module>
     50 """
---> 51 from ._loess import (loess, loess_model, loess_inputs, loess_control,
     52                      loess_outputs, loess_prediction,

ModuleNotFoundError: No module named 'skmisc.loess._loess'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
/tmp/ipykernel_3616337/2319832946.py in <module>
      5 #import skmisc
      6 #import loess
----> 7 sc.pp.highly_variable_genes(adata, flavor="seurat_v3", n_top_genes = 4000 )
      8 
      9 #sc.pp.normalize_total(adata, inplace=True)

/usr/local/lib/python3.8/dist-packages/scanpy/preprocessing/_highly_variable_genes.py in highly_variable_genes(adata, layer, n_top_genes, min_disp, max_disp, min_mean, max_mean, span, n_bins, flavor, subset, inplace, batch_key, check_values)
    417 
    418     if flavor == 'seurat_v3':
--> 419         return _highly_variable_genes_seurat_v3(
    420             adata,
    421             layer=layer,

/usr/local/lib/python3.8/dist-packages/scanpy/preprocessing/_highly_variable_genes.py in _highly_variable_genes_seurat_v3(adata, layer, n_top_genes, batch_key, check_values, span, subset, inplace)
     53         from skmisc.loess import loess
     54     except ImportError:
---> 55         raise ImportError(
     56             'Please install skmisc package via `pip install --user scikit-misc'
     57         )

ImportError: Please install skmisc package via `pip install --user scikit-misc`

------ Here is what I tried after pip install --user scikit-misc ------

import sys
sys.path.append('/home/ysun/miniconda3/lib/python3.9/site-packages')
import skmisc
import loess
sc.pp.highly_variable_genes(adata, flavor="seurat_v3", n_top_genes = 4000 )

But unfortunately, it did not work at all. I got about the same error message.

Please help. Thanks. ...

LLehner commented 1 year ago

Hi @yingsun-ucsd After installing the skmisc package did you restart the jupyter kernel?

yingsun-ucsd commented 1 year ago

I did. But the issue is still there.

giovp commented 4 months ago

I think you need to install skmisc closing this due to inactivity but feel free to reopen