Description Usage Arguments Details Value Author(s) See Also Examples
Order/sort genotype or haplotype object according to order of allele names or genotypes
1 2 3 4 5 6 7 8 9 10 | ## S3 method for class 'genotype'
order(..., na.last=TRUE, decreasing=FALSE,
alleleOrder=allele.names(x), genotypeOrder=NULL)
## S3 method for class 'genotype'
sort(x, decreasing=FALSE, na.last=NA, ...,
alleleOrder=allele.names(x), genotypeOrder=NULL)
genotypeOrder(x)
genotypeOrder(x) <- value
|
... |
genotype or haplotype in |
x |
genotype or haplotype in |
na.last |
as in default |
decreasing |
as in default |
alleleOrder |
character, vector of allele names in wanted order |
genotypeOrder |
character, vector of genotype/haplotype names in wanted order |
value |
the same as in argument |
Argument genotypeOrder
can be usefull, when you want that some
genotypes appear "together", whereas they are not "together" by allele
order.
Both methods (order
and sort
) work with genotype and
haplotype classes.
If alleleOrder
is given, genotypeOrder
has no effect.
Genotypes/haplotypes, with missing alleles in alleleOrder
are
treated as NA
and ordered according to order
arguments related to NA
values. In such cases a warning is issued
("Found data values not matching specified alleles. Converting to NA.")
and can be safely ignored. Genotypes present in x
, but not
specified in genotypeOrder
, are also treated as NA
.
Value of genotypeOrder
such as "B/A" matches also "A/B" in case
of genotypes.
Only unique values in argument alleleOrder
or
genotypeOrder
are used i.e. first occurrence prevails.
The same as in order
or sort
Gregor Gorjanc
genotype
,
allele.names
,
order
, and
sort
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | x <- c("C/C", "A/C", "A/A", NA, "C/B", "B/A", "B/B", "B/C", "A/C")
alleles <- c("A", "B", "C")
g <- genotype(x, alleles=alleles, reorder="yes")
## "C/C" "A/C" "A/A" NA "B/C" "A/B" "B/B" "B/C" "A/C"
h <- haplotype(x, alleles=alleles)
## "C/C" "A/C" "A/A" NA "C/B" "B/A" "B/B" "B/C" "A/C"
## --- Standard usage ---
sort(g)
## "A/A" "A/B" "A/C" "A/C" "B/B" "B/C" "B/C" "C/C" NA
sort(h)
## "A/A" "A/C" "A/C" "B/A" "B/B" "B/C" "C/B" "C/C" NA
## --- Reversed order of alleles ---
sort(g, alleleOrder=c("B", "C", "A"))
## "B/B" "B/C" "B/C" "A/B" "C/C" "A/C" "A/C" "A/A" NA
## note that A/B comes after B/C since it is treated as B/A;
## order of alleles (not in alleleOrder!) does not matter for a genotype
sort(h, alleleOrder=c("B", "C", "A"))
## "B/B" "B/C" "B/A" "C/B" "C/C" "A/C" "A/C" "A/A" NA
## --- Missing allele(s) in alleleOrder ---
sort(g, alleleOrder=c("B", "C"))
## "B/B" "B/C" "B/C" "C/C" "A/C" "A/A" NA "A/B" "A/C"
sort(g, alleleOrder=c("B"))
## "B/B" "C/C" "A/C" "A/A" NA "B/C" "A/B" "B/C" "A/C"
## genotypes with missing allele are treated as NA
sort(h, alleleOrder=c("B", "C"))
## "B/B" "B/C" "C/B" "C/C" "A/C" "A/A" NA "B/A" "A/C"
sort(h, alleleOrder=c("B"))
## "B/B" "C/C" "A/C" "A/A" NA "C/B" "B/A" "B/C" "A/C"
## --- Use of genotypeOrder ---
sort(g, genotypeOrder=c("A/A", "C/C", "B/B", "A/B", "A/C", "B/C"))
## "A/A" "C/C" "B/B" "A/B" "A/C" "A/C" "B/C" "B/C" NA
sort(h, genotypeOrder=c("A/A", "C/C", "B/B",
"A/C", "C/B", "B/A", "B/C"))
## "A/A" "C/C" "B/B" "A/C" "A/C" "C/B" "B/A" "B/C" NA
## --- Missing genotype(s) in genotypeOrder ---
sort(g, genotypeOrder=c( "C/C", "A/B", "A/C", "B/C"))
## "C/C" "A/B" "A/C" "A/C" "B/C" "B/C" "A/A" NA "B/B"
sort(h, genotypeOrder=c( "C/C", "A/B", "A/C", "B/C"))
## "C/C" "A/C" "A/C" "B/C" "A/A" NA "C/B" "B/A" "B/B"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.