make.grid              package:rflowcyt              R Documentation

_M_a_k_e _a _m_a_t_r_i_x _o_f _v_a_l_u_e_s _a_l_l_o_c_a_t_e_d _i_n _a _t_w_o _d_i_m_e_n_s_i_o_n_a_l _g_r_i_d

_D_e_s_c_r_i_p_t_i_o_n:

     A two-dimensional plot can be subdivided via grid marks and lines.
      Each component of the resulting grid is called a cell.  The
     function 'make.grid' determines a matrix of values corresponding
     to the number of observations that lie within each cell of the
     grid.  The function 'make.density' estimates the values allocated
     to each grid cell by a 'status' binary variable.  The values are
     estimated to be either a difference in counts between the two
     status categories, a proportion, a normalized proportion, and a z
     statistic for each cell such that an image or ContourScatterPlot
     plot can be implemented.

_U_s_a_g_e:

     make.grid(x, y, x.grid = seq(0, 1025, by = 25),
                y.grid = seq(0, 1025, by = 25))

     make.density(x, y, status = NULL,
               x.grid = seq(0, 1025, by = 25),
               y.grid = seq(0, 1025, by = 25),
               type.CSP = c("count.diff", "p.hat", "p.hat.norm", "z.stat"))

_A_r_g_u_m_e_n_t_s:

       x: a vector of data values for the x-axis 

       y: a vector of data values for the y-axis

  status: a vector of 0, 1 values denoting two categories

  x.grid: a vector of grid marks to allocate x

  y.grid: a vector of grid marks to allocate y

type.CSP: character string denoting the type.CSP of value to be
          estimated using the 'status' for each cell grid

_D_e_t_a_i_l_s:

     The following details the options for 'type.CSP':

"_c_o_u_n_t._d_i_f_f" The cell value is the count difference between the two
     'status' categories

"_p._h_a_t" The grid cell value is the proportion of observations with
     'status'==1 for that grid cell.

"_p._h_a_t._n_o_r_m" The grid cell value is the following:

     (ie, (p.hat -  0.05)/sqrt( (0.05 * (1-0.05)) /n)

     p.hat is the proportion in 'status'==1

     where n is the number of cells in the grid with information.  The
     default is to set the z statistic to zero for the cells with no
     information in either status.  The value 0.5 is considered to be
     the case of no difference when the counts of both categories of
     'status' are the same in the grid cell.


"_z._s_t_a_t" The cell value is a z statistic computed as the following:

     (ie, (p.hat -  p.bar)/se(p.bar))

     p.hat is the proportion in 'status'==1

     p.bar is the average of p.hat over the whole grid

     se(p.bar)=sqrt((1-p.bar)(p.bar)/n), where n is the number of cells
     in the grid with information.  

_V_a_l_u_e:

       z: matrix of values corresponding to the counts in an x-y grid

 n.cells: (only output for 'make.grid'); number of total observations
          in z

type.CSP: (only output for 'make.density'); the type.CSP of value in
          each cell.

_N_o_t_e:

     In the base package, the function 'image' could make a plot with
     the resulting matrix of values.

_A_u_t_h_o_r(_s):

     Zoe Moodie, A.J. Rossini, J.Y. Wan

_S_e_e _A_l_s_o:

     'image', 'ContourScatterPlot', 'pairs.CSP', 'legend.CSP',
     'heat.colors'

_E_x_a_m_p_l_e_s:

      
       if (require(rfcdmin)){
        data.there<-is.element(c("st.1829", "unst.1829", "st.DRT", "unst.DRT"),objects())
        if ( ( sum(data.there) != length(data.there) )){
           ## obtaining the FCS objects from VRC data
           data(VRCmin)
       }

     var1<-st.DRT@data[,4]
     var2<-st.DRT@data[,5]
     var1.2<-unst.DRT@data[,4]
     var2.2<-unst.DRT@data[,5]

     col.nm<-colnames(st.DRT@data)

     ## The status where 1=stimulated
     ## 0 = unstimulated
     status<-c(rep(1, dim(st.DRT@data)[1]), rep(0, dim(unst.DRT@data)[1]))
     x <- c(var1, var1.2)
     y <-c(var2, var2.2)

     count.output1<-make.grid(var1, var2)
     count.output0<-make.grid(var1.2, var2.2)

     ## matrix of counts
     mat.counts1<-count.output1$z
     mat.counts0<-count.output0$z
     ##total observations
     total.stimulated<-count.output1$n.cells
     total.unstimulated<-count.output0$n.cells

     count.diff.output <-make.density(x, y, status=status, type.CSP="count.diff")
     ## matrix of cont differences between the status categories
     mat.count.diff <-count.diff.output$z

     p.hat.output <-make.density(x, y, status=status, type.CSP="p.hat")
     ## matrix of cont differences between the status categories
     mat.p.hat <-p.hat.output$z

     p.hat.norm.output <-make.density(x, y, status=status, type.CSP="p.hat.norm")
     ## matrix of cont differences between the status categories
     mat.p.hat.norm <-p.hat.norm.output$z

     z.stat.output <-make.density(x, y, status=status, type.CSP="z.stat")
     ## matrix of cont differences between the status categories
     mat.z.stat <-z.stat.output$z

     if (interactive()){
     par(mfrow=c(3,2))

     image(mat.counts1,yaxt="n", xaxt="n",
       main="make.grid: Counts for stimulated",
        xlab=col.nm[4],
        ylab=col.nm[5], col=heat.colors(20))

     image( mat.counts0,yaxt="n", xaxt="n",
       main="make.grid: Counts for unstimulated",
        xlab=col.nm[4],
        ylab=col.nm[5], col=heat.colors(20))

     image( mat.count.diff,yaxt="n", xaxt="n",
       main="make.density: Count Difference (Stimulated-Unstimulated)",
        xlab=col.nm[4],
        ylab=col.nm[5], col=heat.colors(20))

     image( mat.p.hat,yaxt="n", xaxt="n",
       main="make.density: Proportion of Stimulated",
        xlab=col.nm[4],
        ylab=col.nm[5], col=heat.colors(20))

     image( mat.p.hat.norm,main="make.density: Normalized proportion of Stimulated",
        xlab=col.nm[4],yaxt="n", xaxt="n",
        ylab=col.nm[5], col=heat.colors(20))

     image( mat.z.stat, main="make.density: z statistic",
        xlab=col.nm[4],yaxt="n", xaxt="n",
        ylab=col.nm[5], col=heat.colors(20))

     }
     }

