Open brianpenghe opened 2 years ago
It seems to be something about the genes.tsv
. I replaced it with another genes.tsv and it didn't produce errors.
@brianpenghe, do you have a copy of your original file? Any idea what could have been different?
@dn-ra, would you be able to share the first couple lines of your file, and let me know how it was generated?
@brianpenghe, do you have a copy of your original file? Any idea what could have been different?
@dn-ra, would you be able to share the first couple lines of your file, and let me know how it was generated?
I think I found the cause: When the genes.tsv only has one column it doesn't work and throws this error.
Thanks!
@brianpenghe What column did you add to the genes.tsv so that it worked? I currently have a genes.tsv file with one column for the gene names and am getting the same error as you did. Thanks!
If that’s a case that can happen, we should deal with it. @brianpenghe please share a few lines of the file in a code block.
In my case, there were three files:
barcodes.tsv
genes.tsv
matrix.mtx
What didn't work was a genes.tsv
that looks like this:
AL627309.1
AL669831.5
LINC00115
FAM41C
AL645608.3
SAMD11
NOC2L
KLHL17
PLEKHN1
PERM1
What worked was a genes.tsv
that looks like this:
ENSG00000243485 MIR1302-2HG
ENSG00000237613 FAM138A
ENSG00000186092 OR4F5
ENSG00000238009 AL627309.1
ENSG00000239945 AL627309.3
ENSG00000239906 AL627309.2
ENSG00000241599 AL627309.4
ENSG00000236601 AL732372.1
ENSG00000284733 OR4F29
ENSG00000235146 AC114498.1
So I had to import the data with the latter genes.tsv
and then replaced the var.names with the correct genes.
I noticed that the sc.read_10x_mtx
function can read both .gz or text formats and decide on their own what format they are. Whether the gene file name is genes.tsv
or 'features.tsv' also matters.
Any ideas?
I've fixed the error I was getting, which was posted on another issue and referenced here. Here's the solution that worked for me: https://github.com/scverse/scanpy/issues/1916#issuecomment-1286404697
I encountered the same error (KeyError: 1) when trying to load the .mtx file with scanpy.read_10x_mtx(). After several unsuccessful attempts at renaming the columns and indices in the 'genes.tsv' file in different ways, I found a workaround that worked for me:
This approach allowed me to bypass the KeyError and successfully load the data.
I have a similar issue to this comment.
Carraro=sc.read_10x_mtx('/mnt/Carraro',var_names='gene_ids')
Switching to
gene_symbols
didn't workError messages:
Any ideas?