sort.Pedigree {GeneticsPed} | R Documentation

## Sort pedigree

### Description

Pedigree sort

### Usage

    ## S3 method for class 'Pedigree'
    sort(x, decreasing=FALSE, na.last=TRUE, ..., by="default")

### Arguments

`x` | pedigree, object to be sorted
`decreasing` | logical, sort order
`na.last` | logical, control treatment of `NA`s; check `order`
`...` | arguments passed to `order`, see details
`by` | character, sort by "default", "pedigree", "generation", or "dtBirth" information, see details

### Details

Sorting of the pedigree can be performed in different ways. Since pedigree can contain date of birth, sorting by this would be the most obvious way and it would be the most detailed sort. However, there might be the case that date of birth is not available for some or all individuals. Therefore, this function by default (when `by="default"`) tries to figure out what would be the best way to perform the sort. If date of birth is available for all individuals then date of birth is used for sorting. If not, generation information is used, but only if it is known for all individuals (it should be more or less easy to figure out the generation for all individuals in the pedigree CHECK). Again if not, sorting is done via information in pedigree i.e. ascendants will precede descendants or vice versa. User can always define it's own preference by argument `by`. When `by="dtBirth"` or `by="generation"` sorting is performed via `order` and its arguments `na.last` and `decreasing` can be used. With `by="pedigree"` argument `decreasing` has an effect.

Generation values can have different meaning i.e. values might either increase or decrease from ascendants to descendant with the same meaning. This information is stored in attribute `generationOrder` (at the time of creating the pedigree object via `Pedigree`) and used for determining the order of sorting if sorting is by generation. The output of the result might therefore be opposite of what user might expect. If that is the case, use argument `decreasing` as defined in `order`. Look also into examples bellow.

### Value

Sorted pedigree

### Author(s)

Gregor Gorjanc

### See Also

`Pedigree` and `order`

### Examples

      ped <- generatePedigree(nId=5)
      ped <- ped[sample(1:nrow(ped)), ]
      sort(ped)
      ## sort(ped, by="dtBirth")       ## TODO
      sort(ped, by="generation")
      ## try(sort(ped, by="pedigree")) ## TODO

      ## Sorting with decreasing generation values from ascendants to descendants
      ped1 <- generatePedigree(nId=5, generationOrder="decreasing")
      sort(ped1, by="generation")
      sort(ped1, decreasing=TRUE, by="generation")
      sort(ped1, decreasing=FALSE, by="generation")

      ## Sorting with unknown values
      ped[1, "generation"] <- NA
      sort(ped, na.last=TRUE, by="generation")
      sort(ped, na.last=FALSE, by="generation")
      sort(ped, na.last=NA, by="generation")

[Package GeneticsPed version 1.50.0 Index]