These functions print and summarize table of alleles and loci (objects
of class "loci"
).
# S3 method for loci
print(x, details = FALSE, ...)
# S3 method for loci
summary(object, ...)
# S3 method for summary.loci
print(x, ...)
# S3 method for loci
[(x, i, j, drop = FALSE)
# S3 method for summary.loci
plot(x, loci, what = "both", layout = 1, col = c("blue", "red"), ...)
summary.loci
returns a list with the genes as names and each
element made a list with two vectors "genotype"
and
"allele"
with the frequencies (numbers) of genotypes and
alleles, respectively. The names of these two vectors are the observed
genotypes and alleles.
print
and plot
methods return NULL.
an object of class "loci"
or "summary.loci"
.
a logical value: if TRUE
the data are printed as
a data frame; the default is FALSE
.
indices of the rows and/or columns to select or to drop. They may be numeric, logical, or character (in the same way than for standard R objects).
a logical specifying whether to returned an object of
the smallest dimension possible, i.e., may return a vector or a
factor if drop = TRUE
(this is not the default).
the loci (genes) to be plotted. By default, all loci are plotted.
the frequencies to be plotted. Three choices are possible:
"alleles"
, "genotypes"
, and "both"
(the default),
or any unambiguous abbreviations.
the number of graphs to be plotted simultaneously.
the colours used for the barplots.
further arguments to be passed to or from other methods.
Emmanuel Paradis
Genotypes not observed in the data frame are not counted.
When using the [
method, if only one column is extracted and
the option drop = TRUE
, or if the returned data frame has no `locus'
column, then the class "loci"
is dropped. The option drop = FALSE
(default) keeps the class (see examples).
An object of class "loci"
can be edited in the R data editor
with, e.g., fix(x)
or x <- edit(x)
.
summary.loci
computes the absolute frequencies (counts); see
the examples on how to compute the relative frequencies (proportions).
read.loci
, getAlleles
, edit.loci
data(jaguar)
s <- summary(jaguar)
if (FALSE) {
## works if the device is large enough:
plot(s, layout = 30, las = 2)
layout(1)
}
## compute the relative frequencies:
rapply(s, function(x) x/sum(x), how = "replace")
## extract a single locus:
jaguar[, 1]
jaguar[, 1, drop = TRUE] # returns a vector
jaguar[[1]] # also returns a vector
Run the code above in your browser using DataLab