Skip to content

error of read.table when spaces are present in columns, (" (1 of many)" mention cases)  #1

@sebriq

Description

@sebriq

Error of read.table in server.R; due to the presence of spaces in upstream_gene_symbol and as_gene_symbol columns; where and when " (1 of many)" mention is added.

procedure to find the error's cause.

Rscript app.R -c ~/Bureau/projets/RegenLink/2018/DiffContigsInfos.tsv -s ~/Bureau/projets/RegenLink/2018/sample_conditions_full.tsv

Listening on http://0.0.0.0:8080
Warning: Error in scan: la ligne 125 n'avait pas 57 éléments
55: scan
54: read.table
53: loadContigsfile [/home/seb/Bureau/projets/RegenLink/2018/dekupl-viewer/src/server.R#11]
52: server [/home/seb/Bureau/projets/RegenLink/2018/dekupl-viewer/src/server.R#22]
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
la ligne 125 n'avait pas 57 éléments

cat ~/Bureau/projets/RegenLink/2018/DiffContigsInfos.tsv | sed -e 's/(//' | sed -e 's/)//' > DiffContigTest.tsv # remove first double parenthesis

Warning: Error in scan: la ligne 125 n'avait pas 57 éléments
55: scan
54: read.table
53: loadContigsfile [/home/seb/Bureau/projets/RegenLink/2018/dekupl-viewer/src/server.R#11]
52: server [/home/seb/Bureau/projets/RegenLink/2018/dekupl-viewer/src/server.R#22]
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
la ligne 125 n'avait pas 57 éléments

-> Not due to the parenthesis itself

cat ~/Bureau/projets/RegenLink/2018/DiffContigsInfos.tsv | sed -e 's/ (1 of many)/_(1_of_many)/' > DiffContigTest.tsv # remove all spaces

~/Bureau/projets/RegenLink/2018/dekupl-viewer/src$ Rscript app.R -c ./DiffContigTest.tsv -s ~/Bureau/projets/RegenLink/2018/sample_conditions_full.tsv

Warning: Error in scan: la ligne 2543 n'avait pas 57 éléments
55: scan
54: read.table
53: loadContigsfile [/home/seb/Bureau/projets/RegenLink/2018/dekupl-viewer/src/server.R#11]
52: server [/home/seb/Bureau/projets/RegenLink/2018/dekupl-viewer/src/server.R#22]
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
la ligne 2543 n'avait pas 57 éléments

-> report the error to line 2543 containing the next " (1 of many)" mention.

-> so the error seems to be due to read.table which doesn't like the spaces in a tsv without quotes.

The simpler solution is to add "sep = "\t"" to the read.table function.
This correction seems to work in my case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions