data.matrix returns txt file packed into a single column
1
0
Entering edit mode
6.7 years ago
eculfa • 0

I am trying to convert my txt file into a data.matrix before generating a heatmap out of it bur when I try data.matrix function, resulting matrix only consists of two columns; sample numbers and all the other information (basemean, log2foldchange, pvalue etc.) packed into a single column. How do I fix this?

Thank you so much,

this is where you can find the .txt file I am using. https://www.dropbox.com/s/n13ny5ropeg8p83/deseq2uaa.txt?dl=0

commands I used;

install.packages("gplots")
library(gplots)
x <- read.csv("deseq2uaa.txt", check.names= FALSE)
y <- data.matrix(x)
R • 1.4k views
ADD COMMENT
0
Entering edit mode

Please post your actual code

ADD REPLY
1
Entering edit mode
6.7 years ago

Something like this ? You were close with your code above, just set a separator (sep="\t") and chose the first line of your file as column names (header=TRUE)

df <- read.csv(file="deseq2uaa.txt", header=TRUE, sep="\t")
matrix <- as.matrix(df)
ADD COMMENT
0
Entering edit mode

thank you so much! this helped. :)

ADD REPLY
0
Entering edit mode

Hello,

I now have another problem. After I converted my data frame into a matrix, I wanted to generate a heatmap but I don't know how to only use the data from "log2foldchange" column to generate the heatmap. I would also like to exclude any "NA" within that specific column. How do I do this? Do you have an idea?

Thanks so much.

ADD REPLY
0
Entering edit mode

I suggest you to take a deep look at this vignette (DESeq2) :

https://bioconductor.org/packages/3.7/bioc/vignettes/DESeq2/inst/doc/DESeq2.html

Try to experiment all the command line of this doc in order to assimilate the process

You will find how to remove your 0 counts row, how to normalize your counts for exploratory analysis, and how to create a proper heatmap.

Also, to remove rows with NA you can try the following ( https://stackoverflow.com/questions/4862178/remove-rows-with-nas-missing-values-in-data-frame ) :

df[complete.cases(df), ]
ADD REPLY
0
Entering edit mode

Thank you so much for all the feedback Bastien. I appreciate it.

ADD REPLY

Login before adding your answer.

Traffic: 2127 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6