velocyto-team / velocyto.py

RNA velocity estimation in Python
http://velocyto.org/velocyto.py/
BSD 2-Clause "Simplified" License
160 stars 83 forks source link

gracefully skip empty (low coverage) bam files. #140

Open Xparx opened 6 years ago

Xparx commented 6 years ago

I have come across an issue where velocyto crash when the number of reads aligned in a cell is very few. The velocyto matrix subsequently becomes empty. If you want to run a bulk run this will break the run unexpectedly.

It would be nice to be able to flag to just skip files that are empty. Specific error follows below:

Traceback (most recent call last):
  File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/velocyto/commands/_run.py", line 286, in _run
    ds = loompy.create(filename=outfile, matrix=total, row_attrs=ra, col_attrs=ca, dtype="float32")
TypeError: create() got an unexpected keyword argument 'matrix'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.virtualenvs/singleCellAnalysis/bin/velocyto", line 11, in <module>
    sys.exit(cli())
  File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/velocyto/commands/run_smartseq2.py", line 71, in run_smartseq2
    samtools_memory=1, dump=dump, verbose=verbose, additional_ca=additional_ca)
  File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/velocyto/commands/_run.py", line 297, in _run
    loompy.create(filename=outfile, layers=tmp_layers, row_attrs=ra, col_attrs=ca, file_attrs={"velocyto.__version__": vcy.__version__, "velocyto.logic": logic})
  File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/loompy/loompy.py", line 990, in create
    raise ValueError("Main matrix cannot be empty")
ValueError: Main matrix cannot be empty
lelesama commented 5 years ago

I always have the same ‘ValueError: Main matrix cannot be empty’,can you help me? thank you!