annotate SMART/DiffExpAnal/DESeqTools/majSequence.R @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
1 # majSequence
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
2 # compute proportion of reads associated with most expressed sequence
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 # input : counts, target, projectName
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5 # output : barplot, % associated with majority gene
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7 # created Feb 7th, 2012
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8 # modified Feb 20th, 2012
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 # modified April 30th, 2012
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 # Marie-Agnes Dillies
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 majSequence <- function( counts, group, OUT_majSequenceName, out = T, position = "topright" ){
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 if (out) png( file=OUT_majSequenceName )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 maj <- apply(counts, 2, function(x){x <- x[order(x, decreasing=T)]; x[1]*100/sum(x)})
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 seqname <- apply(counts, 2, function(x){x <- x[order(x, decreasing=T)]; names(x)[1]})
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 x <- barplot( maj, col=as.integer(group)+1, main = "Proportion of reads from most expressed gene",
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 ylim = c(0, max(maj)*1.2), cex.main=0.8 )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 for (i in 1:length(seqname)) text( x[i], maj[i]/2, seqname[i], cex=0.8, srt=90, adj=0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 legend( position, as.character(unique(group)), lty=1, col=as.integer(unique(group))+1 )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 if (out) dev.off()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 }