| Title: | User Tools for Accessing the STOICH Project Database |
|---|---|
| Description: | User tools for working with The STOICH (Stoichiometric Traits of Organisms in their Chemical Habitats) Project database <https://snr-stoich.unl.edu/>. This package is designed to aid in data discovery, filtering, pairing water samples with organism samples, and merging data tables to assist users in preparing data for analyses. For additional examples see "Additional Examples" and the readme file at <https://github.com/STOICH-project/STOICH-utilities>. |
| Authors: | Chad Petersen [aut, cre], Jessica Corman [ctb], Halvor Halvorson [ctb], Casey Brucker [ctb], Eli Wess [ctb], U.S. National Science Foundation [fnd] |
| Maintainer: | Chad Petersen <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.2 |
| Built: | 2026-05-31 06:49:26 UTC |
| Source: | https://github.com/stoich-project/stoich-utilities |
Filters STOICH data tables following a filtering operation against rows of other tables to remove any corresponding entries from other tables.
filterJoinSTOICH(dataTables, filtTable)filterJoinSTOICH(dataTables, filtTable)
dataTables |
The STOICH data tables filtered using filterSTOICH. |
filtTable |
The table name filtering was performed on. |
Tables with corresponding entries that were removed from one table removed from the other tables.
Chad Petersen [email protected]
## Not run: # Not typically run independently. This function is called by filterSTOICH # to clean up before returning data. ## End(Not run)## Not run: # Not typically run independently. This function is called by filterSTOICH # to clean up before returning data. ## End(Not run)
Filters the STOICH data from release files based on selected criteria.
filterSTOICH(dataTables, var, val, condition)filterSTOICH(dataTables, var, val, condition)
dataTables |
The STOICH data tables loaded using loadSTOICH. |
var |
The STOICH variable to filter. Use View(stoichData$metadata) to see a table of all variables and their descriptions (assumes data was loaded into the variable "stoichData"). The variable can be either the joined variable name (including the table name) "SampleDate.SampleEvent" or the prejoin name "SampleDate". The joined variable name will be required for multiple variables with the same name (such as "Notes"). |
val |
The value or value range for the variable you want to filter. The conditions "greater than" and "less than" only work with a single numeric or date value, while "equal" and "not equal" work with a single value or an array of values (text, numeric or date). The "range" condition requires an array of 2 numeric or date values. |
condition |
The criteria used for filtering (greater than, less than, equal, not equal, range, etc.). See the val parameter for the possible inputs for each condition. |
The STOICH data tables after filtering has been applied.
Chad Petersen [email protected]
## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") # filtering by table such as: stoichFiltered <- filterSTOICH(dataTables=stoichData, var="TrophicMode", val="photoautotroph", condition="equal") stoichFiltered <- filterSTOICH(dataTables=stoichData, var="Latitude", val=c(54.1, 103.1), condition="range") stoichFiltered <- filterSTOICH(dataTables=stoichData, var="Type.OrganismStoichiometry", val="seston", condition="equal") stoichFiltered <- filterSTOICH(dataTables=stoichData, var="Name", val=c("Suggs", "Barco"), condition="contains") stoichTable <- joinSTOICH(stoichFiltered) ## End(Not run)## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") # filtering by table such as: stoichFiltered <- filterSTOICH(dataTables=stoichData, var="TrophicMode", val="photoautotroph", condition="equal") stoichFiltered <- filterSTOICH(dataTables=stoichData, var="Latitude", val=c(54.1, 103.1), condition="range") stoichFiltered <- filterSTOICH(dataTables=stoichData, var="Type.OrganismStoichiometry", val="seston", condition="equal") stoichFiltered <- filterSTOICH(dataTables=stoichData, var="Name", val=c("Suggs", "Barco"), condition="contains") stoichTable <- joinSTOICH(stoichFiltered) ## End(Not run)
Joins the STOICH data tables from release files into a single table.
joinSTOICH(dataTables)joinSTOICH(dataTables)
dataTables |
The STOICH data tables loaded using loadSTOICH. |
A single table merged from the individual STOICH data tables.
Chad Petersen [email protected]
## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") # filtering by table such as: stoichFiltered <- filterSTOICH(dataTables=stoichData, var="TrophicMode", val="photoautotroph", condition="not equal") |> filterSTOICH(dataTables=stoichFiltered, var="Latitude", val=c(104.92, 103.01), condition="range") stoichTable <- joinSTOICH(stoichFiltered) ## End(Not run)## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") # filtering by table such as: stoichFiltered <- filterSTOICH(dataTables=stoichData, var="TrophicMode", val="photoautotroph", condition="not equal") |> filterSTOICH(dataTables=stoichFiltered, var="Latitude", val=c(104.92, 103.01), condition="range") stoichTable <- joinSTOICH(stoichFiltered) ## End(Not run)
Loads STOICH data from release files.
loadSTOICH(dataPath = file.path(path.expand("~"), "data"))loadSTOICH(dataPath = file.path(path.expand("~"), "data"))
dataPath |
The path to the STOICH data directory. |
A list containing the STOICH data tables
Chad Petersen [email protected]
## Not run: stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") ## End(Not run)## Not run: stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") ## End(Not run)
Looks for matches between organism stoichiometry and water chemistry data when the date & time or GPS locations are slightly off. This could be time intensive so if possible perform any filtering operations before locating data pairs.
locateDataPairsSTOICH( dataTables, timeDiff = 7, timeUnits = "days", distance = 1, pairMethod = "Min Time", ignoreExisting = TRUE )locateDataPairsSTOICH( dataTables, timeDiff = 7, timeUnits = "days", distance = 1, pairMethod = "Min Time", ignoreExisting = TRUE )
dataTables |
The STOICH data tables loaded using loadSTOICH. |
timeDiff |
The maximum time difference to consider for matches between data. |
timeUnits |
What units to use for the time difference search (months, weeks, days, hours). |
distance |
Distance between data points in km. |
pairMethod |
How to determine the best pair from multiple matches. Options are: Min Time - Prioritize the minimum time. Min Dist - Prioritize the minimum distance. #days=#km - Minimize in space and time using a relation for # days equal # kilometers (enter decimal numbers, i.e. "1.5days=2.1km"). Avg Water - Takes the average for all the water chemistry data returned that matches an organism data entry. |
ignoreExisting |
Determines if the existing data pairs should be ignored and processed the same as other data. Probably only useful for averaging water data since the other data points already have matching time and distance data. |
The STOICH data tables after pairs have been found. The water chemistry data will be copied to a new entry with a SampleEventId matching the organism stoichiometry data. The notes will be updated adding a comment about the original SampleEventId(s), such as "OriginalSampleEventId=(10, 11, 12)" for an average of 3 water chemistry samples to the Notes of tbl_WaterChemistry.
Chad Petersen [email protected]
## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") # filtering by table and pairing example with pipes: stoichFiltered <- stoichData |> filterSTOICH(var="Latitude", val=c(54.1, 103.1), condition="range") |> locateDataPairsSTOICH(timeDiff=2, timeUnits="weeks", distance=1, pairMethod="1.5days=2.1km") stoichTable <- joinSTOICH(stoichFiltered) ## End(Not run)## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") # filtering by table and pairing example with pipes: stoichFiltered <- stoichData |> filterSTOICH(var="Latitude", val=c(54.1, 103.1), condition="range") |> locateDataPairsSTOICH(timeDiff=2, timeUnits="weeks", distance=1, pairMethod="1.5days=2.1km") stoichTable <- joinSTOICH(stoichFiltered) ## End(Not run)
Used to help explore the STOICH data.
metadataSTOICH(dataTables, metadata = NA)metadataSTOICH(dataTables, metadata = NA)
dataTables |
The STOICH data tables loaded using loadSTOICH. |
metadata |
A character describing what type of metadata is being requested. Possible options are: "variables", "joined", "full". metadata="joined" returns the variable names after joinSTOICH is performed (you can use this name before the join to identify a table and variable). metadata="full" returns a table of all the variables, the table name it belongs to and what data is stored in each variable. |
A vector or table with the requested data.
Chad Petersen [email protected]
## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") # list the variable names metadataSTOICH(stoichData, "variables") ## End(Not run)## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") # list the variable names metadataSTOICH(stoichData, "variables") ## End(Not run)
Checks if the STOICH data tables loaded from release files are in the proper format for joining and filtering.
verifySTOICH(dataTables)verifySTOICH(dataTables)
dataTables |
The STOICH data tables loaded using loadSTOICH. |
True if the STOICH data tables are the correct format or stop and return the first error found if an incorrect format is detected.
Chad Petersen [email protected]
## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") verifySTOICH(stoichData) ## End(Not run)## Not run: # Load the data stoichData <- loadSTOICH(dataPath="C:/Users/example_user/STOICH_data_location") verifySTOICH(stoichData) ## End(Not run)