R/callAberrations.r

Defines functions callAberrations

Documented in callAberrations

####################################################################
## Author: Gro Nilsen, Knut Liestřl and Ole Christian Lingjćrde.
## Maintainer: Gro Nilsen <gronilse@ifi.uio.no>
## License: Artistic 2.0
## Part of the copynumber package
## Reference: Nilsen and Liestřl et al. (2012), BMC Genomics
####################################################################


#Function that calls segments as gain, normal or loss

##Input:
### segments: segmentation results from pcf or multipcf
### thres.gain,thres.loss: threshold(s) to be applied for abberration calling

##Required by: none

##Requires: 
### is.multiseg
### pullOutContent


callAberrations <- function(segments,thres.gain,thres.loss=-thres.gain){
  
  #Make sure segments is a data frame
  segments <- pullOutContent(res=segments,what="segments")

  if(is.multiseg(segments)){
    call.seg <- matrix("normal",nrow=nrow(segments),ncol=ncol(segments)-5)
    colnames(call.seg) = colnames(segments)[-c(1:5)]
		gain <- segments[,-c(1:5),drop=FALSE] > thres.gain
		call.seg[gain] <- "gain"
    loss <- segments[,-c(1:5),drop=FALSE] < thres.loss
    call.seg[loss] <- "loss"
    
    call.seg <- as.data.frame(cbind(segments[,c(1:5)],call.seg))
    
  }else{
    call.seg <- rep("normal",nrow(segments))
		gain <- segments[,7] > thres.gain
		call.seg[gain] <- "gain"
    loss <- segments[,7] < thres.loss
    call.seg[loss] <- "loss"
    
    call.seg <- as.data.frame(cbind(segments[,c(1:6)],call.seg))
    colnames(call.seg)[7] = "call"
    
  }
  
  return(call.seg)

}

Try the copynumber package in your browser

Any scripts or data that you put into this service are public.

copynumber documentation built on Nov. 8, 2020, 6:10 p.m.