Colours in degradation plot
1
0
Entering edit mode
@kfbargadlgehues-317
Last seen 10.2 years ago
Dear Jim, thanks for your useful chunk of code. I pasted it and got some results, i.e, two different types of lines, but the command reached an erro and didn?t draw all the curves in my degradation plot. I had 27 arrays and got only twelve lines, and the error I got is the following: > my.plotAffyRNAdeg(AffyRNAdeg(data), col=1:length(sampleNames(data))) Error in plot.xy(xy.coords(x, y), type = type, col = col, lty = lty, ...) : invalid line type I got eight solid lines and four ?-? lines Can you give me some more hints? Regards, David You will likely have a hard time using just colors to separate the samples. Changing the line type is likely to work better for you. Unfortunately, plotAffyRNAdeg() doesn't have a lty variable that you can use to change the line type. However, it is not difficult to add. Something like the following might do the trick (although what I have done here is hackish and ad hoc). my.plotAffyRNAdeg <- function (rna.deg.obj, transform = "shift.scale", cols = NULL, lntype = NULL, ...) { if (!is.element(transform, c("shift.scale", "shift.only", "neither"))) stop("Tranform must be 'shift.scale','shift.only', or 'neither'") mns <- rna.deg.obj$means.by.number if (is.null(cols)) cols = rep(4, dim(mns)[1]) ylab = "Mean Intensity" if (transform == "shift.scale") { sds <- rna.deg.obj$ses mn <- mns[, 1] mns <- sweep(mns, 1, mn) mns <- mns/(sds) mns <- sweep(mns, 1, 1:(dim(mns)[1]), "+") ylab <- paste(ylab, ": shifted and scaled") } else if (transform == "shift.only") { mn <- mns[, 1] mns <- sweep(mns, 1, mn) mns <- sweep(mns, 1, 1:(dim(mns)[1]), "+") ylab <- paste(ylab, ": shifted") } plot(-2, -1, pch = "", xlim = range(-1, (dim(mns)[2])), ylim = range(min(as.vector(mns)) - 1, max(as.vector(mns)) + 1), xlab = "5' <-----> 3'\n Probe Number ", ylab = ylab, axes = FALSE, main = "RNA digestion plot", ...) axis(1) axis(2) if(is.null(lntype)){ full <- floor(dim(mns)[1]/8) mod <- dim(mns)[1]%%8 for(i in (seq(along=full))) lntype <- c(lntype, rep(i, 8)) lntype <- c(lntype, rep(full + 1, mod)) } for (i in 1:dim(mns)[1]) lines(0:((dim(mns)[2] - 1)), mns[i, ], col = cols[i], lty = lntype[i]) } Paste this into your R session, then you can do something like: my.plotAffyRNAdeg(AffyRNAdeg(abatch), col=1:length(sampleNames (abatch))) HTH, Jim
• 1.4k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 17 hours ago
United States
kfbargad@lg.ehu.es wrote: > Dear Jim, > > thanks for your useful chunk of code. I pasted it and got some > results, i.e, two different types of lines, but the command reached an > erro and didn?t draw all the curves in my degradation plot. I had 27 > arrays and got only twelve lines, and the error I got is the following: > > >>my.plotAffyRNAdeg(AffyRNAdeg(data), col=1:length(sampleNames(data))) > > Error in plot.xy(xy.coords(x, y), type = type, col = col, lty = > lty, ...) : > invalid line type > > I got eight solid lines and four ?-? lines > > Can you give me some more hints? Stupid mistake on my part. Change the line in my.plotAffyRNAdeg() near the end that reads: for(i in (seq(along=full))) lntype <- c(lntype, rep(i, 8)) -to- for(i in 1:full) lntype <- c(lntype, rep(i, 8)) Then it should work. Jim > > Regards, > > David > > > > You will likely have a hard time using just colors to separate the > samples. Changing the line type is likely to work better for you. > Unfortunately, plotAffyRNAdeg() doesn't have a lty variable that you > can > use to change the line type. However, it is not difficult to add. > Something like the following might do the trick (although what I have > done here is hackish and ad hoc). > > my.plotAffyRNAdeg <- function (rna.deg.obj, transform > = "shift.scale", > cols = NULL, lntype = NULL, ...) > { > if (!is.element(transform, c("shift.scale", "shift.only", > "neither"))) > stop("Tranform must be 'shift.scale','shift.only', > or 'neither'") > mns <- rna.deg.obj$means.by.number > if (is.null(cols)) > cols = rep(4, dim(mns)[1]) > ylab = "Mean Intensity" > if (transform == "shift.scale") { > sds <- rna.deg.obj$ses > mn <- mns[, 1] > mns <- sweep(mns, 1, mn) > mns <- mns/(sds) > mns <- sweep(mns, 1, 1:(dim(mns)[1]), "+") > ylab <- paste(ylab, ": shifted and scaled") > } > else if (transform == "shift.only") { > mn <- mns[, 1] > mns <- sweep(mns, 1, mn) > mns <- sweep(mns, 1, 1:(dim(mns)[1]), "+") > ylab <- paste(ylab, ": shifted") > } > plot(-2, -1, pch = "", xlim = range(-1, (dim(mns)[2])), ylim = > range(min(as.vector(mns)) - > 1, max(as.vector(mns)) + 1), xlab = "5' <-----> 3'\n Probe > Number ", > ylab = ylab, axes = FALSE, main = "RNA digestion plot", > ...) > axis(1) > axis(2) > if(is.null(lntype)){ > full <- floor(dim(mns)[1]/8) > mod <- dim(mns)[1]%%8 > for(i in (seq(along=full))) > lntype <- c(lntype, rep(i, 8)) > lntype <- c(lntype, rep(full + 1, mod)) > } > for (i in 1:dim(mns)[1]) lines(0:((dim(mns)[2] - 1)), mns[i, > ], col = cols[i], lty = lntype[i]) > } > > Paste this into your R session, then you can do something like: > > my.plotAffyRNAdeg(AffyRNAdeg(abatch), col=1:length(sampleNames > (abatch))) > > HTH, > > Jim > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor -- James W. MacDonald Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109
ADD COMMENT

Login before adding your answer.

Traffic: 576 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6