-1

This is my code:

A<-read.delim("/Users/macbookair11/Downloads/file.txt",header = T)
names(A)
attach(A)
P<--log10(fdr)

plot(lfc,P,type="p",
xlab="log2fc",
ylab="-log10fdr",
pch=16,
xlim=c(-5,5)
)
abline(h =(-log10(0.01)), untf = FALSE, col="red")
abline(v =(log2(2)), untf = FALSE, col="red")
abline(v =-(log2(2)), untf = FALSE, col="red")
text(lfc,P, labels=Transcript, cex=0.6, pos=4, col="red")

I need to label not all the points, but only those ones which have y>2 and (x<-1 or x>1).

How can I change my script to make it work in a right way?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
user2080209
  • 749
  • 3
  • 8
  • 25
  • Thread http://stackoverflow.com/questions/7611169/intelligent-point-label-placement-in-r offers several solutions. Maybe one or a few of them would fit your situation, also? –  Sep 27 '13 at 19:19
  • Sorry, I slightly misread the question, try something like text(lfc[(lfc>1 | lfc<(-1)) & P>2], P[(lfc>1 | lfc<(-1)) & P>2], labels=Transcript[(lfc>1 | lfc<(-1)) & P>2], cex=0.6, pos=4, col="red") . Without the actual data this is untested. –  Sep 27 '13 at 19:23

1 Answers1

0

Cannot show you how to do it with your data since its not available; this shows some conditional labeling of "outliers" from a t-test.

x <- rnorm(100)
y<- rchisq(100,1)
plot(x,y, xlim=c(-3.5,3.5))
abline(v= c(-1.96, 1.96), col='red')
abline(h= 3.84, col='red')
text(x[ abs(x) > 2|y > 3.8], y[abs(x) > 2|y > 3.8]+.15, 
        paste0("(",round(x[ abs(x) > 2|y > 3.8],1), " , ", 
                   round(y[ abs(x) > 2|y > 3.8],1),
                ")" ) )
IRTFM
  • 258,963
  • 21
  • 364
  • 487