thank you my file was too big to be opened in notepad ++
hi,
i have a correlation matrix of genes but i am going to remove alphabet from rows and columns to prepare my file for matlb i did like below
> mycounts <- read.table("tmatnorm_rld500.txt", header = T, sep = "\t", row.names=1)
> head(mycounts[,1:3])
AT1G01060 AT1G01170 AT1G01180
AT1G01060 1.0000000 0.3193360 0.6272994
AT1G01170 0.3193360 1.0000000 0.3178880
AT1G01180 0.6272994 0.3178880 1.0000000
AT1G01260 0.2658624 0.3588030 0.2542234
AT1G01380 0.6178751 0.1561297 0.7052692
AT1G01490 0.5990499 0.6129301 0.6424225
> rownames(mycounts) <- NULL
> head(mycounts[,1:3])
AT1G01060 AT1G01170 AT1G01180
[1,] 1.0000000 0.3193360 0.6272994
[2,] 0.3193360 1.0000000 0.3178880
[3,] 0.6272994 0.3178880 1.0000000
[4,] 0.2658624 0.3588030 0.2542234
[5,] 0.6178751 0.1561297 0.7052692
[6,] 0.5990499 0.6129301 0.6424225
> colnames(mycounts) <- NULL
>
> head(mycounts[,1:3])
[,1] [,2] [,3]
[1,] 1.0000000 0.3193360 0.6272994
[2,] 0.3193360 1.0000000 0.3178880
[3,] 0.6272994 0.3178880 1.0000000
[4,] 0.2658624 0.3588030 0.2542234
[5,] 0.6178751 0.1561297 0.7052692
[6,] 0.5990499 0.6129301 0.6424225
> write.table(mycounts, file = "correlation.txt", dec = ".", sep = "\t", quote = FALSE, row.names=F)
> mycounts <- read.table("correlation.txt", header = T, sep = "\t")
> head(mycounts[,1:3])
V1 V2 V3 <---this line
1 1.0000000 0.3193360 0.6272994
2 0.3193360 1.0000000 0.3178880
3 0.6272994 0.3178880 1.0000000
4 0.2658624 0.3588030 0.2542234
5 0.6178751 0.1561297 0.7052692
6 0.5990499 0.6129301 0.6424225
but as you consider, i have something in colnames?? then how I can get rid of alphabet and only have the similarity values please?
thank you
4 answers
Add col.names=FALSE to the write.table() command and you should have a matrix with no row or column names.
write.table(m,file="outfile,txt",sep="\t", col.names = F, row.names = F)
V1 to V3 is what R assigns to columns, when there are no header names!
Try open your text file in notepad or something similar and see if you have colnames in there?
You could use less, vi, or head -1 tmatnorm_rld500.txt to see the first line(s) of your file without having to open it.
sorry you mean I did like below
> less(mycounts)
Error: could not find function "less"
> head -1 mycounts
Error: unexpected symbol in "head -1 mycounts"
less, vi, and head are all linux/unix commands that will not run in R.
These (less, head, vi) are bash commands working only in pure linux. These commands do not work in R unless you invoke the system or system2 function in R
I am in windows
Try to use notepad++ directly (easier for you) or the col-names and row-names FALSE
thank you Antonio
I am not an ms-dos expert, but you can check your file in the command line console of windows. If you open the program Command Prompt, you'll have to go to your directory with your file and type in:
more file.txt
It will show you the first 'page' of your file, you can then stop showing it with CTRL-break.
thank you for your suggestion
Log in to answer this question.