Hi,
I encountered a strange issue while reading in a data table from txt
format. If I read it from txt
by read.table
it does not include all rows but if I convert to csv
and read it with read.csv
its perfect. Does someone know the issue or is it my code?
Here is the file.
test <- read.table("./Annotations/all_genes_pombase.txt",
+ header=T,
+ sep="\t",
+ row.names=1,
+ stringsAsFactors = F)
> dim(test)
[1] 4533 7
> str(test)
'data.frame': 4533 obs. of 7 variables:
$ name : chr "SPAC1002.01" "pom34" "gls2" "taf11" ...
$ chromosome : chr "I" "I" "I" "I" ...
$ description : chr "conserved fungal protein " "nucleoporin Pom34 " "glucosidase II alpha subunit Gls2 " "transcription factor TFIID complex subunit Taf11 (predicted) " ...
$ feature_type: chr "protein_coding" "protein_coding" "protein_coding" "protein_coding" ...
$ strand : int 1 1 -1 -1 -1 -1 -1 -1 -1 -1 ...
$ start : int 1798347 1799061 1799915 1803624 1804548 1807270 1807996 1809480 1811408 1813740 ...
$ end : int 1799015 1800053 1803141 1804491 1806797 1807781 1809433 1811361 1813805 1815796 ...
try using
read.delim
instead and specifying the corresponding arguments for your text fileThanks steve and Devon! read.delim works fine!
also it would be more useful to see the actual source txt file, using something like
head
in the terminalThe file is linked to in the post.
It works fine with
read.delim
, for whatever that's worth.My solution is like this: suppose
gene.tab.matrix.v4.txt
is the file you want to read. what you need to do is replace all special symbols such as`
,(
,)
to-
and then read it withread.table
.Perl
script to replace these special symbols is like this way:A few points: