counts_to_percentages: Calculate counts percentages

Description Usage Arguments Details Value Examples

Description

This function transforms the counts matrix (samples x taxa) in the @commdf@counts slot of a epd.entity.df-class object to percentages relative to the total amount of particles in each sample (row).

Usage

1
2
3
4
5
6
7
counts_to_percentages(x, offset = 1e-04)

## S4 method for signature 'epd.entity.df'
counts_to_percentages(x, offset = 1e-04)

## S4 method for signature 'epd.entity'
counts_to_percentages(x, offset = 1e-04)

Arguments

x

epd.entity epd.entity.df-class or epd.entity-class objects.

offset

numeric Numeric value to avoid dividing by zero if the total of particles is zero for a particular sample. This may happen when x has been filtered by taxa groups. For instance, if only trees and shrubs ("TRSH") are kept in the x@commdf@counts slot some sites in the last glacial maximum could have no pollen at all, because all vegetation was herbaceos or small shrubs. The effect of the offset is negligible because it only affect pollen counts of zero. The result is to indicate that when counts are present, the results is numerical zero and not NA. This is relevant to discriminate sites and times combinations where pollen counts are not available (NA) and not numerically zero.

Details

Although the function work with epd.entity.df-class and epd.entity-class objects, the later are previously transformed using entity_to_matrices without any posterior data manipulation and transformation. A lot of entities have information from different taxonomical groups (terrestrial plants pollen and algae or fungi spores). Hence, percentages calculated in this base may be meaningless and its use is unrecommended.

Value

The function returns a epd.entity.df-class object, which is a modified version of x (or entity_to_matrices(x) if x is a epd.entity-class object), in which values in @counts slot represent percentages instead of raw counts.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
epd.connection <- connect_to_epd(host="localhost", database="epd",
                                 user="epdr", password="epdrpw")
epd.1 <- get_entity(1, epd.connection)
epd.1 <- entity_to_matrices(epd.1)
epd.1 <- filter_taxagroups(epd.1, c("DWAR", "HERB", "LIAN", "TRSH",
                           "UPHE", "INUN")) ## All pollen taxa groups
epd.1.percent <- counts_to_percentages(epd.1)
head(epd.1.percent@commdf@counts)
head(epd.1@commdf@counts)

## End(Not run)

dinilu/EPDr documentation built on Aug. 22, 2019, 1:03 p.m.