0

I have created an MDS plot in R using the following code:

library(ggplot2)
data<-read_csv("Uni/MSci/Project/DATA/new data sheets/comparisons/matrix for 
MDS.csv")
matrix<-data.matrix(data[2:25])

d <- dist(t(matrix))

c<-cmdscale(d, eig=TRUE,k=2)
x <- c$points[,1]
y <- c$points[,2]

mds<-plot(x, y, xlab="Coordinate 1", ylab="Coordinate 2", main="MDS")
text(x, y,labels = names(x))

I want the data points from the first 12 columns to be a different colour to the last 12 columns (the first column not included), is there a way I can do this?

An example of my dataframe is as follows:

All DE probes           GAc         GAs         GAt         GAcAt       
GAsAc
GENE:JGI_V11_1000360103 1.374700022 1.334393131 1.001545297 1.201249615  
1.37799781
GENE:JGI_V11_1000360203 1.123109605 1.488452974 1.115555715 1.335694066  
1.410720257
GENE:JGI_V11_1000360303 0.957649492 1.266468558 1.146132718 1.009817126  
1.287685907
GENE:JGI_V11_1000440101 0.97539842  0.95643555  0.913679292 1.005319047  
0.9977714

The data frame however has 25 columns(the first being gene labels) and 61,005 rows - I have just shown a tiny snippet so as not to produce pages of script.

A.Carter
  • 49
  • 8
  • When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. We don't have access to your csv file so this isn't as helpful as it could be. Maybe just use a built in data set to show what you are trying to do. Explicitly any packages you are using in the code. – MrFlick Mar 16 '18 at 17:57
  • Try `text(x, y, labels = names(x))` – zx8754 Mar 19 '18 at 13:16

0 Answers0