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)

