R/filterBkpStep.R

Defines functions filterBkpStep.profileCGH filterBkpStep

Documented in filterBkpStep filterBkpStep.profileCGH

### Copyright (C) 2005 Institut Curie
### Author(s): Philippe Hupé (Institut Curie) 2005
### Contact: glad@curie.fr



filterBkpStep <- function(...)
  {
    UseMethod("filterBkpStep")
  }



filterBkpStep.profileCGH <- function(profileCGH, MinBkpWeight=0.35, DelBkpInAmp=TRUE, DelBkpInDel=TRUE, assignGNLOut=TRUE, verbose=FALSE, ...)
  {


    if (verbose) print("filterBkpStep: starting function")            

    profileCGH <- filterBkp(profileCGH, MinBkpWeight=MinBkpWeight, DelBkpInAmp=DelBkpInAmp, DelBkpInDel=DelBkpInDel, assignGNLOut=assignGNLOut, verbose=verbose)


    
    fin <- 0
    maxiter <- 100
    nbiter <- 0
    

    if (is.data.frame(profileCGH$BkpInfo))
      {
        BkpInfo <- profileCGH$BkpInfo
        indexWeightToSmall <- which(BkpInfo$Weight < MinBkpWeight & BkpInfo$GNLchange == 0 & BkpInfo$ZoneGNL != 2)
        indexWeightToSmall <- c(indexWeightToSmall, which(BkpInfo$Weight == 0))
        indexWeightZero <- which(BkpInfo$Weight == 0 & BkpInfo$GNLchange == 1)        
        if (length(indexWeightToSmall)>0 || length(indexWeightZero)>0)
          {
            fin <- 0
          }
        else
          {
            fin <- 1
          }
        while (fin!=1)
          {
            nbiter <- nbiter + 1

            profileCGH <- filterBkp(profileCGH, MinBkpWeight=MinBkpWeight, DelBkpInAmp=DelBkpInAmp, DelBkpInDel=DelBkpInDel, assignGNLOut=assignGNLOut, verbose=verbose)

            if (is.data.frame(profileCGH$BkpInfo))
              {
                BkpInfo <- profileCGH$BkpInfo
                indexWeightToSmall <- which(BkpInfo$Weight<MinBkpWeight & BkpInfo$GNLchange==0 & BkpInfo$ZoneGNL!=2)
                indexWeightZero <- which(BkpInfo$Weight==0 & BkpInfo$GNLchange==1)
                if (length(indexWeightToSmall) > 0 || length(indexWeightZero) > 0)
                  {
                    fin <- 0
                  }
                else
                  {
                    fin <- 1
                  }
                if(nbiter > maxiter)
                  {
                    fin <- 1
                    print("There is something wrong in the loop calling filterBkp")
                  }
              }
            else
              {
                fin <- 1
              }
          }
      }


    if (verbose) print("filterBkpStep: ending function")
    
    return(profileCGH)
    
  }

Try the GLAD package in your browser

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

GLAD documentation built on Nov. 8, 2020, 11:10 p.m.