Mercurial > repos > yufei-luo > s_mart
comparison SMART/DiffExpAnal/DESeqTools/majSequence.R @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17:b0e8584489e6 | 18:94ab73e8a190 |
---|---|
1 # majSequence | |
2 # compute proportion of reads associated with most expressed sequence | |
3 | |
4 # input : counts, target, projectName | |
5 # output : barplot, % associated with majority gene | |
6 | |
7 # created Feb 7th, 2012 | |
8 # modified Feb 20th, 2012 | |
9 # modified April 30th, 2012 | |
10 # Marie-Agnes Dillies | |
11 | |
12 | |
13 majSequence <- function( counts, group, OUT_majSequenceName, out = T, position = "topright" ){ | |
14 | |
15 if (out) png( file=OUT_majSequenceName ) | |
16 | |
17 maj <- apply(counts, 2, function(x){x <- x[order(x, decreasing=T)]; x[1]*100/sum(x)}) | |
18 seqname <- apply(counts, 2, function(x){x <- x[order(x, decreasing=T)]; names(x)[1]}) | |
19 | |
20 x <- barplot( maj, col=as.integer(group)+1, main = "Proportion of reads from most expressed gene", | |
21 ylim = c(0, max(maj)*1.2), cex.main=0.8 ) | |
22 for (i in 1:length(seqname)) text( x[i], maj[i]/2, seqname[i], cex=0.8, srt=90, adj=0) | |
23 legend( position, as.character(unique(group)), lty=1, col=as.integer(unique(group))+1 ) | |
24 | |
25 if (out) dev.off() | |
26 } |