high memory consumption and nonetype error
- Dominant language
- Python
- Stars
- 50
- Forks
- 17
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 3
Description
Hi,
I tried to export adata object to mtx format (matrix.mtx, genes.tsv, barcodes.tsv) using besca.export.X_to_mtx while finding that it took a lot o memory. Are there any ways to reduce the memory usage ?

Besides, sometimes the following error occured, how to keep avoid of it ?
```
In [28]: bc.export.X_to_mtx(adata)
writing out matrix.mtx ...
adata.X successfully written to matrix.mtx.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[28], line 1
----> 1 bc.export.X_to_mtx(adata)
File ~/programs/miniconda3/envs/py311/lib/python3.11/site-packages/besca/export/_export.py:124, in X_to_mtx(adata, outpath, write_metadata, geneannotation, additional_geneannotation)
122 fp.write(ENSEMBL + "\t" + symbol + "\t" + feature + "\n")
123 else:
--> 124 for ENSEMBL, symbol in zip(genes_ENSEMBL, genes_SYMBOL):
125 fp.write(ENSEMBL + "\t" + symbol + "\n")
126 fp.close()
TypeError: 'NoneType' object is not iterable
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at besca.export.X_to_mtx in besca/export/_export.py, especially the metadata-writing loop around line 124, and reproduce the export with the reported adata object. Determine why the gene arrays can be None and where memory usage grows; done means the export avoids the NoneType failure and uses less memory without breaking matrix.mtx, genes.tsv, or barcodes.tsv output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100