Question: Error in reading expression matrix
0
gravatar for sidrah.maryam
3 months ago by
sidrah.maryam20 wrote:

Hello I am trying to read expression matrix using the code :

adata.var = sc.read_csv('/home/sidrah19220/rna/auxfile/EXP0001_PCG_beforeQC.txt')

But I am facing this error:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/sidrah19220/anaconda3/envs/scenic_protocol/lib/python3.6/site-packages/anndata/_io/read.py", line 48, in read_csv return read_text(filename, delimiter, first_column_names, dtype) File "/home/sidrah19220/anaconda3/envs/scenic_protocol/lib/python3.6/site-packages/anndata/_io/read.py", line 322, in read_text return _read_text(f, delimiter, first_column_names, dtype) File "/home/sidrah19220/anaconda3/envs/scenic_protocol/lib/python3.6/site-packages/anndata/_io/read.py", line 352, in _read_text raise ValueError(f"Did not find delimiter {delimiter!r} in first line.") ValueError: Did not find delimiter ',' in first line.

adata.var = sc.read_csv('/home/sidrah19220/rna/auxfile/EXP0001_PCG_beforeQC.txt') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/sidrah19220/anaconda3/envs/scenic_protocol/lib/python3.6/site-packages/anndata/_io/read.py", line 48, in read_csv return read_text(filename, delimiter, first_column_names, dtype) File "/home/sidrah19220/anaconda3/envs/scenic_protocol/lib/python3.6/site-packages/anndata/_io/read.py", line 322, in read_text return _read_text(f, delimiter, first_column_names, dtype) File "/home/sidrah19220/anaconda3/envs/scenic_protocol/lib/python3.6/site-packages/anndata/_io/read.py", line 352, in _read_text raise ValueError(f"Did not find delimiter {delimiter!r} in first line.") ValueError: Did not find delimiter ',' in first line.

Please suggest the solution.

I even tried using the delimiter argument, but no help.

sequencing rna-seq python R • 206 views
ADD COMMENTlink modified 3 months ago by Shalu Jhanwar470 • written 3 months ago by sidrah.maryam20

what's the delimiter in input file? By default, delimiter is comma. Seems that is not found in the very first line.

ADD REPLYlink modified 3 months ago • written 3 months ago by cpad011214k

Since the input file is txt while it is looking for csv file you have to specify the delimiter argument. Else re-save the file with extension .csv. that should work.

ADD REPLYlink written 3 months ago by Arindam Ghosh310
1

It did work now. Thank you.

ADD REPLYlink written 3 months ago by sidrah.maryam20
1
gravatar for Shalu Jhanwar
3 months ago by
Shalu Jhanwar470
Switzerland
Shalu Jhanwar470 wrote:

It looks like the header line does not contain the same number of columns as the rest of the files. I'd suggest trying to load the dataset without header (e.g. header=None). If it reads successfully, then you can rename the columns directly in the object. Alternatively, you can skip the header line while reading the file into an object.

ADD COMMENTlink written 3 months ago by Shalu Jhanwar470

I removed the delimiter argument from default. and it did work. Thnak you for the help

ADD REPLYlink written 3 months ago by sidrah.maryam20

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one answer if they work. This will help future users that might find this post find the right answer.

Upvote|Bookmark|Accept

ADD REPLYlink written 4 weeks ago by RamRS30k

Thanks for the suggestion. I would do so next time onwards. :)

ADD REPLYlink written 10 days ago by sidrah.maryam20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1573 users visited in the last hour