as.geneSet           package:GeneticsBase           R Documentation

_C_o_n_v_e_r_t _a_n _e_x_i_s_t_i_n_g _o_b_j_e_c_t _t_o _a _g_e_n_e_S_e_t

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

     ## 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),
       ...)

_A_r_g_u_m_e_n_t_s:

       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.

_V_a_l_u_e:

     An S4 object of class geneSet

_A_u_t_h_o_r(_s):

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

_S_e_e _A_l_s_o:

     'geneSet'

_E_x_a_m_p_l_e_s:

     ## 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

