Title: | Permutations of Treatment Labels and TITAN2 Analysis |
---|---|
Description: | Permute treatment labels for taxa and environmental gradients to generate an empirical distribution of change points. This is an extension for the 'TITAN2' package <https://cran.r-project.org/package=TITAN2>. |
Authors: | Peter DeWitt [aut, cre] , Stephanie Figary [aut] , Naomi Detenbeck [aut] |
Maintainer: | Peter DeWitt <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.2 |
Built: | 2024-10-29 04:48:05 UTC |
Source: | https://github.com/usepa/ptitan2 |
Four Example data sets for use the pTITAN2 package.
C_IC_D_06_wID C_IC_N_06_wID CD_06_Mall_wID CN_06_Mall_wID
C_IC_D_06_wID C_IC_N_06_wID CD_06_Mall_wID CN_06_Mall_wID
An object of class data.frame
with 251 rows and 2 columns.
An object of class data.frame
with 124 rows and 2 columns.
An object of class data.frame
with 251 rows and 501 columns.
An object of class data.frame
with 124 rows and 501 columns.
Example data sets are from publicly available macroinvertebrate survey data from California. The data sets are broken down between the environmental variable, in this case percent impervious cover, and macroinvertebrate data. Separate data files are provided for each 'treatment' that is explored. In this case, the treatments are data from either drought (dry) or normal precipitation years in the Chaparral region of California.
CN_06_Mall_wID
(Chaparral Region, Treatment = Normal) file contains
raw macroinvertebrate density data for 500 possible macroinvertebrate codes
for each taxonomic level (class, order, family, genus).
The raw data files are provided for your use as well. See example below for accessing these files.
head(C_IC_D_06_wID) # Environemntal Gradient, Dry Treatment head(C_IC_N_06_wID) # Environemntal Gradient, Normal Treatment head(CD_06_Mall_wID) # Taxonomic, Dry Treatment head(CN_06_Mall_wID) # Taxonomic, Normal Treatment # Get the paths to the raw data files list.files(system.file("extdata", package = "pTITAN2"))
head(C_IC_D_06_wID) # Environemntal Gradient, Dry Treatment head(C_IC_N_06_wID) # Environemntal Gradient, Normal Treatment head(CD_06_Mall_wID) # Taxonomic, Dry Treatment head(CN_06_Mall_wID) # Taxonomic, Normal Treatment # Get the paths to the raw data files list.files(system.file("extdata", package = "pTITAN2"))
Generate a taxonomic data set with codes which have at least n occurrences.
occurrences(data, n = 5L)
occurrences(data, n = 5L)
data |
A |
n |
the minimum number of occurrences. |
Of the codes with at least n occurrences, the code with the most taxonomic
detail needs to be selected for the titan
run. This
means if the macroinvertebrate count has at least n occurrences in a genus
code, the family, order, and class codes associated with these counts should
be removed. Or, for another example, if there are too few counts at the
genus level, but at least n counts at the family level- the family code would
be retained and the order and class codes would be removed.
Coding: All of the macroinvertebrates were coded so the first two letters indicate the class, the second two letters indicate the order, the third two letters indicate the family, and the last two numbers indicate the genus. "00" indicates that there is no information at that level. For example: A code that is 'Bi000000' is the Bivalvia class, while BiVe0000 is the Bivalvia class, Veneroida order. BiVeSh00 is the Bivalvia class, Veneroida order, Spheriridae family. BiVeSh01 is a genus within that family.
NOTE: The example script that inspired the development of this function
required the data set to have the column names in alpha order. This function
relaxes that requirement by using the arrange
call.
a data.frame
with six columns: taxon
, Class
,
Order
, Family
, Genus
, and count
.
vignette(topic = "pTITAN2", package = "pTITAN2")
# Report the tax with minimum of five (default) occurrences. occurrences(CN_06_Mall_wID[, -1]) # Report the tax with at least six occurrences occurrences(CN_06_Mall_wID[, -1], n = 6)
# Report the tax with minimum of five (default) occurrences. occurrences(CN_06_Mall_wID[, -1]) # Report the tax with at least six occurrences occurrences(CN_06_Mall_wID[, -1], n = 6)
Results for a permutation example.
permutation_example
permutation_example
An object of class data.frame
with 10 rows and 7 columns.
The code to generate this example permuation set can be found via
system.file("example-scripts", "permutation_example.R", package = "pTITAN2")
vignette("pTITIAN2")
Permute treatment labels for a taxa and associated environmental gradients.
permute(taxa, envs, sid) permute2(..., minTaxonFreq = 3L, trys = 100L)
permute(taxa, envs, sid) permute2(..., minTaxonFreq = 3L, trys = 100L)
taxa |
a list of |
envs |
a list of |
sid |
a character vector of length one with the name of the column identifying the station id. |
... |
passed to permute |
minTaxonFreq |
min number of occurrences for each taxon |
trys |
maximum number of attempts to generate a meaningful permutation |
The taxa and envs lists are expected to be of equal length and that the ith element of taxa list is associated with the ith element of the envs list. That is, the taxa and environmental gradient for treatment 1 are both the first elements of the respective lists, the taxa and environmental gradient for treatment 2 are the second elements for the respective lists, etc.
The environmental gradient data.frames are expected to have two columns, one with the station ID and one with the data defining the gradient.
The taxa data.frames are expected to have the station ID column as well. Important The station ID column name needs to be the same for all the taxa and environmental gradient data.frames.
A list of lists of lists. At the top level the elements are the treatment groups. There are as many elements as the length of the lists taxa and envs.
The second level are the taxa and environmental gradient.
vignette(topic = "pTITAN2", package = "pTITAN2")
example_permutation <- permute(taxa = list(CD_06_Mall_wID, CN_06_Mall_wID), envs = list(C_IC_D_06_wID, C_IC_N_06_wID), sid = "StationID") str(example_permutation, max.level = 2)
example_permutation <- permute(taxa = list(CD_06_Mall_wID, CN_06_Mall_wID), envs = list(C_IC_D_06_wID, C_IC_N_06_wID), sid = "StationID") str(example_permutation, max.level = 2)
Permute treatment labels for taxa and environmental gradients to generate an empirical distribution of change points.