Please cite the use of our package in your papers so other scientists can learn about tRowel! We built this package in our limited free time, so every citation genuinely helps (and motivates us to keep creating free tools for the community).
Thank you, Gwen
library(tRowel)
https://drive.google.com/drive/folders/1kG1JcsoekXWp2iKFw15Ney-96iyfJT7e?usp=sharing
1:1 testPit and testElevation
1:2 InambariRegion
2:1 munsling - Converts a Munsell specification
to CIE Lab coordinates for clustering 2:2
ratioRustler - Calculate elemental ratios
3:1 terraTrend - Plot proxy trends 3:2
buriedBar - Plots proxies with a bar plot 3:3
loamRanger - Plots composition of sand, silt, and clay in
soil/sediment 3:4 groundTruth - Prepares your
soil/sediment picture for use in paleoPanel 3:5
paleoPanel - Plots multiple existing figures/plots to
create a panel of figures
4:1 clastCluster - Statistically cluster
(Gower’s or Euclidean) and graphically display soil/sediment data as a
profile 4:2 terraceWrangler - Plots
clastCluster data with landscape elevation
testPit and testElevation are dataframes within tRowel for practicing using the functions. testPit is a faux soil/sediment dataframe with randomly picked paleoenvironmental data. testElevation is a dataframe to practice terraceWrangler. It contains random elevation data.
InambariRegeion is a subset of a larger soil geochemistry dataframe comparing Amazonian Dark Earths to naturally formed soil in the Amazon. For further information on this dataset: https://datadryad.org/dataset/doi:10.5061/dryad.3tx95x6cc
data(testPit, package = "tRowel")
data(testElevation, package = "tRowel")
munsling - Converts a Munsell specification to CIE Lab
coordinates for clusteringratioRustler - Calculate elemental ratiosmunsling allows the user to convert Munsell colors into
CIE Lab coordinates for future clustering. There are three arguments.
The bolded arguments are required to run the function:
Here is an example of munsling with testPit. You must save your data to a new dataframe name.
testPit_withMun <- munsling(testPit, munsellCol = "Munsell")
ratioRustler calculates ratios and adds a column of the calculated ratio to your dataframe. It takes the numerator column(s) for a row and divides it by the denominator column(s) from the same row and places the new ratio values in a new column. The author typically uses this for pXRF data. There are four arguments. The bolded arguments are required to run the function:
Example with vector input (i.e. only calculating one ratio at a time)
testPit_withRatio <- ratioRustler(df = testPit, numerator = "Fe",denominator = "Ca", new_col = "MyRatio",
removeNAs = TRUE)
Example with a list input (i.e. calculating multiple ratios at a time)
nums <- list(c("Fe","Ca"),"Al", "Si")
denoms <- list("K","P",c("Sr","Fe"))
#Create the following ratios: (Fe+Ca)/K, Al/P, and Si/(Sr+Fe)
testPit_withRatio <- ratioRustler(df = testPit, numerator = nums, denominator = denoms, new_col = NULL,
removeNAs = TRUE)
terraTrend plots paleoenvironmental trends with depth
below surface on the Y axis and proxy values on the X axis to illustrate
trends across time/depth. There are 18 arguments for this function. The
bolded arguments below are required to run the function:
#filter for one profile
testPitP5 <- dplyr::filter(testPit, ProfileID == "Profile_5")
terraP5 <- terraTrend(testPitP5,depth = "Depth_cm_Start",max_depth = 140,proxies = c("Ca","Mg"),measurement_lab = "PPM", linecolors = c("green","blue"),legendtitle = "Elements",depth_lab = "Depth (cm)")
terraP5
buriedBar plots a side-by-side bar graph to analyze and
compare the quantity of pollen counts (or other proxy) by depth. There
are 19 arguments. The bolded arguments below are required to run the
function:
#filter for one profile
testPitP5 <- dplyr::filter(testPit, ProfileID == "Profile_5")
buriedP5 <- buriedBar(testPitP5, proxies = c("OrganicC_pct","Carbonate_pct"), depth = "Depth_cm_Start", title = "LOI", max_depth = 140, measurement_lab = "% of sample", legendtitle= "Proxies", barcolors = c("purple","orange"))
buriedP5
#add panel example
loamRanger plots the composition of soil/sediments by
the percent representation of clay, silt, and sand. There are 11
arguments. The bolded arguments are required to use the function:
#filter for one profile
testPitP5 <- dplyr::filter(testPit, ProfileID == "Profile_5")
loamP5 <- loamRanger(testPitP5, depth = "Depth_cm_Start", sand = "Sand_pct", silt = "Silt_pct", sandcolor = "blue", siltcolor = "green", claycolor = "purple", mindepth=0, title = "Texture of Profile 5")
loamP5
groundTruth prepares your soil/sediment profile picture for use in paleoPanel. This function saves your soil/sediment pic as a ggplot object, so you can combine it with other plots in paleoPlot.
#download example image
file_path <- system.file("extdata", "groundTruth.png", package = "tRowel")
#save to figure name
soilpic <- groundTruth(file_path, imageformat = "png", width = 10, height = 10, WHratio = 1)
paleoPanel plots multiple existing figures/plots to create a multi-figure panel plot.
#No groundTruth image:
paleoPanel(terraP5,buriedP5,loamP5,cols = 3,border=TRUE)
#With groundTruth
paleoPanel(terraP5,buriedP5,loamP5,cols = 3,profile = soilpic,plotwidths = c(1,3))
## Coordinate system already present.
## ℹ Adding new coordinate system, which will replace the existing one.
You can control the figure size/dimensions when you set up your opts_chunk or when you hit Export (export > save image > adjust width/height > update preview). If your preview of your figure looks distorted, you need to adjust your RStudio setting or just wait to export them.
These figures function as ggplots. So, if you want to add something (i.e. a new theme), you’d type your figure name and then use plus signs like you would in ggplot2 (for more information see ggplot2 package)
clastCluster statistically clusters (using Gower’s or Euclidean) and then graphically display soil/sediment data as a profile. Before completing the cluster analysis, the function will display an average silhouette plot (the ideal number of clusters will have the highest value). The user will manually type the number of clusters in the console and hit enter. next, the function will return any plots the user picked in the arguments (ordination or plot [profile plot]) and return a list containing the data and plots.This data can be used to apply elevation points to the plot in terraceWrangler.
There are 16 arguments. The bolded arguments are required: 1) dirtdata Data frame containing soil characteristic data for clustering.Should have unique rownames. 2) distance Character. Either Euclidean (“E”, “e”, “Euclidean”, “euclidean”) or Gower (“G”,“g”, “Gower”,“gower”). If you have only numeric data, use Euclidean. If your data contains a mix of data types, use Gower. 3) depthStart Name of the column in dirtdata containing information on the starting depth of sample. 4) depthEnd Name of the column in dirtdata containing information on the ending depth of sample. 5) profile The name of column containing profile IDs if multiple soil profiles exist in dirtdata. If the data contains one single profile, set to Null. Default is NULL (i.e. a single profile). 6) ordination Logical. Should an ordination of the data be performed and plotted. Default is FALSE. If distance = Euclidean, Principle Component Analysis (PCA) is performed. If distance = Gower, a Principle Co-ordinate Analysis (PCoA) is performed. 7) minK Numeric. Minimum number of clusters to try. Default is 2. 8) maxK Numeric. Maximum number of clusters to try. Must be less than the number of rows in dirtdata. Default is 10. 9) nstart Numeric. Number of random starts to be used in clustering algorithm. 10) plot Logical. Should profile cluster plots be generated. Default is TRUE. 11) depthticks Numeric. Interval for plotting depth. Default is 10. 12) minDepth Numeric. Minimum depth to be used in plotting. Default is 0. 13) maxDepth Numeric. Maximum depth to be used in plotting. Default is NULL. 14) clusterColors Character. Colors to be used in plotting. Default is random soil-like colors. 15) profileOrder Character. Order in which to plot profiles if multiple soil profiles are present in dirtdata. 16) profileName Character. If a single profile. What should profile be named? Default is Null. 17) plotTitle Character. Title for ordination plots. Default is NULL.
#Example using Euclidean distance and PCA
library(dplyr)
testPitM <- testPit_withMun
testPitM <- select(testPitM, -c(Munsell) )
EuclidExample <- clastCluster(dirtdata = testPitM, distance = "E", depthStart = "Depth_cm_Start", depthEnd = "Depth_cm_End",
profile = "ProfileID", ordination = TRUE, plot = TRUE, maxDepth = 150, depthticks = 10)
4#For the number of clusters to select
EuclidExample
#Example using Gower's distance and PCoA
# testPit2 <- testPit
# testPit2 <- select(testPit2, -c(SampleID) )
GowerExample <- clastCluster(dirtdata = testPitM, distance = "G",depthStart = "Depth_cm_Start", depthEnd = "Depth_cm_End",
minK = 2, maxK=8, profile = "ProfileID", ordination = TRUE, plot = TRUE, plotTitle="Cluster Analysis of Arroyo Profiles",
maxDepth = 150, depthticks = 10)
4#For the number of clusters to select
GowerExample
Note that in this example, that we set maxDepth = 150
even though our maximum in the depthStart in the data is
140. This is because data in our case for depthStart
represent the starting depth of a sample zone and our sample zones are
every 10 cm. Therefore we need to add 10 to our maximum depth range when
plotting to include samples starting at 140 cm.
terraceWrangler uses the returned data from clastCluster and replots it with elevation to show relief across a landscape. So, profiles must be entered in order from the original dirtdata used in clastCluster.
There are 10 arguments. The bolded arguments are required to run the function:
You must complete the clastCluster example above before running the terraceWrangler examples.
terraceWrangler(clastData = EuclidExample$data, elevData = testElevation,surfaceElevM = "surfaceElevM",profileClast = "ProfileID",profileElev = "ProfileID")