Question: extract count data for a gene ID list in R
0
gravatar for Bioinfonext
4 months ago by
Bioinfonext250
Korea
Bioinfonext250 wrote:

Hello,

I am using below R code to extract count data for multiple samples from a file but not able to write as a matrix could you please help with it?

data = read.table("DESeq2-Norm-Count-Table.txt",header=T,sep='\t',check.names=F)
> otu.list = read.table("Aman_root_gene.list.txt",header=F,sep='\t',check.names=F)
> i <- row.names(data) %in% otu.list[[1]]
> dim(data[i, ])
[1] 25 72
> write.table(i,"Aman_root_25.gene.txt",sep="\t")

Many thanks

R • 142 views
ADD COMMENTlink written 4 months ago by Bioinfonext250

Please show content of that file.

ADD REPLYlink written 4 months ago by ATpoint38k
1
gravatar for Bioinfonext
4 months ago by
Bioinfonext250
Korea
Bioinfonext250 wrote:

thanks, it is sorted by using below code.

> df = as.data.frame(data[i, ])
> write.table(df,"Aman_root_25.gene.txt",sep="\t")

Thanks

ADD COMMENTlink modified 4 months ago • written 4 months ago by Bioinfonext250

Do you not have to use:

write.table(df, 'Aman_root_25.gene.txt', sep = '\t', quote = FALSE)

?

ADD REPLYlink modified 4 months ago • written 4 months ago by Kevin Blighe65k

Many thanks, I have updated the correct code, why we need to use quote= FALSE?

ADD REPLYlink written 4 months ago by Bioinfonext250

Yes, does changing it to df solve the problem?

quote = FALSE just prevents R adding quotations ( " ) to any text in the output file.

ADD REPLYlink written 4 months ago by Kevin Blighe65k
1

By mistake I post wrong code ....so I changed it. Yes above code work for me.

ADD REPLYlink written 4 months ago by Bioinfonext250
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: 758 users visited in the last hour