I have a data frame containing ~10000 rows and 3 columns:
ENSEMBL J1.1 J1.2
ENSG00000166710 800 900
ENSG00000163220 15000 32500
ENSG00000156508 600 900
...
> as.data.frame(colnames(TPMProtCod_J1.1_J1.2))
colnames(TPMProtCod_J1.1_J1.2)
1 ENSEMBL
2 J1.1
3 J1.2
> dim(TPMProtCod_J1.1_J1.2)
[1] 10602 3
I've created a scatterplot with the following code:
plot(TPMProtCod_J1.1_J1.2$J1.1, TPMProtCod_J1.1_J1.2$J1.2, col = "lightblue", pch=19, cex=2, xlab = "J1.1 (TPM)", ylab = "J1.2 (TPM)")
text(TPMProtCod_J1.1_J1.2$J1.1, TPMProtCod_J1.1_J1.2$J1.2, labels = row.names(TPMProtCod_J1.1_J1.2), cex= 0.9)
But how do I make it so that each point displays the corresponding ensembl ID instead of the row number?
It seems that you need to change row.names(...)
to TPMProtCod_J1.1_J1.2$ENSEMBL
:
text(TPMProtCod_J1.1_J1.2$J1.1, TPMProtCod_J1.1_J1.2$J1.2, labels = TPMProtCod_J1.1_J1.2$ENSEMBL, cex= 0.9)