CallRegions               package:BAC               R Documentation

_C_a_l_l _a_n_d _m_e_r_g_e _r_e_g_i_o_n_s _u_s_i_n_g _j_o_i_n_t _p_o_s_t_e_r_i_o_r _p_r_o_b_a_b_i_l_i_t_i_e_s _c_a_l_c_u_l_a_t_e_d _b_y _B_A_C.

_D_e_s_c_r_i_p_t_i_o_n:

     Call and merge regions using joint posterior probabilities
     calculated by BAC.

_U_s_a_g_e:

     CallRegions(position,jointPP,cutoff=0.5,maxGap=500)

_A_r_g_u_m_e_n_t_s:

position: A vector containing the probe genomic positions

 jointPP: A vector containing the joint posterior probabilities as
          returned by BAC.

  cutoff: The cutoff used to call regions.

  maxGap: The maximum gap allowed between regions. Regions that are
          less than maxGap bps away will be merged.

_V_a_l_u_e:

     A vector containing the region index for each probe. Probes with
     the same positive index belong to the same region, whereas probe
     with index zero are  background probes (not part of a bound
     region). These indices can be used to form a BED file, see example
     below.

_A_u_t_h_o_r(_s):

     Raphael Gottardo, raph@stat.ubc.ca

_S_e_e _A_l_s_o:

     BAC

_E_x_a_m_p_l_e_s:

     # Load the data
     data(ER)
     # Only select the first 5000 probes for speed-up
     ER<-ER[1:5000,]
     # Calculate the joint posterior probabilities
     #Only use 100 iterations for speed up (You should use more! See default value) 
     BAConER<-BAC(ER[,5:7], ER[,2:4], B=100,verbose=FALSE,w=5)
     # For Regions using 0.5 cut-off for the joint posterior probabilities
     ERregions<-CallRegions(ER[,1],BAConER$jointPP,cutoff=0.5,maxGap=500)
     # Create the BED file
     nRegions<-max(ERregions)
     BED<-matrix(0,nRegions,4)
     for(i in 1:nRegions)
     {
     BED[i,2:3]<-range(ER[ERregions==i,1])
     #The score should be between 0 and 1000
     BED[i,4]<-max(BAConER$jointPP[ERregions==i])*1000
     }
     BED<-data.frame(BED)
     # The ER data is a subset of chr 21
     BED[,1]<-"chr21"
     names(BED)<-c("chrom","chromStart","chromEnd","Score")
     # print it
     print(BED)

