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: zero-size array to reduction operation #153

Open
laracbusby opened this issue Oct 1, 2024 · 0 comments
Open

ValueError: zero-size array to reduction operation #153

laracbusby opened this issue Oct 1, 2024 · 0 comments

Comments

@laracbusby
Copy link

laracbusby commented Oct 1, 2024

Hi,

I'm in the process of trying to use SAMap to look at sea lamprey (my own) and mouse (previously published) scRNA-seq data. I have been hitting a roadblock with the SAMap step, and I am not sure whether this is consequence of issues with my use of the gene name conversion functionality, or if it relates to my input file format.

I used RefSeq annotation files to map my reads in CellRanger and have created np.arrays for converting protein id's to gene names. From a cursory check, I feel relatively confident that my protein IDs in my conversion tables match the ones in my BLAST outputs.

Screenshot 2024-09-30 at 17 53 54

In order to get my input scRNAseq data into the appropriate .h5ad format, I read my data into Seurat in RStudio and then used the following to export it as a .h5ad file:

`t24 <- Read10X(data.dir = "/Users/larabusby/Dropbox/Berkeley/jupyter/Analysis station/Remap lamprey/T24_RefSeq/outs/filtered_feature_bc_matrix")

t24 <- CreateSeuratObject(counts = t24, project = "t24", min.cells = 3, min.features = 200)

SaveH5Seurat(t24, filename = "t24_refseq.h5Seurat")

Convert("t24_refseq.h5Seurat", dest = "h5ad")
`

I have tried to run SAMap as follows:
`fn1 = 't24_refseq.h5ad'
fn2 = 'e95.h5ad'

filenames = {'pm':fn1,'mm':fn2}

n1 = np.array(Pm_attrib_Prot_correct)
n2 = np.array(Mm_attrib_Prot_correct)

sm = SAMAP(
filenames,
f_maps = 'maps/fixed/',
names = {'pm' : n1, 'mm' : n2})`

The error that I get is as follows:
` Traceback (most recent call last)
Cell In[277], line 4
1 n1 = np.array(Pm_attrib_Prot_correct)
2 n2 = np.array(Mm_attrib_Prot_correct)
----> 4 sm = SAMAP(
5 filenames,
6 f_maps = 'maps/fixed/',
7 names = {'pm' : n1, 'mm' : n2})

File ~/miniconda3/envs/myenv/lib/python3.9/site-packages/samap/mapping.py:149, in SAMAP.init(self, sams, f_maps, names, keys, resolutions, gnnm, save_processed, eval_thr)
144 if names is not None:
145 gnnm, gns_dict, gns = _coarsen_blast_graph(
146 gnnm, gns, names
147 )
--> 149 gnnm = _filter_gnnm(gnnm, thr=0.25)
150 else:
151 gnnm, gns, gns_dict = gnnm

File ~/miniconda3/envs/myenv/lib/python3.9/site-packages/samap/mapping.py:1362, in _filter_gnnm(gnnm, thr)
1360 def _filter_gnnm(gnnm, thr=0.25):
1361 x, y = gnnm.nonzero()
-> 1362 mas = gnnm.max(1).A.flatten()
1363 gnnm4 = gnnm.copy()
1364 gnnm4.data[gnnm4[x, y].A.flatten() < mas[x] * thr] = 0

File ~/miniconda3/envs/myenv/lib/python3.9/site-packages/scipy/sparse/_data.py:333, in _minmax_mixin.max(self, axis, out)
303 def max(self, axis=None, out=None):
304 """
305 Return the maximum of the matrix or maximum along an axis.
306 This takes all elements into account, not just the non-zero ones.
(...)
331
332 """
--> 333 return self._min_or_max(axis, out, np.maximum)

File ~/miniconda3/envs/myenv/lib/python3.9/site-packages/scipy/sparse/_data.py:217, in _minmax_mixin._min_or_max(self, axis, out, min_or_max)
214 axis += 2
216 if (axis == 0) or (axis == 1):
--> 217 return self._min_or_max_axis(axis, min_or_max)
218 else:
219 raise ValueError("axis out of range")

File ~/miniconda3/envs/myenv/lib/python3.9/site-packages/scipy/sparse/_data.py:168, in _minmax_mixin._min_or_max_axis(self, axis, min_or_max)
166 N = self.shape[axis]
167 if N == 0:
--> 168 raise ValueError("zero-size array to reduction operation")
169 M = self.shape[1 - axis]
170 idx_dtype = self._get_index_dtype(maxval=M)

ValueError: zero-size array to reduction operation`

It is not clear to me what this issue relates to - I saw that another poster (#114) had the same error and resolved it by preprocessing their transcript files for BLAST. As far as I can tell this should not be necessary provided appropriate use of the 'names' term in the SAMAP function.

I would really appreciate any suggestions about the likely origin of this error - thanks in advance!

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

1 participant