extract count data for a gene ID list in R
1
0
Entering edit mode
4.0 years ago
Bioinfonext ▴ 460

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 • 1.3k views
ADD COMMENT
0
Entering edit mode

Please show content of that file.

ADD REPLY
1
Entering edit mode
4.0 years ago
Bioinfonext ▴ 460

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 COMMENT
0
Entering edit mode

Do you not have to use:

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

?

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Yes, does changing it to df solve the problem?

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

ADD REPLY
1
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 3741 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