Question: data.matrix returns txt file packed into a single column
0
gravatar for eculfa
10 months ago by
eculfa0
eculfa0 wrote:

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 • 298 views
ADD COMMENTlink modified 10 months ago by zx87546.5k • written 10 months ago by eculfa0

Please post your actual code

ADD REPLYlink written 10 months ago by russhh4.2k
1
gravatar for Bastien Hervé
10 months ago by
Bastien Hervé3.3k
Limoges, CBRS, France
Bastien Hervé3.3k wrote:

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 COMMENTlink modified 10 months ago • written 10 months ago by Bastien Hervé3.3k

thank you so much! this helped. :)

ADD REPLYlink written 10 months ago by eculfa0

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 REPLYlink written 10 months ago by eculfa0

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 REPLYlink written 10 months ago by Bastien Hervé3.3k

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

ADD REPLYlink written 10 months ago by eculfa0
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: 754 users visited in the last hour