-
Notifications
You must be signed in to change notification settings - Fork 105
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: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (1, 4) + inhomogeneous part. #1109
Comments
Similar issue but with alevin-fry data, concatenated with scanpy. adatas = []
for sample in samples:
adata = pyroe.load_fry(
f"alevin_fry/{sample}/",
output_format="snRNA")
adata.obs['sample'] = sample
adatas.append(adata)
adata = sc.concat(adatas, index_unique='_') |
It has to do with the numpy version they used. It works when you lower numpy to 1.21.1 but installing this is not possible in more recent python versions, so I switched my conda env to python 3.8 and then I could downgrade. It would be nice if they fixed this issue for more recent python/numpy versions. |
Guessing this is the change in numpy: numpy/numpy#14794 . Would a try except at the np.array(res) be an accepted way to deal with handling versions of numpy? |
Thank you for your advice, it works for me! |
The issue has been reported before and has been fixed in #1059. |
hi @WeilerP how did you solve the issue? |
I used the following commands and created a new environment based on this #1040 (comment).
This error is resolved for me. |
Hello, I have tried the tips above and in different threads including setting different environments with python=3.8 or 3.6. I have downgraded pandas and numpy with either numba compatability issues or kernels dying when generating umaps. Is there a way to fix this inhomogenous shape issue without downgrading libraries that the developers are working on? |
Hi, same issue here. |
Thank you so much for your great tool!
I use seuratdisk convert rds to h5ad, and use velocyto convert bam to loom. And I merged these 2 files. and when I got to the: scv.tl.velocity_graph(adata)
It shows: ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (1, 4) + inhomogeneous part.
Here is my all codes:
import anndata
import scvelo as scv
import pandas as pd
import numpy as np
import scanpy as sc
import matplotlib as plt
file_path = '/Users/eaiscui/Desktop/temp/mouseforvelocyto_final.h5ad'
adata=sc.read_h5ad('mouseforvelocyto_final.h5ad')
adata.obs.seurat_clusters=adata.obs.seurat_clusters.astype('category')
ldata1 = anndata.read_loom('/Users/eaiscui/Desktop/loomfiles/Dminus_H2B.loom')
ldata2 = anndata.read_loom('/Users/eaiscui/Desktop/loomfiles/Dplus_H2B.loom')
rename barcodes in order to merge:
barcodes = [bc.split(':')[1] for bc in ldata1.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] + '_10' for bc in barcodes]
ldata1.obs.index = barcodes
barcodes = [bc.split(':')[1] for bc in ldata2.obs.index.tolist()]
barcodes = [bc[0:len(bc)-1] + '_11' for bc in barcodes]
ldata2.obs.index = barcodes
make variable names unique
ldata1.var_names_make_unique()
ldata2.var_names_make_unique()
concatenate the three loom
ldata = ldata1.concatenate([ldata2])
scv.utils.clean_obs_names(adata)
scv.utils.clean_obs_names(ldata)
adata = scv.utils.merge(adata, ldata)
scv.settings.verbosity = 3 # show errors(0), warnings(1), info(2), hints(3)
scv.settings.presenter_view = True # set max width size for presenter view
scv.set_figure_params('scvelo') # for beautified visualization
scv.pl.proportions(adata)
scv.pp.filter_genes(adata, min_shared_counts=20)
scv.pp.normalize_per_cell(adata)
scv.pp.filter_genes_dispersion(adata, n_top_genes=2000)
scv.pp.log1p(adata)
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000)
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)
scv.tl.velocity(adata)
scv.tl.velocity_graph(adata)
Then it shows:
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (1, 4) + inhomogeneous part.
Please help! Thank you so much!
The text was updated successfully, but these errors were encountered: