EdgeR - topTags sort up and down?
3
1
Entering edit mode
susan klein ▴ 10
@susan-klein-10119
Last seen 8.0 years ago

Is there a way to sort topTags output for up and down regulated genes separately? i.e. I want the top 20 up regulated and top 20 downregulated:

x <- read.delim("counts.txt",row.names="geneid")

group <- factor(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2))

y <- DGEList(counts=x,group=group)

y <- calcNormFactors(y)

design <- model.matrix(~group)

y <- estimateDisp(y,design)

fit <- glmQLFit(y,design)

qlf <- glmQLFTest(fit,coef=2

topTags(qlf,n=20,sort.by="logFC")

This only gives the upregulated genes. I want the full  table of results, not just a gene list. Is there a way to make sort.by sort up and down? Also is there a way to ouput the toptags table as tab delimited instead of the painful spaced table that is printed?

 

Thanks very much,

 

S.

edgeR • 2.5k views
ADD COMMENT
2
Entering edit mode
@ryan-c-thompson-5618
Last seen 8 months ago
Scripps Research, La Jolla, CA

If you want to do some more advanced sorting, I recommend you use n=Inf and then coerce the result to a data frame (using as.data.frame)and perform whatever filtering and sorting you want to. And for writing to a file, look at the documentation for write.table.

ADD COMMENT
0
Entering edit mode

Indeed, I would be inclined to do:

all.res <- topTags(qlf, n=Inf)
up.res <- all.res[all.res$table$logFC > 0,]
down.res <- all.res[all.res$table$logFC < 0,]

This sorts on significance, rather than the log-fold change, which gives you more reliable results.

Also, to elaborate on Ryan's comment, set sep="\t" in write.table to get tab-delimited output.

ADD REPLY
0
Entering edit mode
@deepak-tanwar-8113
Last seen 17 months ago
McGill University, Canada

n = "all"

ADD COMMENT
0
Entering edit mode
susan klein ▴ 10
@susan-klein-10119
Last seen 8.0 years ago

Great, thanks. I think n="all" solves this, thanks.

 

S.

ADD COMMENT

Login before adding your answer.

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