Question: flowviz
0
gravatar for Jiang, Mike
4.6 years ago by
Jiang, Mike1.2k
(Private Address)
Jiang, Mike1.2k wrote:
Joachim, Sorry I misunderstood your problem. It is probably not easy to do so unless you are willing to hack into hexbin::grid.hexagons and flowViz::panel.xyplot.flowframe. If it is just for small data set, you can simply use bin the data and do ggplot on the data.frame ,which gives you more flexibility in coloring. Here is one example: library(ggplot2) mat<-exprs(fs[[1]]) x<- mat[,"FSC-H"] y<- mat[,"SSC-H"] bin <- hexbin(x,y, xbin = 128) df <- data.frame(hcell2xy(bin), count = bin at count) ggplot(df, aes(x = x, y = y)) + geom_point(aes(color = sqrt(count))) + scale_color_gradient(low = "white", high = "black" , na.value = "red", limit = c(1, 2)) + theme_bw() Yon change use the 'limit' and 'na.value' to thresholding the colors. Mike Mike On 08/12/2014 05:42 AM, Joachim Schumann wrote: > Hi Mike, > > I did not get the point how to write a color ramp function with a > treshold. > > Right now I'm creating the xyplots like that: > > ff<-read.FCS("test.fcs",alter.names=TRUE,transformation=FALSE,min.li mit=NULL) > colramp <- colorRampPalette(c("white","black"))(236) > col=colorRampPalette(colramp) > xyplot(FS.Log ~ FL.4.Log ,data=ff, smooth=FALSE, xbin=128, colramp=col > ,par.settings = list(panel.background=list(col = "white")), axis = > axis.default, scales=(list(x=list(draw=FALSE), y=list(draw=FALSE))), > xlab="", ylab="") > > I can get the maximal value by: > > mat<-exprs(ff) > x<-mat[,"FS.Log"] > y<-mat[,"FL.4.Log"] > bin<-hexbin(x,y,xbins=128) > c<-bin at count > m<-max(c) > > The counts should be the values plotted by the xyplot function, right? > > How can I define the color palette with 236 linear gradiations from > white to black starting by 0, ending by e.g. m-100. All the other > values (m-100 to m) shall be black. > > Thank. > > Joachim > > Am 24.03.2014 18:34, schrieb Mike: >> >> If you use |hexbin| version of |xyplot|, then the value is simply the >> cell counts falling into each hexagon. >> It is not difficult to write your own customized colour ramp function >> to generate color schemes that you described based on your threshold. >> >> There are a little hacking you need to do in order to get the count >> value of each hexagon though, firstly you need to call |hexbin| on >> each |flowFrame|, >> >> |bin <- hexbin(x,y,xbins=xbins) >> | >> >> |x, y| is the intensity values from the two channels you defined in >> formula (e.g. |SSC-H|~|FSC-H|), which you can get by >> >> |mat <- exprs(fs[[1]]) >> x <- mat[, channel_A) >> y <- mat[, channel_B) >> | >> >> then you get the the counts vector by |bin at count|. >> >> Mike >> >> On 03/22/2014 03:44 AM, Joachim Schumann wrote: >> >>> Hi Mike, >>> >>> thanks for your answer. I defined a colramp from white to black now. >>> Is there any way I can have a look at the values that are calculated >>> within the xyplot? The reason: I want to define a threshold. E.g.: >>> The highest value within the xyplot is 1000, the lowest is 0. I want >>> all values ranging from 900-1000 beeing black and all values from >>> 900-0 should have those 255 gradiations. >>> >>> Best, >>> Joachim >>> >>> Am 20.03.2014 19:04, schrieb Mike: >>>> 'colramp' argument is what you are looking for, here is the example >>>> code. >>>> >>>> library(flowViz) >>>> data(GvHD) >>>> fs <- GvHD[1:2] >>>> >>>> #generate all colors you need >>>> myColors <- gray.colors(255) >>>> #reverse it as you want dark for high and white for low >>>> myColors <- rev(myColors) >>>> #wrap it into a ramp function >>>> myColRamp <- colorRampPalette(myColors) >>>> >>>> # pass the ramp function to xyplot >>>> xyplot(`SSC-H`~`FSC-H`, fs, smooth = FALSE, xbin = 128, colramp = >>>> myColRamp) >>>> >>>> >>>> Mike Jiang >>>> >>>> On 03/18/2014 09:34 AM, Joachim Schumann wrote: >>>>> Hi Mike, >>>>>> >>>>>> thanks for your answer. I think xbin is the only thing I need. But I >>>>>> have another question: I want to create a xyplot of my data. The >>>>>> range >>>>>> of e.g. columns FS.Log and FL.4.Log is from 0-4095. I want to display >>>>>> the xyplot (FL.4.Log ~ FS.Log) as a grayscale image with 256 linear >>>>>> gradiations. Black should indicate 4095 (maxRange) and white should >>>>>> indicate 0 (minRange). Now I need 256 linear gradiations from >>>>>> black to >>>>>> white. The data resolution should be 128. >>>>>> Can you tell me how to create such a grayscale image? I attached an >>>>>> image showing the grayscale. >>>>>> >>>>>> Best, >>>>>> Joachim >>>>>> >>>>>> >>>>>> Am 14.03.2014 18:07, schrieb Mike: >>>>>> > `nbin` is for displaying the marginal events (i.e. those gray >>>>>> segments >>>>>> > piled up at the edges) >>>>>> > >>>>>> > `binSize` is for `timeline plotting`, i.e. when you do 'xyplot' >>>>>> on a >>>>>> > `flowFrame` without 'formula` supplied , for example: >>>>>> > >>>>>> > xyplot(GvHD[["s5a05"]], binSize = 100) >>>>>> > >>>>>> > So again, 'xbin' is the argument to adjust the 'resolution' for >>>>>> > 'non-smoothed' xyplot . e.g. >>>>>> > >>>>>> > xyplot(`FSC-H` ~ `SSC-H`, GvHD[["s5a05"]], smooth = FALSE, xbin >>>>>> = 32) >>>>>> > #lower resolution and faster rendering >>>>>> > >>>>>> > xyplot(`FSC-H` ~ `SSC-H`, GvHD[["s5a05"]], smooth = FALSE, xbin >>>>>> = 128) >>>>>> > #higher resolution and slower rendering >>>>>> > >>>>>> > >>>>>> > Mike >>>>>> > >>>>>> > >>>>>> > On 03/13/2014 04:08 AM, Joachim Schumann wrote: >>>>>> >> Yes, i meant the xyplot. Can I also change the number of events >>>>>> >> within one bin? The vignette sometimes says nbin, sometimes >>>>>> binSize. >>>>>> >> >>>>>> >> Am 12.03.2014 18:11, schrieb Mike: >>>>>> >>> Not sure what you mean by `histogram`. If you are talking about >>>>>> >>> `xyplot`, there is `xbin` argument to adjust resolution (when you >>>>>> >>> set `smooth = FALSE`). >>>>>> >>> >>>>>> >>> Mike >>>>>> >>> On 03/12/2014 05:32 AM, Joachim Schumann wrote: >>>>>> >>>> Hi Mr. Jiang, >>>>>> >>>> >>>>>> >>>> I'm using flowViz to create a histogram of my flow >>>>>> cytometric data. >>>>>> >>>> Is there any way I can adjust the data resolution (eg to 128) >>>>>> >>>> within the histogram? >>>>>> >>>> >>>>>> >>>> Best regards, >>>>>> >>>> Joachim >>>>>> >>>> >>>>>> >>> >>>>>> >> >>>>>> >> >>>>>> > >>>>>> >>>>>> >>>>>> -- >>>>>> M. Sc. Joachim Schumann >>>>>> Department of Environmental Microbiology >>>>>> AG Flow Cytometry >>>>>> Helmholtz Centre for Environmental Research - UFZ >>>>>> Permoserstra?e 15, 04318 Leipzig >>>>>> >>>>>> E-Mail: joachim.schumann at ufz.de >>>>>> http://www.ufz.de >>>>>> >>>>> -- >>>>> Joachim Schumann >>>>> Department of Environmental Microbiology >>>>> AG Flow Cytometry >>>>> Helmholtz Centre for Environmental Research - UFZ >>>>> Permoserstra?e 15, 04318 Leipzig >>>>> E-Mail: joachim.schumann at ufz.de <mailto:joachim.schumann at="" ufz.de=""> >>>>> http://www.ufz.de >>>> >>> >>> >>> -- >>> M. Sc. Joachim Schumann >>> Department of Environmental Microbiology >>> AG Flow Cytometry >>> Helmholtz Centre for Environmental Research - UFZ >>> Permoserstra?e 15, 04318 Leipzig >>> >>> E-Mail:joachim.schumann at ufz.de >>> http://www.ufz.de > > > -- > M. Sc. Joachim Schumann > Department of Environmental Microbiology > AG Flow Cytometry > Helmholtz Centre for Environmental Research - UFZ > Permoserstra?e 15, 04318 Leipzig > > E-Mail:joachim.schumann at ufz.de > http://www.ufz.de [[alternative HTML version deleted]]
flowviz • 586 views
ADD COMMENTlink written 4.6 years ago by Jiang, Mike1.2k
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 16.09
Traffic: 187 users visited in the last hour