Learn R Programming

CHNOSZ (version 2.2.0)

rank.affinity: Average ranks of chemical affinities

Description

Affinity rankings for groups of species.

Usage

rank.affinity(aout, groups, rescale = TRUE, percent = FALSE)

Value

The average rankings are inserted into the values element of aout, and the names of the groups are inserted into the species element. The result can be used by diagram to make line plots or predominance diagrams (the predominance fields correspond to the groups with highest average ranking of affinity).

Arguments

aout

list, output of affinity

groups

named list of indices (integer or logical) for species in each group

rescale

logical, rescale average ranks for each group to have the same bounds?

percent

logical, take percentages of average ranks for each group (after rescaling)?

Details

The affinities for all species are ranked, then the average rank for the species in each group is calculated. The calculations are applied to each set of conditions individually (i.e., each grid point in the affinity affinity calculation).

Unless rescale is FALSE, the average rank of each group is rescaled to have the same bounds (from 1 to the total number of species). If percent is TRUE, the average ranks of groups (after rescaling) are converted to percentages.

See Also

demo("rank.affinity")

Examples

Run this code
reset()# Compare Rubisco proteins from three domains
datfile <- system.file("extdata/protein/rubisco.csv", package = "CHNOSZ")
aafile <- system.file("extdata/protein/rubisco_aa.csv", package = "CHNOSZ")
dat <- read.csv(datfile)
aa <- read.csv(aafile)
groups <- sapply(c("A", "B", "E"), "==", dat$domain, simplify = FALSE)
names(groups) <- c("Archaea", "Bacteria", "Eukaryota")
ip <- add.protein(aa, as.residue = TRUE)
basis("QEC")
aout <- affinity(O2 = c(-74, -66, 100), H2O = c(-4, 4, 100), iprotein = ip)
arank <- rank.affinity(aout, groups = groups)
nspecies <- sapply(groups, sum)
names <- paste0(names(groups), " (", nspecies, ")")
diagram(arank, fill = "terrain", font = 2, names = names, format.names = FALSE)
title("Average rank of affinity for Rubisco in different domains")

Run the code above in your browser using DataLab