0

I have a simple PLINK MDS "Cauc71.mds" :

    FID         IID     SOL     C1              C2 
1   Lezgins     lez37   0       0.0196617       0.0366344 
2   Georgians   mg47    0       0.0121934       -0.0335062 
    ...
71  Kumyk       Kumyk22 0       0.00135308      0.00216335 

The following code will produce a plot in R :

d <- read.table("Cauc71.mds", header=TRUE)
plot(d$C1, d$C2, pch=20, cex=2, col = d$SOL+1)

Is there a simple way to use text-labels from the IID column {lez37, mg47 etc } instead of the pch points?

Thank you!

2 Answers2

1

You cannot define this in plot. You can only plot points, lines etc. But you could add the text afterwards, e.g.

text(d$C1, d$C2, labels=d$IID, col = d$SOL+1)

Additionally, you will probably need to position the text properly using the parameters pos or adj.

If you also want to get rid of the points, you could add the argument type="n" to the plot function.

Mark Heckmann
  • 10,943
  • 4
  • 56
  • 88
0

Try this:

d <- read.table("Cauc71.mds", header=TRUE)
plot(d$C1, d$C2, pch=20, cex=0, col = d$SOL+1)
text(d$C1, d$C2, labels=d$IID)

You can also use the ggplot2 package to generate better plots:

library(ggplot2)
ggplot(d, aes(x=C1, y=C2, label=IID))+geom_text()

enter image description here

Ali
  • 9,440
  • 12
  • 62
  • 92