R/segregationRatios.R

Defines functions `segregationRatios`

`segregationRatios` <-
function(x, drop.cols=NULL)
{
  
  ## Description: Computes segregation ratios for a matrix of markers
  ## where the rows are markers and the columns are individuals

  ## Arguments:
  ## x : matrix of 0's, 1,s and NA's representing scores of dominant markers
  ##     where the rows are markers and the columns are individuals
  ## drop.cols: columns to drop when calculating segregation ratios

  ## Values:
  ## Returns an object of type segRatio containing
  ## r:  no. of 1's for each individual
  ## n:  total no. of markers present for each individual
  ## seg.ratio:  segregation proportion for each individual
  ## n.individuals: total number of individuals

  if (! is.matrix(x))
    stop("A matrix must be supplied")

  r <- rowSums(x,na.rm=TRUE)
  n <- rowSums(!is.na(x))

  res <- list(r=r, n=n, seg.ratio=r/n, n.individuals=dim(x)[2],
              call=match.call())
  oldClass(res) <- "segRatio"
  return(res)
  
}

Try the polySegratio package in your browser

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

polySegratio documentation built on May 2, 2019, 6:09 p.m.