Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: operands could not be broadcast together with shapes (5305,10) (18027,) (5305,10) #15

Open
wangqihao-code opened this issue Sep 26, 2024 · 2 comments

Comments

@wangqihao-code
Copy link

Dear Axel,
I use the data you gave :
“burkhardt21_merged.h5ad”
“burkhardt21_communications_Ctrl.csv”
“burkhardt21_communications_IFNg.csv”

I encountered a problem when running the following code:
fs.pp.construct_flows_from_cellchat(adata,
cellchat_output_key,
gem_expr_key = 'X_gem',
scale_gem_expr = True,
model_organism = 'human',
flowsig_network_key = 'flowsig_network',
flowsig_expr_key = 'X_flow')

The error message is as follows:
/opt/anaconda3/envs/Python/bin/python /home/inspur/FlowSig/pancreatic_islets_example_script.py
2024-09-26 15:06:59.948040: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
2024-09-26 15:06:59.949669: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2024-09-26 15:06:59.983754: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-09-26 15:07:00.613010: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Removing 6624 genes not expressing in IFNg.
Removing 7700 genes not expressing in Ctrl.
100%|██████████| 30/30 [00:02<00:00, 10.24it/s]
Traceback (most recent call last):
File "/home/inspur/FlowSig/pancreatic_islets_example_script.py", line 23, in
fs.pp.construct_flows_from_cellchat(adata,
File "/opt/anaconda3/envs/Python/lib/python3.8/site-packages/flowsig/preprocessing/_flow_expressions.py", line 233, in construct_flows_from_cellchat
adata_gem, flow_gem_vars = construct_gem_expressions(adata, gem_expr_key, scale_gem_expr)
File "/opt/anaconda3/envs/Python/lib/python3.8/site-packages/flowsig/preprocessing/_flow_expressions.py", line 27, in construct_gem_expressions
adata_gem.X *= scale_factor
ValueError: operands could not be broadcast together with shapes (5305,10) (18027,) (5305,10)

I would appreciate if you could answer for me.

@axelalmet
Copy link
Owner

Hi wangqihao,

First, I am very sorry for taking so long to get back to you.

I double-checked this example and it works fine on my laptop (M2 Macbook Pro).

Given where the error occurs, would you be able to tell me your versions of anndata, scanpy, and possibly tensorflow? Thanks!

Best wishes,
Axel.

@ximenshaoshao
Copy link

Hi axel:
I also encountered the same error as

Dear Axel, I use the data you gave : “burkhardt21_merged.h5ad” “burkhardt21_communications_Ctrl.csv” “burkhardt21_communications_IFNg.csv”

I encountered a problem when running the following code: fs.pp.construct_flows_from_cellchat(adata, cellchat_output_key, gem_expr_key = 'X_gem', scale_gem_expr = True, model_organism = 'human', flowsig_network_key = 'flowsig_network', flowsig_expr_key = 'X_flow')

The error message is as follows: /opt/anaconda3/envs/Python/bin/python /home/inspur/FlowSig/pancreatic_islets_example_script.py 2024-09-26 15:06:59.948040: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0. 2024-09-26 15:06:59.949669: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used. 2024-09-26 15:06:59.983754: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2024-09-26 15:07:00.613010: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT Removing 6624 genes not expressing in IFNg. Removing 7700 genes not expressing in Ctrl. 100%|██████████| 30/30 [00:02<00:00, 10.24it/s] Traceback (most recent call last): File "/home/inspur/FlowSig/pancreatic_islets_example_script.py", line 23, in fs.pp.construct_flows_from_cellchat(adata, File "/opt/anaconda3/envs/Python/lib/python3.8/site-packages/flowsig/preprocessing/_flow_expressions.py", line 233, in construct_flows_from_cellchat adata_gem, flow_gem_vars = construct_gem_expressions(adata, gem_expr_key, scale_gem_expr) File "/opt/anaconda3/envs/Python/lib/python3.8/site-packages/flowsig/preprocessing/_flow_expressions.py", line 27, in construct_gem_expressions adata_gem.X *= scale_factor ValueError: operands could not be broadcast together with shapes (5305,10) (18027,) (5305,10)

I would appreciate if you could answer for me.

my environment versions are as follows:
Package Version


absl-py 2.1.0
adjustText 1.3.0
aiobotocore 2.5.4
aiohappyeyeballs 2.4.4
aiohttp 3.11.11
aioitertools 0.12.0
aiosignal 1.3.2
anndata 0.11.1
annotated-types 0.7.0
annoy 1.17.3
array_api_compat 1.10.0
asciitree 0.3.3
asttokens 2.0.5
astunparse 1.6.3
async-timeout 5.0.1
attrs 24.3.0
biothings-client 0.3.1
bleach 6.2.0
bokeh 3.6.2
botocore 1.31.17
cachetools 5.5.0
causaldag 0.1a163
certifi 2024.12.14
charset-normalizer 3.4.1
click 8.1.8
cloudpickle 3.1.0
colorcet 3.1.0
comm 0.2.1
conditional-independence 0.1a6
contourpy 1.3.1
cycler 0.12.1
dask 2024.12.1
dask-expr 1.1.21
dask-image 2024.5.3
dataclasses 0.6
datashader 0.16.3
debugpy 1.6.7
decorator 5.1.1
dill 0.3.9
distributed 2024.12.1
dm-tree 0.1.8
docopt 0.6.2
docrep 0.3.2
einops 0.8.0
et_xmlfile 2.0.0
exceptiongroup 1.2.0
executing 0.8.3
fasteners 0.19
filelock 3.16.1
flatbuffers 24.12.23
FlowSig 0.1.2
fonttools 4.55.3
frozendict 2.4.6
frozenlist 1.5.0
fsspec 2023.6.0
ftpretty 0.4.0
gast 0.6.0
geopandas 1.0.1
goatools 1.4.12
google-ai-generativelanguage 0.6.10
google-api-core 2.24.0
google-api-python-client 2.156.0
google-auth 2.37.0
google-auth-httplib2 0.2.0
google-generativeai 0.8.3
google-pasta 0.2.0
googleapis-common-protos 1.66.0
graphical-model-learning 0.1a8
graphical-models 0.1a21
grpcio 1.68.1
grpcio-status 1.68.1
h5py 3.12.1
h5sparse 0.1.0
holoviews 1.20.0
httplib2 0.22.0
idna 3.10
igraph 0.11.8
imageio 2.36.1
importlib_metadata 8.5.0
inflect 7.4.0
ipdb 0.13.13
ipykernel 6.29.5
ipython 8.30.0
jedi 0.19.2
Jinja2 3.1.5
jmespath 1.0.1
joblib 1.4.2
jupyter_client 8.6.0
jupyter_core 5.7.2
keras 3.7.0
kiwisolver 1.4.8
kneaddata 0.12.0
lazy_loader 0.4
legacy-api-wrap 1.4.1
leidenalg 0.10.2
libclang 18.1.1
linkify-it-py 2.0.3
llvmlite 0.43.0
locket 1.0.0
louvain 0.8.2
Markdown 3.7
markdown-it-py 3.0.0
MarkupSafe 3.0.2
matplotlib 3.10.0
matplotlib-inline 0.1.6
matplotlib-scalebar 0.8.1
mdit-py-plugins 0.4.2
mdurl 0.1.2
mizani 0.13.1
ml-dtypes 0.4.1
more-itertools 10.5.0
mpmath 1.3.0
msgpack 1.1.0
multidict 6.1.0
multipledispatch 1.0.0
multiscale_spatial_image 1.0.1
mygene 3.2.2
namex 0.0.8
natsort 8.4.0
nest-asyncio 1.6.0
networkx 3.4.2
numba 0.60.0
numcodecs 0.13.1
numexpr 2.10.2
numpy 1.26.4
nvidia-cublas-cu12 12.4.5.8
nvidia-cuda-cupti-cu12 12.4.127
nvidia-cuda-nvrtc-cu12 12.4.127
nvidia-cuda-runtime-cu12 12.4.127
nvidia-cudnn-cu12 9.1.0.70
nvidia-cufft-cu12 11.2.1.3
nvidia-curand-cu12 10.3.5.147
nvidia-cusolver-cu12 11.6.1.9
nvidia-cusparse-cu12 12.3.1.170
nvidia-nccl-cu12 2.21.5
nvidia-nvjitlink-cu12 12.4.127
nvidia-nvtx-cu12 12.4.127
ome-zarr 0.10.2
omnipath 1.0.8
openpyxl 3.1.5
opt_einsum 3.4.0
optree 0.13.1
packaging 24.2
pandas 2.2.3
panel 1.5.5
param 2.2.0
parso 0.8.4
partd 1.4.2
patsy 1.0.1
pexpect 4.8.0
pgmpy 0.1.26
pillow 11.0.0
PIMS 0.7
pip 24.2
platformdirs 3.10.0
plotnine 0.14.4
pooch 1.8.2
progressbar2 4.5.0
prompt-toolkit 3.0.43
propcache 0.2.1
proto-plus 1.25.0
protobuf 5.29.2
psutil 5.9.0
ptyprocess 0.7.0
pure-eval 0.2.2
pyarrow 18.1.0
pyasn1 0.6.1
pyasn1_modules 0.4.1
pyct 0.5.0
pydantic 2.10.4
pydantic_core 2.27.2
pydot 3.0.3
pygam 0.9.1
Pygments 2.15.1
pyliger 0.2.3
pynndescent 0.5.13
pyogrio 0.10.0
pyparsing 3.2.0
pyproj 3.7.0
python-dateutil 2.9.0.post0
python-igraph 0.11.8
python-utils 3.9.1
pytz 2024.2
pyviz_comms 3.0.3
PyYAML 6.0.2
pyzmq 26.2.0
requests 2.32.3
rich 13.9.4
rsa 4.9
s3fs 2023.6.0
scanpy 1.10.4
scikit-image 0.25.0
scikit-learn 1.6.0
scipy 1.11.4
seaborn 0.13.2
session-info 1.0.0
setuptools 75.1.0
shapely 2.0.6
six 1.16.0
slicerator 1.1.0
sortedcontainers 2.4.0
spatial_factorization 0.0.1
spatial_image 1.1.0
spatialdata 0.2.5.post0
squidpy 1.6.2
stack-data 0.2.0
statsmodels 0.14.4
stdlib-list 0.11.0
sympy 1.13.1
tblib 3.0.0
tensorboard 2.18.0
tensorboard-data-server 0.7.2
tensorflow 2.18.0
tensorflow-io-gcs-filesystem 0.37.1
tensorflow-probability 0.25.0
termcolor 2.5.0
texttable 1.7.0
tf_keras 2.18.0
threadpoolctl 3.5.0
tifffile 2024.12.12
tomli 2.2.1
toolz 1.0.0
torch 2.5.1
tornado 6.4.2
tqdm 4.67.1
traitlets 5.14.3
triton 3.1.0
typeguard 4.4.1
typing 3.7.4.3
typing_extensions 4.12.2
tzdata 2024.2
uc-micro-py 1.0.3
umap-learn 0.5.7
uritemplate 4.1.1
urllib3 1.26.20
validators 0.34.0
wcwidth 0.2.5
webencodings 0.5.1
Werkzeug 3.1.3
wheel 0.44.0
wrapt 1.17.0
xarray 2024.7.0
xarray-dataclasses 1.9.1
xarray-datatree 0.0.15
xarray-schema 0.0.3
xarray-spatial 0.4.0
xgboost 2.1.3
XlsxWriter 3.2.0
xyzservices 2024.9.0
yarl 1.18.3
zarr 2.18.3
zict 3.0.0
zipp 3.21.0

Please check these

PS: site-factorization packages is not suitable for python3.8, so python 3.10 was used for this env.
Thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants