-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Please make sure these conditions are met
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pertpy.
- (optional) I have confirmed this bug exists on the main branch.
Report
Good:
import pertpy as pt
import scanpy as sc
import schist
adata = pt.dt.haber_2017_regions()
sc.pp.neighbors(adata)
schist.inference.nested_model(adata, n_init=100, random_seed=5678)
tasccoda_model = pt.tl.Tasccoda()
tasccoda_data = tasccoda_model.load(
adata, type="cell_level", cell_type_identifier="nsbm_level_1",
sample_identifier="batch", covariate_obs=["condition"],
levels_orig=["nsbm_level_4", "nsbm_level_3", "nsbm_level_2", "nsbm_level_1"],
add_level_name=True
)
tasccoda_model.prepare(tasccoda_data, modality_key="coda",
reference_cell_type="18",
formula="condition",
pen_args=dict(phi=0, lambda_1=3.5),
tree_key="tree")
tasccoda_model.run_nuts(tasccoda_data, modality_key="coda", rng_key=1234,
num_samples=10000, num_warmup=1000)
sc.tl.umap(tasccoda_data["rna"])
tasccoda_model.plot_effects_umap(tasccoda_data,
effect_name=["effect_df_condition[T.Salmonella]",
"effect_df_condition[T.Hpoly.Day3]",
"effect_df_condition[T.Hpoly.Day10]"],
cluster_key="nsbm_level_1")
Bad:
import pertpy as pt
from matplotlib import cm
import scanpy as sc
haber_cells = pt.dt.haber_2017_regions()
sccoda_model = pt.tl.Sccoda()
sccoda_data = sccoda_model.load(
haber_cells,
type="cell_level",
generate_sample_level=True,
cell_type_identifier="cell_label",
sample_identifier="batch",
covariate_obs=["condition"],
)
sccoda_data.mod["coda_salm"] = sccoda_data["coda"][
sccoda_data["coda"].obs["condition"].isin(["Control", "Salmonella"])
].copy()
sc.pp.pca(sccoda_data["rna"])
sc.pp.neighbors(sccoda_data["rna"])
sc.tl.umap(sccoda_data["rna"])
sccoda_model.plot_effects_umap(
sccoda_data, modality_key_2="coda_salm",
effect_name="effect_df_condition[T.Salmonella]",
cluster_key="cell_label"
)
Traceback:
Traceback (most recent call last):
File "<path>/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
return self._engine.get_loc(casted_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
File "index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 7081, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 7089, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Effect'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<path>/pertpy/tools/_coda/_base_coda.py", line 2187, in plot_effects_umap
data_rna.obs[effect] = [data_coda.varm[effect].loc[f"{c}", "Effect"] for c in data_rna.obs[cluster_key]]
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "<path>/lib/python3.12/site-packages/pandas/core/indexing.py", line 1183, in __getitem__
return self.obj._get_value(*key, takeable=self._takeable)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/lib/python3.12/site-packages/pandas/core/frame.py", line 4214, in _get_value
series = self._get_item_cache(col)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/lib/python3.12/site-packages/pandas/core/frame.py", line 4638, in _get_item_cache
loc = self.columns.get_loc(item)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path>/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3812, in get_loc
raise KeyError(key) from err
KeyError: 'Effect'
See #773 (comment) and #773 (comment).
Versions
Dependency | Version |
---|---|
colorama | 0.4.6 |
blitzgsea | 1.3.54 |
psutil | 7.0.0 |
statsmodels | 0.14.4 |
opt_einsum | 3.4.0 |
reportlab | 4.4.1 |
certifi | 2025.4.26 (2025.04.26) |
xarray | 2025.4.0 |
nvidia-curand-cu12 | 10.3.7.77 |
sympy | 1.14.0 |
nvidia-cufft-cu12 | 11.3.0.4 |
seaborn | 0.13.2 |
requests | 2.32.3 |
numpyro | 0.18.0 |
decoupler | 1.8.0 |
lightning-utilities | 0.14.3 |
arrow | 1.3.0 |
sphinxcontrib-htmlhelp | 2.1.0 |
sphinxcontrib-serializinghtml | 2.0.0 |
PyQt6_sip | 13.10.0 |
networkx | 3.4.2 |
idna | 3.10 |
leidenalg | 0.10.2 |
lamin_utils | 0.14.0 |
tqdm | 4.67.1 |
patsy | 1.0.1 |
nvidia-cuda-nvrtc-cu12 | 12.6.77 |
parso | 0.8.4 |
llvmlite | 0.43.0 |
nvidia-cufile-cu12 | 1.11.1.6 |
cffi | 1.17.1 |
anndata | 0.11.4 |
sphinxcontrib-bibtex | 2.6.3 |
natsort | 8.4.0 |
typing_extensions | 4.13.2 |
pyparsing | 3.2.3 |
scanpy | 1.11.1 |
filelock | 3.18.0 |
toyplot | 2.0.0 |
flax | 0.10.6 |
optax | 0.2.4 |
custom-inherit | 2.4.1 |
lightning | 2.5.1.post0 |
ipython | 9.2.0 |
nvidia-cublas-cu12 | 12.6.4.1 |
etils | 1.12.2 |
charset-normalizer | 3.4.2 |
scikit-misc | 0.5.1 |
ete4 | 4.3.0 |
zstandard | 0.23.0 |
h5py | 3.13.0 |
nvidia-nvjitlink-cu12 | 12.6.85 |
PyQt6-Qt6 | 6.9.0 |
chex | 0.1.89 |
pycparser | 2.22 |
importlib_resources | |
absl-py | 2.2.2 |
sphinxcontrib-devhelp | 2.0.0 |
nvidia-cusolver-cu12 | 11.7.1.2 |
nvidia-nvtx-cu12 | 12.6.77 |
pandas | 2.2.3 |
decorator | 5.2.1 |
defusedxml | 0.7.1 |
packaging | 24.2 |
sphinxcontrib-qthelp | 2.0.0 |
numpy | 1.26.4 |
traitlets | 5.14.3 |
PyYAML | 6.0.2 |
nvidia-cuda-cupti-cu12 | 12.6.80 |
pypng | 0.20220715.0 |
pyomo | 6.9.2 |
legacy-api-wrap | 1.4.1 |
sphinxcontrib-jsmath | 1.0.1 |
lineax | 0.0.8 |
prompt_toolkit | 3.0.51 |
ml_collections | 1.1.0 |
pytz | 2025.2 |
equinox | 0.12.2 |
jedi | 0.19.2 |
triton | 3.3.0 |
wadler_lindig | 0.1.6 |
stack-data | 0.6.3 |
pytorch-lightning | 2.5.1.post0 |
session-info2 | 0.1.2 |
loguru | 0.7.3 |
simplejson | 3.20.1 |
adjustText | 1.3.0 |
numba | 0.60.0 |
multipledispatch | 1.0.0 (0.6.0) |
sparse | 0.17.0 |
cycler | 0.12.1 |
fsspec | 2025.5.0 |
jaxtyping | 0.3.2 |
ml_dtypes | 0.5.1 |
asttokens | 3.0.0 |
sparsecca | 0.3.1 |
joblib | 1.5.0 |
igraph | 0.11.8 |
mpmath | 1.3.0 |
nvidia-cusparse-cu12 | 12.5.4.2 |
jaxlib | 0.6.1 |
nvidia-cudnn-cu12 | 9.5.1.17 |
nvidia-cuda-runtime-cu12 | 12.6.77 |
torchmetrics | 1.7.1 |
urllib3 | 2.4.0 |
mudata | 0.3.1 |
sphinxcontrib-applehelp | 2.0.0 |
jaxopt | 0.8.5 |
attrs | 25.3.0 |
ott-jax | 0.5.0 |
scvi-tools | 1.3.1.post1 |
threadpoolctl | 3.6.0 |
pyarrow | 20.0.0 |
toolz | 1.0.0 |
fast-array-utils | 1.2.1 |
python-dateutil | 2.9.0.post0 |
scipy | 1.15.2 |
PyQt6 | 6.9.0 |
chardet | 5.2.0 |
kiwisolver | 1.4.8 |
matplotlib | 3.10.3 |
scikit-learn | 1.5.2 |
Component | Info |
---|---|
Python | 3.12.10 |
OS | Linux-6.9.8-amd64-x86_64-with-glibc2.41 |
Updated | 2025-05-22 10:00 |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working