celltypist icon indicating copy to clipboard operation
celltypist copied to clipboard

Can't run cell typist with a my own model

Open anemartinezlarrinaga2898 opened this issue 3 years ago • 5 comments

Hello : )

Im trying to run cell typist with my own model and in the step "Training data using SGD logistic regression" I get the following error:

OMP: Error #13: Assertion failure at kmp_runtime.cpp(3689).
OMP: Hint Please submit a bug report with this message, compile and run commands used, and machine configuration info including native compiler and operating system versions. Faster response will be obtained by including all program sources. For information on submitting this issue, please see https://bugs.llvm.org/.
/Users/amartinezl/opt/anaconda3/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 2 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '
zsh: abort      python 2.5_RunCellTypist_OwnModel.py

Anyone has faced this error before?

Thanks!

This is the code Im using:

import os
import anndata
from scipy import io
import numpy as np
import pandas as pd
import re
import celltypist
from celltypist import models
import scanpy as sc

os.chdir("/Users/amartinezl/Library/CloudStorage/OneDrive-JosepCarrerasLeukaemiaResearchInstitute(IJC)/2_PhD/2_CELLULAR_SYSTEMS_GENOMICS/3_MEREU_PBMC_IMMUNE_ATLAS/1_ANALISIS/5_AnalisisFetal/AnotacionesCellTypist/")
os.getcwd() 

def CellClasificatioin_OwnModel(data_train,data_query,model,cell_type_label):
    print("Working with your own Model")
    predictions = celltypist.annotate(data_query, model = new_model , majority_voting = True)   
    adata = predictions.to_adata()
    metadata=adata.obs  
    return {'predictions_metadata': metadata, 'adata': adata}

path_data_query="4_PrediccionesCellTypist_Compartments/0_Data" # The fetal objects
path_data_train="5_PythonData_AdultImmune/PythonFiles" # The adult immune atlas 
cell_type_label="Annot_Layer_3_Short_Name"
data_train = sc.read_h5ad(f"{path_data_train}/CellTypistFormat_AnnData_AdultImmuneAtlas.h5ad")

metadata=data_train.obs
metadata_cell_label=metadata[["barcode","Annot_Layer_3_Long_Name"]]
#anndata_path = f"{path_data_train}/CellTypistFormat_AnnData_AdultImmuneAtlas.h5ad"
metadata_cell_label=np.array(metadata_cell_label["Annot_Layer_3_Long_Name"])

new_model = celltypist.train(data_train, labels = "Annot_Layer_3_Long_Name", n_jobs = -1, feature_selection = True)

Using it in a Mac System

Hi @anemartinezlarrinaga2898 it doesn't look like a explicit CellTypist error, but more of a scikit-learn/OpenMP issue (see https://github.com/scikit-learn/scikit-learn/pull/15020 and https://github.com/ContinuumIO/anaconda-issues/issues/11294).

Are you running this on a M1/M2 Mac? May be related to the architecture. Can I ask you to show me the output of clang -v?

prete avatar Aug 11 '22 11:08 prete

Hi,

Yes I realized is not a CellTypist error because Im not able also to run the example in the tutorial.

output clang -v -->

Apple clang version 13.0.0 (clang-1300.0.27.3)
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Im running it with the new architecture

I'm not sure of a workaround for ARM architecture. There may be some useful information for you to try here: https://forum.image.sc/t/napari-tensorflow-aicsimageio-stardist-care-n2v-pyclesperanto-running-native-on-apple-silicon-m1/55051/3

Otherwise, can I suggest you try this on Google Colab?

prete avatar Aug 11 '22 13:08 prete

Ok!

Will try on Google Colab! And if it does not work will try on the cluster of mi institut

Thanks!

@anemartinezlarrinaga2898, I will close this issue for now. If you still have problems, please let us know or feel free to reopen it.

ChuanXu1 avatar Sep 20 '22 20:09 ChuanXu1