velocyto.py icon indicating copy to clipboard operation
velocyto.py copied to clipboard

ValueError: Main matrix cannot be empty

Open lelesama opened this issue 6 years ago • 10 comments

I always have the same error 'ValueError: Main matrix cannot be empty' 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 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 avatar Feb 23 '19 14:02 lelesama

What is the command you are running?

gioelelm avatar Mar 26 '19 15:03 gioelelm

Hey, I had the same error using the Velocyto run command. Which was thrown at the very end when it tried to write the loom file. And appears to be related to another error of an unexpected keyword argument for 'matrix'.

This does seem related, though slightly different from the problem in issues #110 which seems to indicated an issue with the barcode file, though I did not use one, and in the past I was able to use 'velocyto run' without a -b argument. So I'm not sure if there is a different issue here or not.

Relevant code:

velocyto run -m /PATH/hg19_rmsk.gtf /PATH/cellsorted_HM_final.bam /PATH/GRCh37.74.gtf

2019-12-17 12:44:48,916 - DEBUG - Writing loom file
Traceback (most recent call last):
  File "/usr/local/lib64/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 "/usr/local/bin/velocyto", line 11, in <module>
    load_entry_point('velocyto==0.17.17', 'console_scripts', 'velocyto')()
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib64/python3.6/site-packages/velocyto/commands/run.py", line 116, in run
    samtools_memory=samtools_memory, dump=dump, loom_numeric_dtype=dtype, verbose=verbose, additional_ca=additional_ca)
  File "/usr/local/lib64/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 "/usr/local/lib/python3.6/site-packages/loompy/loompy.py", line 980, in create
    raise ValueError("Main matrix cannot be empty")
ValueError: Main matrix cannot be empty

ArcusGears avatar Dec 17 '19 19:12 ArcusGears

Hi, I get the exact same error running "velocyto run-smartseq2" on smartseq2 samples aligned with kallisto (from which I got pseudobam files). Was this "empty matrix" issue solved? Cause I went through issue #110 but couldn't find a suitable solution...

Thanks for the help! BW Sabrina

SabrinaITNL avatar Aug 10 '20 16:08 SabrinaITNL

@SabrinaITNL, have you fond the solution to this issue ? Pease let me know.

Thanks.

akhst7 avatar Dec 26 '20 19:12 akhst7

Hi @akhst7, No I still haven't find a solution to the issue. I keep getting the "empry matrix" error.

BW Sabrina

SabrinaITNL avatar Jan 15 '21 11:01 SabrinaITNL

Hi @SabrinaITNL, my issue was solved by providing the right matrix file.

akhst7 avatar Jan 15 '21 15:01 akhst7

Hi @SabrinaITNL, my issue was solved by providing the right matrix file.

hi, can you briefly talk about how you solve it by providing matrix file??

yyc4217 avatar May 11 '21 07:05 yyc4217

@yyc4217,

A following is the line I used to run Velocyte;

velocyto run -b filtered_feature_bc_matrix/barcodes.tsv -o /temp/home -m GRCh38_rmsk.gtf cellsorted_PBMC.bam.bam refdata-gex-GRCh38-2020-A/genes/genes.gtf

My issue was not using the right barcodes.tsv.

I hope this helps and let me know if you need a further help.

akhst7 avatar May 12 '21 13:05 akhst7

You might want to check if any of the cell barcodes ("CB" tag in the .bam file) contain dashes ("-"), since velocyto.py uses dashes to determine barcodes. Reference: https://github.com/velocyto-team/velocyto.py/blob/0963dd2df0ac802c36404e0f434ba97f07edfe4b/velocyto/counter.py#L211-L212

pormr avatar Sep 21 '21 03:09 pormr