summary.loci: Print and Summaries of Loci Objects

View source: R/summary.loci.R

summary.lociR Documentation

Print and Summaries of Loci Objects

Description

These functions print and summarize table of alleles and loci (objects of class "loci").

Usage

## S3 method for class 'loci'
print(x, details = FALSE, ...)
## S3 method for class 'loci'
summary(object, ...)
## S3 method for class 'summary.loci'
print(x, ...)
## S3 method for class 'loci'
x[i, j, drop = FALSE]
## S3 method for class 'summary.loci'
plot(x, loci, what = "both", layout = 1, col = c("blue", "red"), ...)

Arguments

x, object

an object of class "loci" or "summary.loci".

details

a logical value: if TRUE the data are printed as a data frame; the default is FALSE.

i, j

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

drop

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

loci

the loci (genes) to be plotted. By default, all loci are plotted.

what

the frequencies to be plotted. Three choices are possible: "alleles", "genotypes", and "both" (the default), or any unambiguous abbreviations.

layout

the number of graphs to be plotted simultaneously.

col

the colours used for the barplots.

...

further arguments to be passed to or from other methods.

Details

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

Value

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.

Author(s)

Emmanuel Paradis

See Also

read.loci, getAlleles, edit.loci

Examples

data(jaguar)
s <- summary(jaguar)
## Not run: 
## works if the device is large enough:
plot(s, layout = 30, las = 2)
layout(1)

## End(Not run)
## 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

pegas documentation built on May 29, 2024, 2:27 a.m.