as.geneSet {GeneticsBase} | R Documentation

## Convert an existing object to a geneSet

### Description

Convert an existing object to a geneSet. Methods currenrly exist only for matrix and data.frame objects.

### Usage

    ## S3 method for class 'matrix':
    as.geneSet(x, ... )
    ## S3 method for class 'data.frame':
    as.geneSet(x,
      gene.columns,
      format=c("single", "adjacent"),
      ploidy=2,
      alleles=NULL,
      sep="/",
      remove.spaces=TRUE,
      reorder=c("freq", "yes", "no", "default", "ascii"),
      allow.partial.missing=FALSE,
      markerNames,
      phase=list(F),
      ...)

### Arguments

`x` | The matrix or data.frame object to be converted
`gene.columns` | Names or indexes of columns containing genotypes
`format` | One of "single", indiciating that each specified column contains a complete genotype (e.g. "A/C"), or "adjacent" indicating that sets of `ploidy` adjacent columns each contain as single allele (e.g. "A", "C")
`ploidy` | Number of allele copies per genotype. Defaults to 2
`alleles` | Not currently supported. In the future, this variable will allow specification of the allele strings for each genotype.
`sep` | A character value or a numeric index vector indicating how allels are spearated within genotypes, defaults to "/". If a character, it indicates that alleles within a genotype are separated by this character (e.g. for "A/C", `sep="/"`). If a numeric vector (of length `ploidy`-1), the value(s) indicate which positions separate allele names (e.g. for "AA", `sep=1`).
`remove.spaces` | Should whitespace be removed before processing.
`reorder` | One of "freq", "yes", "no", "default", or "ascii", indicating whether and how alleles should be reorderd within genotypes. If `reorder="no"`, the observed order is preserved (important when phase is known). If `reorder="freq"`, sort alleles within each individual by observed frequency. If `reorder="yes"`, sort alleles in the order provided by the `alleles` argument. If `reorder="ascii"`, reorder alleles in ASCII order (alphabetical, with all upper case before lower case). The default value is `"freq"`.
`allow.partial.missing` | Logical value indicating whether a genotype is permitted to be partially missing. When `allow.partial.missing=FALSE`, if any individual allele is missing within a genotype, the entire genotype will be converted to a missing value. When `allow.partial.missing=TRUE`, the missingness of individual alleles will be preserved.
`markerNames` | Character vector of names to use for the genotype columns. This must have the same lenght as the number of genotype columns.
`phase` | List indicating whether phase is known for each genotype column. If the list has a single logical entry, this will apply to all genotype columns.
`...` | Optional arguments.

### Value

An S4 object of class geneSet

### Author(s)

Gregory R. Warnes greg@random-technologies-llc.com

### See Also

`geneSet`

### Examples

    ## Create a test data set where there are several genotypes in columns
    ## of the form "A/T".
    test1 <- data.frame(Tmt=sample(c("Control","Trt1","Trt2"),20, replace=TRUE),
                    G1=sample(c("A/T","T/T","T/A",NA),20, replace=TRUE),
                    N1=rnorm(20),
                    I1=sample(1:100,20,replace=TRUE),
                    G2=paste(sample(c("134","138","140","142","146"),20,
                                    replace=TRUE),
                             sample(c("134","138","140","142","146"),20,
                                    replace=TRUE),
                             sep=" / "),
                    G3=sample(c("A /T","T /T","T /A"),20, replace=TRUE),
                    comment=sample(c("Possible Bad Data/Lab Error",""),20,
                                   rep=TRUE)
                    )
    test1

    ## now automatically convert genotype columns
    geno1 <- as.geneSet(test1)
    geno1

[Package GeneticsBase version 1.6.0 Index]