Question: MDS Plot R
0
gravatar for BioBaby
15 months ago by
BioBaby20
BioBaby20 wrote:

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 • 1.6k views
ADD COMMENTlink written 15 months ago by BioBaby20

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

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

ADD REPLYlink modified 15 months ago • written 15 months ago by Kevin Blighe66k

i did not generate plot

ADD REPLYlink written 15 months ago by BioBaby20

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

ADD REPLYlink written 15 months ago by Kevin Blighe66k

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.

ADD REPLYlink written 15 months ago by BioBaby20

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.

ADD REPLYlink written 15 months ago by Kevin Blighe66k

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

ADD REPLYlink written 15 months ago by BioBaby20

What is the output of dev.off()?

ADD REPLYlink written 15 months ago by Kevin Blighe66k

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?

ADD REPLYlink written 15 months ago by BioBaby20
 legend(
  "topleft",
  bty = 'n',
  c("a", "b","c","d"),
  pch = 19,
  fill = c("red", "blue", "green", "black"))
ADD REPLYlink written 15 months ago by Kevin Blighe66k

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)
ADD REPLYlink written 15 months ago by BioBaby20

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

ADD REPLYlink written 15 months ago by Kevin Blighe66k

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

ADD REPLYlink written 15 months ago by BioBaby20
1

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

ADD REPLYlink written 15 months ago by ATpoint39k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1863 users visited in the last hour