Generating an MDS plot in R for population stratification

0

Hello,
I'm very new to bioinformatics and I'm just starting out using PLINK and R to perform a GWAS for the first time. I've generated a .mds file through PLINK of 10 dimensions that looks like this file

With many more rows of course. I'm trying to graph an MDS plot of this data but I'm not sure how? I found this code online:

m <- read.table('pca.mds', header = TRUE)
m <- as.matrix(m[, 4:13])
mds <- cmdscale(as.dist(1-m))
plot(mds)

But this generates the error:

non-square matrixnumber of items to replace is not a 
multiple of replacement length
Error in dimnames(points) <- list(rn, NULL) : 
length of 'dimnames' [1] not equal to array extent

Can someone help explain why this is happening and how to fix it? I'm very new to this, and I'd like to generate a plot that looks like:

sample mds plot

Probably with more dimensions though obviously. Or I'm not really sure if there's a better way to generate an MDS plot for the purposes of population stratification? Any help would be much appreciated!


Stratification


R


MDS


PCA


PLINK

• 69 views



Source link