This is a test version of Biostars. For the public version, visit https://www.biostars.org.
MDS Plot R

Hi, I am new to R and need to generate MDS plot for 4 different sample with 3 replicates each, indicate with four different color (replicate should have color).I tried this code:

library("limma")
library("edgeR")
library("ggplot2")
x <- read.delim("IR_all",row.names="gene")
group <- factor(c(1,1,1,2,2,2,3,3,3,4,4,4))
y <- DGEList(counts=x,group=group)
y <- calcNormFactors(y)
design <- model.matrix(~group)
y <- estimateDisp(y,design)
plotMDS(y,col=c(rep("green",3),rep("blue",3),rep("green",3), rep("black",3)))
rna-seq

...and, voilà!, what happened when you tried that code?

Take a look at the example in the EdgeR vignette: MDS plot

i did not generate plot

Which system are you using? Also, is it a remote server? Ensure that you have not already opened the output stream somewhere else by running dev.off() multiple times

no i did not use dev.off().....yes I am using server which give mds plot very late but I got after 6-8 hrs. i already got mds plot with column name itself but i want to define column by specific color and I try this code. but no output even after one day.

You have configured X11 protocol so that the R plot window will open up in your local OS, right? Is there any message after you run plotMDS()? Check that it has not saved the figure to a default PDF name in your working directory on the server itself.

no R plot window open even at local OS......no message came after running plotMDS()...Outfile generate but it is 0 kb.

What is the output of dev.off()?

now I got output...thanks Kevin....now I want to mention that which sample representing which color (legend)....after above code I am giving this code:

 legend("topleft", legend=c("a", "b","c","d"), pch=19,col=c(rep("red",3),rep("blue",3),rep("green",3), rep("black",3)))

but it is giving "a", "b", "c" in Red color and "d" in blue.I want a in red, b in blue, c in green, d in black color....how to do that?

 legend(
  "topleft",
  bty = 'n',
  c("a", "b","c","d"),
  pch = 19,
  fill = c("red", "blue", "green", "black"))

thanks kevin...it works....can you tell me how to give 16 different color......if I am giving by this way ...it goes to new line then it is error.

 plotMDS(y,h,col=c(rep("red",3),rep("blue",3),rep("green",3), rep("black",3), rep("brown",3),rep("cyan",3),rep("yellow",3),rep("pink",3),rep("gray",3),rep("magenta",3),rep("orange",3),rep("seagreen",3),rep("turquoise",3),rep("purple",3)+ ep("skyblue",3), rep("salmon",3), pch=19)

Your colour vector there produces 48 colours (?) Sorry, I now have to catch the train / metro.

yes...i am having 16 sample with 3 replicates....whenever you get time please tell me how to deal with this.

Why don't you try to solve it yourself. This is basic R and solving it yourself using google will help improving yourself.

0 answers

No answers yet.

Log in to answer this question.