theislab / cellrank

CellRank: dynamics from multi-view single-cell data
https://cellrank.org
BSD 3-Clause "New" or "Revised" License
342 stars 47 forks source link

Failed model: genes not translating to the model in .gene_trends #838

Closed keithgmitchell closed 2 years ago

keithgmitchell commented 2 years ago

...

model = cr.ul.models.GAM(adata)
cr.pl.gene_trends(
    adata,
    model,
    test_sig[0:20],
    ncols=3,
    data_key="Ms",
    color='pterotyping_donor__anno',
    time_key="ct_pseudotime",
    same_plot=True,
    figsize=(15, 4),
    n_test_points=200,
)
TypeError: Fatal model failure `<FailedModel[origin=GAM[gene=None, lineage=None, model=GammaGAM(callbacks=['deviance', 'diffs'], fit_intercept=True, max_iter=2000, scale=None, terms=s(0), tol=0.0001, verbose=False)]]>`.

Versions:

Package Version Location


absl-py 1.0.0
adjustText 0.7.3
aiohttp 3.8.1
aiosignal 1.2.0
airr 1.3.1
alabaster 0.7.12
amqp 5.0.9
aniso8601 9.0.1
anndata 0.7.8
anndata2ri 1.0.6
annoy 1.17.0
ansi2html 1.6.0
anyio 3.5.0
appdirs 1.4.4
arboreto 0.1.6
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
arrow 1.2.2
asciitree 0.3.3
asgiref 3.5.0
astroid 2.9.3
astunparse 1.6.3
async-timeout 4.0.2
attrs 21.4.0
autopep8 1.6.0
Babel 2.9.1
backcall 0.2.0
backports.zoneinfo 0.2.1
batchglm 0.7.4
bbknn 1.5.1
beautifulsoup4 4.10.0
billiard 3.6.4.0
binaryornot 0.4.4
biopython 1.79
bioservices 1.8.3
black 22.1.0
bleach 4.1.0
bokeh 2.4.2
boltons 21.0.0
boto3 1.20.29
botocore 1.23.29
Brotli 1.0.9
bs4 0.0.1
cachetools 4.2.4
cachey 0.2.1
cattrs 1.10.0
celery 5.2.3
cellrank 1.5.1
cellxgene 1.0.0
certifi 2019.11.28
cffi 1.15.0
chardet 3.0.4
charset-normalizer 2.0.10
click 8.0.3
click-didyoumean 0.3.0
click-plugins 1.1.1
click-repl 0.2.0
cloudpickle 2.0.0
cmake 3.22.2
colorama 0.4.4
coloredlogs 15.0.1
colorlog 6.6.0
colormath 3.0.0
commonmark 0.9.1
ConfigArgParse 1.5.3
configparser 5.2.0
cookiecutter 1.7.3
crossref-commons 0.0.7
ctxcore 0.1.1
cycler 0.11.0
Cython 0.29.27
cytoolz 0.11.2
dash 1.20.0
dash-building-blocks 0.1.2
dash-core-components 2.0.0
dash-cytoscape 0.3.0
dash-html-components 2.0.0
dash-renderer 1.9.1
dash-table 4.11.3
dask 2021.12.0
dask-image 2021.12.0
dbus-python 1.2.16
debugpy 1.5.1
decorator 5.1.0
defusedxml 0.7.1
Deprecated 1.2.13
diffxpy 0.7.4
dill 0.3.4
distributed 2021.12.0
distro-info 0.23ubuntu1
Django 3.2.10
django-celery-beat 2.2.1
django-celery-results 2.3.0
django-crispy-forms 1.14.0
django-extensions 3.1.5
django-filter 21.1
django-js-asset 1.2.2
django-markdownify 0.9.0
django-mptt 0.13.4
django-multiselectfield 0.1.12
django-plotly-dash 1.6.6
django-timezone-field 4.2.3
django-widget-tweaks 1.4.12
djangorestframework 3.13.1
djangorestframework-datatables 0.7.0
docrep 0.3.2
docstring-parser 0.13
docutils 0.17.1
dpd-components 0.1.0
dunamai 1.8.0
easydev 0.12.0
entrypoints 0.3
et-xmlfile 1.1.0
fa2 0.3.5
fastcluster 1.2.4
fastcore 1.3.27
fasteners 0.17.3
fbpca 1.0
flake8 4.0.1
flasgger 0.9.5
Flask 2.0.2
Flask-Compress 1.10.1
Flask-Cors 3.0.10
Flask-RESTful 0.3.9
flask-server-timing 0.1.2
flask-talisman 0.8.1
flatbuffers 1.12
flatten-dict 0.4.2
fonttools 4.28.5
fpdf 1.7.2
freetype-py 2.2.0
frozendict 2.1.3
frozenlist 1.2.0
fsspec 0.7.4
future 0.18.2
fuzzywuzzy 0.18.0
gast 0.4.0
GDAL 3.0.4
geosketch 1.2
get-version 3.5.3
gevent 21.12.0
gitdb 4.0.9
GitPython 3.1.26
google-auth 2.3.3
google-auth-oauthlib 0.4.6
google-pasta 0.2.0
gprofiler-official 1.0.0
graphtools 1.5.2
greenlet 1.1.2
grequests 0.6.0
grpcio 1.43.0
gsea-api 0.3.4
gseapy 0.10.7
gunicorn 20.1.0
h5py 2.10.0
harmonypy 0.0.5
HeapDict 1.0.1
hsluv 5.0.2
humanfriendly 10.0
idna 2.8
igraph 0.9.8
imageio 2.14.1
imagesize 1.3.0
importlib-metadata 4.10.0
importlib-resources 5.4.0
inflect 5.3.0
iniconfig 1.1.1
interlap 0.2.7
intervaltree 2.1.0
ipdb 0.13.9
ipykernel 6.6.1
ipympl 0.8.5
ipython 7.31.0
ipython-genutils 0.2.0
ipywidgets 7.6.5
isort 5.10.1
iterativeWGCNA 1.1.6
itsdangerous 2.0.1
jedi 0.18.1
Jinja2 3.0.3
jinja2-time 0.2.0
jmespath 0.10.0
joblib 0.17.0
json5 0.9.6
jsonschema 4.3.3
jupyter-client 7.1.0
jupyter-core 4.9.1
jupyter-dash 0.4.0
jupyter-helpers 0.2.3
jupyter-lsp 1.5.1
jupyter-server 1.13.4
jupyter-server-mathjax 0.2.3
jupyterlab 3.2.8
jupyterlab-code-formatter 1.4.10
jupyterlab-git 0.34.2
jupyterlab-lsp 3.10.0
jupyterlab-pygments 0.1.2
jupyterlab-server 2.10.3
jupyterlab-templates 0.3.1
jupyterlab-widgets 1.0.2
jupytext 1.13.6
keras 2.7.0
Keras-Preprocessing 1.1.2
kiwisolver 1.3.2
kombu 5.2.3
lazy-import 0.2.2
lazy-object-proxy 1.7.1
lckr-jupyterlab-variableinspector 3.0.9
leidenalg 0.8.8
libclang 13.0.0
llvmlite 0.37.0
locket 0.2.1
loompy 3.0.6
louvain 0.7.1
lxml 4.7.1
lzstring 1.0.4
magicgui 0.3.4
Markdown 3.3.6
markdown-it-py 1.1.0
MarkupSafe 2.0.1
matplotlib 3.5.1
matplotlib-inline 0.1.3
mccabe 0.6.1
mdit-py-plugins 0.3.0
mistune 0.8.4
msgpack 1.0.3
multidict 5.2.0
multiprocessing-on-dill 3.5.0a4
multiqc 1.11
mypy-extensions 0.4.3
napari 0.4.13
napari-console 0.0.4
napari-plugin-engine 0.2.0
napari-svg 0.1.6
natsort 8.0.2
nbclassic 0.3.5
nbclient 0.5.9
nbconvert 6.4.0
nbdime 3.1.1
nbformat 5.1.3
nbresuse 0.4.0
neo4j 4.4.1
nest-asyncio 1.5.4
networkx 2.6.3
notebook 6.4.6
npe2 0.1.2
numba 0.54.1
numcodecs 0.9.1
numexpr 2.8.1
numpy 1.20.0
numpy-groupies 0.9.14
numpydoc 1.2
oauthlib 3.1.1
obonet 0.3.0
omnipath 1.0.5
openpyxl 3.0.9
opt-einsum 3.3.0
Owlready2 0.36
packaging 21.3
pandas 1.2.5
pandocfilters 1.5.0
parasail 1.2.4
parso 0.8.3
partd 1.2.0
passlib 1.7.4
path 16.2.0
pathlib 1.0.1
pathspec 0.9.0
patsy 0.5.2
peepdis 0.1.13
pexpect 4.8.0
phate 1.0.7
PhenoGraph 1.5.7
pickleshare 0.7.5
Pillow 9.0.0
PIMS 0.5
Pint 0.18
pip 20.0.2
platformdirs 2.4.1
plotly 5.5.0
pluggy 1.0.0
pooch 1.6.0
poyo 0.5.0
progressbar2 4.0.0
prometheus-client 0.12.0
prompt-toolkit 3.0.24
protobuf 3.19.1
psutil 5.9.0
psycopg2 2.9.3
psygnal 0.2.0
ptvsd 4.3.2
ptyprocess 0.7.0
py 1.11.0
pyarrow 0.16.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pybiomart 0.2.0
pycodestyle 2.8.0
pycparser 2.21
pydantic 1.9.0
pyDeprecate 0.3.0
pydocstyle 6.1.1
pyflakes 2.4.0
pygam 0.8.0
Pygments 2.11.1
PyGObject 3.36.0
pygpcca 1.0.3
PyGSP 0.5.1
PyHGNC 0.2.4
pylint 2.12.2
PyMySQL 1.0.2
pynndescent 0.5.5
PyOpenGL 3.1.5
pyparsing 3.0.6
PyQt5 5.15.6
PyQt5-Qt5 5.15.2
PyQt5-sip 12.9.0
pyro-api 0.1.2
pyro-ppl 1.8.0
pyrsistent 0.18.0
pysam 0.18.0
pyscenic 0.11.2
pytest 6.2.5
python-apt 2.0.0+ubuntu0.20.4.6 python-crontab 2.6.0
python-dateutil 2.8.2
python-debian 0.1.36ubuntu1
python-igraph 0.9.8
python-Levenshtein 0.12.2
python-lsp-jsonrpc 1.0.0
python-lsp-server 1.3.3
python-slugify 5.0.2
python-utils 3.1.0
pytoml 0.1.21
pytomlpp 1.0.10
pytorch-lightning 1.3.1
pytz 2021.3
pytz-deprecation-shim 0.1.0.post0
PyWavelets 1.2.0
PyYAML 5.4.1
pyzmq 22.3.0
qtconsole 5.2.2
QtPy 2.0.0
questionary 1.10.0
ratelimit 2.2.1
requests 2.24.0
requests-cache 0.9.1
requests-oauthlib 1.3.0
requests-unixsocket 0.2.0
retrying 1.3.3
rich 10.16.2
rope 0.22.0
rpy2 3.4.2
rsa 4.8
s-gd2 1.8
s3fs 0.4.2
s3transfer 0.5.0
scanorama 1.7.1
scanpy 1.8.2
scikit-image 0.19.1
scikit-learn 1.0.2
scikit-misc 0.1.4
scipy 1.7.3
scirpy 0.10.1
scprep 1.1.0
scrublet 0.2.3
scvelo 0.2.4
scvi-tools 0.14.5
seaborn 0.11.2
Send2Trash 1.8.0
setuptools 59.6.0
setuptools-scm 6.4.2
sfaira 0.3.9
sidecar 0.5.1
simplejson 3.17.6
sinfo 0.3.4
six 1.14.0
slicerator 1.0.0
smmap 5.0.0
sniffio 1.2.0
snowballstemmer 2.2.0
solo-sc 1.2 /source/solo sortedcontainers 2.4.0
soupsieve 2.3.1
sparse 0.13.0
spectra 0.0.11
Sphinx 4.4.0
sphinxcontrib-applehelp 1.0.2
sphinxcontrib-devhelp 1.0.2
sphinxcontrib-htmlhelp 2.0.0
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.3
sphinxcontrib-serializinghtml 1.1.5
SQLAlchemy 1.4.31
sqlparse 0.4.2
squarify 0.4.3
squidpy 1.1.2
statsmodels 0.13.1
stdlib-list 0.8.0
suds-community 1.0.0
superqt 0.2.5.post1
switchlang 0.1.0
tables 3.7.0
tasklogger 1.1.0
tblib 1.7.0
tenacity 8.0.1
tensorboard 2.7.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow 2.7.0
tensorflow-estimator 2.7.0
tensorflow-io-gcs-filesystem 0.23.1
termcolor 1.1.0
terminado 0.12.1
testpath 0.5.0
text-unidecode 1.3
texttable 1.6.4
threadpoolctl 3.0.0
tifffile 2021.11.2
toml 0.10.2
tomli 2.0.0
toolz 0.11.2
torch 1.10.1
torchmetrics 0.6.2
tornado 6.1
tqdm 4.62.3
traitlets 5.1.1
trimap 1.0.15
typeguard 2.13.3
typer 0.4.0
typing-extensions 4.0.1
tzdata 2021.5
tzlocal 4.1
ujson 5.1.0
umap-learn 0.5.2
unattended-upgrades 0.1
url-normalize 1.4.3
urllib3 1.25.8
versioneer 0.21
vine 5.0.0
vispy 0.9.4
wcwidth 0.2.5
webencodings 0.5.1
websocket-client 1.2.3
Werkzeug 2.0.2
wheel 0.34.2
widgetsnbextension 3.5.2
wrapt 1.13.3
WTForms 3.0.1
xarray 0.21.0
xeus-python 0.13.6
xeus-python-shell 0.2.0
xlrd 1.2.0
xmltodict 0.12.0
yamlordereddictloader 0.4.0
yapf 0.32.0
yarl 1.7.2
zarr 2.10.3
zict 2.0.0
zipp 3.7.0
zope.event 4.5.0
zope.interface 5.4.0

...

michalk8 commented 2 years ago

Hi @keithgmitchell , could you please post the full traceback? It contains the information needed for debugging.

keithgmitchell commented 2 years ago
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/cellrank/ul/models/_base_model.py in wrapper(wrapped, instance, args, kwargs)
     64                     instance.reraise()
---> 65                 return wrapped(*args, **kwargs)
     66             except Exception as e:  # noqa: B902

TypeError: prepare() got an unexpected keyword argument 'color'

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_347/1362536770.py in <module>
----> 1 velocygraphtor(annotated_final)

/tmp/ipykernel_347/797497014.py in velocygraphtor(annotated_final)
     75         # )
     76 
---> 77         cr.pl.gene_trends(
     78             adata,
     79             model,

/usr/local/lib/python3.8/dist-packages/cellrank/ul/_utils.py in _genesymbols(wrapped, instance, args, kwargs)
    284         use_raw=kwargs.get("use_raw", False),
    285     ):
--> 286         return wrapped(*args, **kwargs)

/usr/local/lib/python3.8/dist-packages/cellrank/pl/_gene_trend.py in gene_trends(adata, model, genes, lineages, backward, data_key, time_key, time_range, transpose, callback, conf_int, same_plot, hide_cells, perc, lineage_cmap, abs_prob_cmap, cell_color, cell_alpha, lineage_alpha, size, lw, cbar, margins, sharex, sharey, gene_as_title, legend_loc, obs_legend_loc, ncols, suptitle, return_models, n_jobs, backend, show_progress_bar, figsize, dpi, save, plot_kwargs, **kwargs)
    197     models = _create_models(model, genes, lineages)
    198 
--> 199     all_models, models, genes, lineages = _fit_bulk(
    200         models,
    201         _create_callbacks(adata, callback, genes, lineages, **kwargs),

/usr/local/lib/python3.8/dist-packages/cellrank/pl/_utils.py in _fit_bulk(models, callbacks, genes, lineages, time_range, parallel_kwargs, return_models, filter_all_failed, **kwargs)
    483     logg.info("    Finish", time=start)
    484 
--> 485     return _filter_models(
    486         models, return_models=return_models, filter_all_failed=filter_all_failed
    487     )

/usr/local/lib/python3.8/dist-packages/cellrank/pl/_utils.py in _filter_models(models, return_models, filter_all_failed)
    532                     model, FailedModel
    533                 ), f"Expected `FailedModel`, found `{type(model).__name__!r}`."
--> 534                 model.reraise()
    535 
    536     if not np.all(modelmask.values):

/usr/local/lib/python3.8/dist-packages/cellrank/ul/models/_base_model.py in reraise(self)
   1349         """Raise the original exception with additional model information."""
   1350         # retain the exception type and also the original exception
-> 1351         raise type(self._exc)(f"Fatal model failure `{self}`.") from self._exc
   1352 
   1353     def _get_colors(

TypeError: Fatal model failure `<FailedModel[origin=GAM[gene=None, lineage=None, model=GammaGAM(callbacks=['deviance', 'diffs'], fit_intercept=True, max_iter=2000, scale=None, terms=s(0), tol=0.0001, verbose=False)]]>`.
michalk8 commented 2 years ago

Thank you! The problem seems with passing color: TypeError: prepare() got an unexpected keyword argument 'color' Think you'd need to pass it as plot_kwargs={'cell_color': 'pterotyping_donor__anno'} cell_color='pterotyping_donor__anno'; see other options for plotting here

keithgmitchell commented 2 years ago

Ahh did not see that in the traceback, thank you!