[BioC] FlowViz log ticks trick
Greg Finak
gfinak at fhcrc.org
Wed Feb 23 18:55:08 CET 2011
Hi, David.
That is the correct mechanism for plotting custom axes. There are no explicit parameters for passing custom axes to the flowViz plotting functions. If you are working with flowFrames, you could still pass the axes=FALSE parameter to the plot method to get the same behaviour. The only thing you must be certain of is that the mapping from channel-space to log-intensity space is correct. Given that you are working with log base 10, you should be using log(X,base=10) in your code rather than log(), which is base 2. Also, I don't think you are constructing your minor ticks correctly (see below). You could construct your axes in one fell swoop, something along the lines of:
#Artifical data points with 65535 channels
X<-log(1:10000,10)*65535/4
plot(X,axes=FALSE)
###
channels<-65535
decades=4
my.fact<-channels/decades.
all.ticks<-NULL;
major<-(10^(0:decades))
for(i in 1:(length(major)-1)){
all.ticks<-c(all.ticks,seq(major[i],major[i+1],l=10))
}
all.ticks<-log(all.ticks,10); #Log base 10
major<-log(major,10);
axis(2,all.ticks*my.fact,label=FALSE)
axis(2,at=major*my.fact,labels=c(expression(10^0), expression(10^1), expression(10^2), expression(10^3), expression(10^4)))
##You could do the same using flowFrames
require(flowCore)
require(flowViz)
X<-as.matrix(cbind(X,X))
colnames(X)<-c("A","B")
X<-flowFrame(X);
plot(X,axes=FALSE) #Calls the plot function in the flowViz package
axis(2,all.ticks*my.fact,label=FALSE)
axis(2,at=major*my.fact,labels=c(expression(10^0), expression(10^1), expression(10^2), expression(10^3), expression(10^4)))
axis(1,all.ticks*my.fact,label=FALSE)
axis(1,at=major*my.fact,labels=c(expression(10^0), expression(10^1), expression(10^2), expression(10^3), expression(10^4)))
On 2011-02-23, at 7:42 AM, Davide Rambaldi wrote:
> Hi, I was unable to find a emthod/parameter to draw tickmarks corriesponding to LOG decades for flow-cytometry data.
>
> I have then implemented my method (is brutal but seems effective).
>
> RESULT: http://img510.imageshack.us/i/pkhlinear.png/
>
> CODE:
>
> # SET number of channels and log decades
> channels <- 65535
> decades <- 4
>
> plot(mData[[1]], "PE", breaks=256, col="orange", ylim=c(0,2500), main="PKH26", axes=F)
> axis(2)
>
> # calculate the main tickmarks
> my.fact <- channels / decades
>
> # main ticks
> axis(1, at=c(0,my.fact,my.fact*2,my.fact*3,my.fact*4), labels=c(expression(10^0), expression(10^1), expression(10^2), expression(10^3), expression(10^4)))
>
> # small ticks
> decade.one <- log(2:9)
> decade.one.log.ticks <- c(round((decade.one*my.fact)/max(decade.one)))
#You want 10 ticks from 1 to 10, 10 to 100, 100 to 1000, etc.
s<-seq(1,10,length=10)
minor.one <-log(s,10)*my.fact
s<-seq(10,100,length=10)
minor.two<-log(s,10)*my.fact
etc...
Cheers,
Greg.
> axis(1, decade.one.log.ticks, labels=FALSE)
> decade.two.log.ticks <- decade.one.log.ticks + round(my.fact)
> axis(1, decade.two.log.ticks, labels=FALSE)
> decade.three.log.ticks <- decade.two.log.ticks + round(my.fact)
> axis(1, decade.three.log.ticks, labels=FALSE)
> decade.four.log.ticks <- decade.three.log.ticks + round(my.fact)
> axis(1, decade.four.log.ticks, labels=FALSE)
>
>
> It is this code correct? There is a better way to do this?
>
> Best Regards
>
> Davide Rambaldi
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
Greg Finak, PhD
Post-doctoral Research Associate
PS Statistics, Vaccine and Infectious Disease Division.
Fred Hutchinson Cancer Research Center
Seattle, WA
(206)667-3116
gfinak at fhcrc.org
More information about the Bioconductor
mailing list