diff --git a/StudentNotebooks/Assignment02/fitchs2-dar-f24-assignment2.Rmd b/StudentNotebooks/Assignment02/fitchs2-dar-f24-assignment2.Rmd new file mode 100755 index 0000000..b4acb05 --- /dev/null +++ b/StudentNotebooks/Assignment02/fitchs2-dar-f24-assignment2.Rmd @@ -0,0 +1,750 @@ +--- +title: "Mars 2020 Mission Data Notebook:" +subtitle: "DAR Assignment 2 (Fall 2024)" +author: "Sean Fitch" +date: "`r format(Sys.time(), '%d %B %Y')`" +output: + html_document: + toc: true + number_sections: true + df_print: paged + pdf_document: default +--- +```{r setup, include=FALSE} + +# Required R package installation; RUN THIS BLOCK BEFORE ATTEMPTING TO KNIT THIS NOTEBOOK!!! +# This section install packages if they are not already installed. +# This block will not be shown in the knit file. +knitr::opts_chunk$set(echo = TRUE) + +# Set the default CRAN repository +local({r <- getOption("repos") + r["CRAN"] <- "http://cran.r-project.org" + options(repos=r) +}) + +if (!require("pandoc")) { + install.packages("pandoc") + library(pandoc) +} + +# Required packages for M20 LIBS analysis +if (!require("rmarkdown")) { + install.packages("rmarkdown") + library(rmarkdown) +} +if (!require("tidyverse")) { + install.packages("tidyverse") + library(tidyverse) +} +if (!require("stringr")) { + install.packages("stringr") + library(stringr) +} + +if (!require("ggbiplot")) { + install.packages("ggbiplot") + library(ggbiplot) +} + +if (!require("pheatmap")) { + install.packages("pheatmap") + library(pheatmap) +} +if (!require("dbscan")) { + install.packages("dbscan") + library(dbscan) +} +if (!require("plotly")) { + install.packages("plotly") + library(plotly) +} +if (!require("dplyr")) { + install.packages("dplyr") + library(dplyr) +} +if (!require("corrplot")) { + install.packages("corrplot") + library(corrplot) +} + +``` + + +# DAR ASSIGNMENT 2 (Introduction): Introductory DAR Notebook + +This notebook is broken into two main parts: + +* **Part 1:** Preparing your local repo for **DAR Assignment 2** +* **Part 2:** Loading and some analysis of the Mars 2020 (M20) Datasets + * Lithology: _Summarizes the mineral characteristics of samples collected at certain sample locations._ + * PIXL: Planetary Instrument for X-ray Lithochemistry. _Measures elemental chemistry of samples at sub-millimeter scales of samples._ + * SHERLOC: Scanning Habitable Environments with Raman and Luminescence for Organics and Chemicals. _Uses cameras, a spectrometer, and a laser of samples to search for organic compounds and minerals that have been altered in watery environments and may be signs of past microbial life._ + * LIBS: Laser-induced breakdown spectroscopy. _Uses a laser beam to help identify minerals in samples and other areas that are beyond the reach of the rover's robotic arm or in areas too steep for the rover to travel._ + +* **Part 3:** Individual analysis of your team's dataset + +* **Part 4:** Preparation of Team Presentation + + +**NOTE:** The RPI github repository for all the code and data required for this notebook may be found at: + +* https://github.rpi.edu/DataINCITE/DAR-Mars-F24 + + +# DAR ASSIGNMENT 2 (Part 1): Preparing your local repo for Assignment 2 + +In this assignment you'll start by making a copy of the Assignment 2 template notebook, then you'll add to your copy with your original work. The instructions which follow explain how to accomplish this. + +**NOTE:** You already cloned the `DAR-Mars-F24` repository for Assignment 1; you **do not** need to make another clone of the repo, but you must begin by updating your copy as instructed below: + +## Updating your local clone of the `DAR-Mars-F24` repository + +* Access RStudio Server on the IDEA Cluster at http://lp01.idea.rpi.edu/rstudio-ose/ + * REMINDER: You must be on the RPI VPN!! +* Access the Linux shell on the IDEA Cluster by clicking the **Terminal** tab of RStudio Server (lower left panel). + * You now see the Linux shell on the IDEA Cluster + * `cd` (change directory) to enter your home directory using: `cd ~` + * Type `pwd` to confirm where you are +* In the Linux shell, `cd` to `DAR-Mars-F24` + * Type `git pull origin main` to pull any updates + * Always do this when you being work; we might have added or changed something! +* In the Linux shell, `cd` into `Assignment02` + * Type `ls -al` to list the current contents + * Don't be surprised if you see many files! +* In the Linux shell, type `git branch` to verify your current working branch + * If it is not `dar-yourrcs`, type `git checkout dar-yourrcs` (where `yourrcs` is your RCS id) + * Re-type `git branch` to confirm +* Now in the RStudio Server UI, navigate to the `DAR-Mars-F24/StudentNotebooks/Assignment02` directory via the **Files** panel (lower right panel) + * Under the **More** menu, set this to be your R working directory + * Setting the correct working directory is essential for interactive R use! + +You're now ready to start coding Assignment 2! + +## Creating your copy of the Assignment 2 notebook + +1. In RStudio, make a **copy** of `dar-f24-assignment2-template.Rmd` file using a *new, original, descriptive* filename that **includes your RCS ID!** + * Open `dar-f24-assignment2-template.Rmd` + * **Save As...** using a new filename that includes your RCS ID + * Example filename for user `erickj4`: `erickj4-assignment2-f24.Rmd` + * POINTS OFF IF: + * You don't create a new filename! + * You don't include your RCS ID! + * You include `template` in your new filename! +2. Edit your new notebook using RStudio and save + * Change the `title:` and `subtitle:` headers (at the top of the file) + * Change the `author:` + * Don't bother changing the `date:`; it should update automagically... + * **Save** your changes +3. Use the RStudio `Knit` command to create an PDF file; repeat as necessary + * Use the down arrow next to the word `Knit` and select **Knit to PDF** + * You may also knit to HTML... +4. In the Linux terminal, use `git add` to add each new file you want to add to the repository + * Type: `git add yourfilename.Rmd` + * Type: `git add yourfilename.pdf` (created when you knitted) + * Add your HTML if you also created one... +5. When you're ready, in Linux commit your changes: + * Type: `git commit -m "some comment"` where "some comment" is a useful comment describing your changes + * This commits your changes to your local repo, and sets the stage for your next operation. +6. Finally, push your commits to the RPI github repo + * Type: `git push origin dar-yourrcs` (where `dar-yourrcs` is the branch you've been working in) + * Your changes are now safely on the RPI github. +7. **REQUIRED:** On the RPI github, **submit a pull request.** + * In a web browser, navigate to https://github.rpi.edu/DataINCITE/DAR-Mars-F24 + * In the branch selector drop-down (by default says **master**), select your branch + * **Submit a pull request for your branch** + * One of the DAR instructors will merge your branch, and your new files will be added to the master branch of the repo. _Do not merge your branch yourself!_ + +# DAR ASSIGNMENT 2 (Part 2): Loading the Mars 2020 (M20) Datasets + +In this assignment there are four datasets from separate instruments on the Mars Perserverance rover available for analysis: + +* **Lithology:** Summarizes the mineral characteristics of samples collected at certain sample locations +* **PIXL:** Planetary Instrument for X-ray Lithochemistry of collected samples +* **SHERLOC:** Scanning Habitable Environments with Raman and Luminescence for Organics and Chemicals for collected samples +* **LIBS:** Laser-induced breakdown spectroscopy which are measured in many areas (not just samples) + +Each dataset provides data about the mineralogy of the surface of Mars. Based on the purpose and nature of the instrument, the data is collected at different intervals along the path of Perseverance as it makes it way across the Jezero crater. Some of the data (esp. LIBS) is collected almost every Martian day, or _sol_. Some of the data (PIXL and SHERLOC) is only collected at certain sample locations of interest + +Your objective is to perform an analysis of the your team's assigned dataset in order to learn all you can about these Mars samples. + +NOTES: + + * All of these datasets can be found in `/academics/MATP-4910-F24/DAR-Mars-F24/Data` + * We have included a comprehensive `samples.Rds` dataset that includes useful details about the sample locations, including Martian latitude and longitude and the sol that individual samples were collected. + * Also included is `rover.waypoints.Rds` that provides detailed location information (lat/lon) for the Perseverance rover throughout its journey, up to the present. This can be updated when necessary using the included `roverStatus-f24.R` script. + * A general guide to the available Mars 2020 data is available here: https://pds-geosciences.wustl.edu/missions/mars2020/index.htm + * Other useful MARS 2020 sites + https://science.nasa.gov/mission/mars-2020-perseverance/mars-rock-samples/ and https://an.rsl.wustl.edu/m20/AN/an3.aspx?AspxAutoDetectCookieSupport=1 + * Note that PIXL, SHERLOC, and Lithology describe 16 sample that were physically collected. There will eventually be 38 samples. These datasets can be merged by sample. The LIBS data includes observations collected at many more locations so how to combine the LIBS data with the other datasets is an open research question. + +## Data Set A: Load the Lithology Data + +The first five features of the dataset describe twenty-four (24) rover sample locations. + +The remaining features provides a simple binary (`1` or `0`) summary of presence or absence of 35 minerals at the 24 rover sample locations. + +Only the first sixteen (16) samples are maintained, as the remaining are missing the mineral descriptors. + +The following code "cleans" the dataset to prepare for analysis. It first creates a dataframe with metadata and measurements for samples, and then creates a matrix containing only numeric measurements for later analysis. + +```{r} +# Load the saved lithology data with locations added +lithology.df<- readRDS("/academics/MATP-4910-F24/DAR-Mars-F24/Data/mineral_data_static.Rds") + +# Cast samples as numbers +lithology.df$sample <- as.numeric(lithology.df$sample) + +# Convert rest into factors +lithology.df[sapply(lithology.df, is.character)] <- + lapply(lithology.df[sapply(lithology.df, is.character)], + as.factor) + +# Keep only first 16 samples because the data for the rest of the samples is not available yet +lithology.df<-lithology.df[1:16,] + +# Look at summary of cleaned data frame +# summary(lithology.df) + +# Create a matrix containing only the numeric measurements. The remaining features are metadata about the sample. +lithology.matrix <- sapply(lithology.df[,6:40],as.numeric)-1 + +# Review the structure of our matrix +# str(lithology.matrix) +``` + + +## Data Set B: Load the PIXL Data + +The PIXL data provides summaries of the mineral compositions measured at selected sample sites by the PIXL instrument. Note that here we scale pixl.mat so features have mean 0 and standard deviation so results will be different than in Assignment 1. + +```{r} +# Load the saved PIXL data with locations added +pixl.df <- readRDS("/academics/MATP-4910-F24/DAR-Mars-F24/Data/samples_pixl_wide.Rds") + +# Convert to factors +pixl.df[sapply(pixl.df, is.character)] <- lapply(pixl.df[sapply(pixl.df, is.character)], + as.factor) + +# Review our dataframe +# summary(pixl.df) + +# Make the matrix of just mineral percentage measurements +pixl.matrix <- pixl.df[,2:14] %>% scale() + +# Review the structure +# str(pixl.matrix) +``` + +## Data Set C: Load the LIBS Data + +The LIBS data provides summaries of the mineral compositions measured at selected sample sites by the LIBS instrument, part of the Perseverance SuperCam. + +```{r} +# Load the saved LIBS data with locations added +libs.df <- readRDS("/academics/MATP-4910-F24/DAR-Mars-F24/Data/supercam_libs_moc_loc.Rds") + +#Drop features that are not to be used in the analysis for this notebook +libs.df <- libs.df %>% + select(!(c(distance_mm,Tot.Em.,SiO2_stdev,TiO2_stdev,Al2O3_stdev,FeOT_stdev, + MgO_stdev,Na2O_stdev,CaO_stdev,K2O_stdev,Total))) + +# Convert the points to numeric +libs.df$point <- as.numeric(libs.df$point) + +# Review what we have +# summary(libs.df) + +# Make the a matrix contain only the libs measurements for each mineral +libs.matrix <- as.matrix(libs.df[,6:13]) + +# Check to see scaling +# str(libs.matrix) +``` + + + +## Dataset D: Load the SHERLOC Data + +The SHERLOC data you will be using for this lab is the result of scientists' interpretations of extensive spectral analysis of abrasion samples provided by the SHERLOC instrument. + +**NOTE:** This dataset presents minerals as rows and sample sites as columns. You'll probably want to rotate the dataset for easier analysis.... + +```{r} + +# Read in data as provided. +sherloc_abrasion_raw <- readRDS("/academics/MATP-4910-F24/DAR-Mars-F24/Data/abrasions_sherloc_samples.Rds") + +# Clean up data types +sherloc_abrasion_raw$Mineral<-as.factor(sherloc_abrasion_raw$Mineral) +sherloc_abrasion_raw[sapply(sherloc_abrasion_raw, is.character)] <- lapply(sherloc_abrasion_raw[sapply(sherloc_abrasion_raw, is.character)], + as.numeric) +# Transform NA's to 0 +sherloc_abrasion_raw <- sherloc_abrasion_raw %>% replace(is.na(.), 0) + +# Reformat data so that rows are "abrasions" and columns list the presence of minerals. +# Do this by "pivoting" to a long format, and then back to the desired wide format. + +sherloc_long <- sherloc_abrasion_raw %>% + pivot_longer(!Mineral, names_to = "Name", values_to = "Presence") + +# Make abrasion a factor +sherloc_long$Name <- as.factor(sherloc_long$Name) + +# Make it a matrix +sherloc.matrix <- sherloc_long %>% + pivot_wider(names_from = Mineral, values_from = Presence) + +# Get sample information from PIXL and add to measurements -- assumes order is the same + +sherloc.df <- cbind(pixl.df[,c("sample","type","campaign","abrasion")],sherloc.matrix) + +# Review what we have +# summary(sherloc.df) + +# Measurements are everything except first column +sherloc.matrix<-as.matrix(sherloc.matrix[,-1]) + +# Sherlock measurement matrix +# Review the structure +# str(sherloc.matrix) +``` + +## Data Set E: PIXL + Sherloc +```{r} +# Combine PIXL and SHERLOC dataframes +pixl_sherloc.df <- cbind(pixl.df,sherloc.df ) + +# Review what we have +str(pixl_sherloc.df) + +# Combine PIXL and SHERLOC matrices +pixl_sherloc.matrix<-cbind(pixl.matrix,sherloc.matrix) + +# Review the structure of our matrix +str(pixl_sherloc.matrix) +summary(pixl_sherloc.matrix) + +pixl_sherloc.scaled<-cbind(scale(pixl.matrix),sherloc.matrix) +pixl_sherloc.scaled <- pixl_sherloc.scaled[, colSums(is.na(pixl_sherloc.scaled)) == 0] +num_duplicates <- sum(duplicated(pixl_sherloc.scaled)) +print(paste("Number of duplicate rows:", num_duplicates)) + +``` + + +## Data Set F: PIXL + Lithography + +Create data and matrix from prior datasets + +```{r} +# Combine our PIXL and Lithology dataframes +pixl_lithology.df <- cbind(pixl.df,lithology.df ) + +# Review what we have +# summary(pixl_lithology.df) + +# Combine PIXL and Lithology matrices +pixl_lithology.matrix<-cbind(pixl.matrix,lithology.matrix) + + +# Review the structure +# str(pixl_lithology.matrix) + +``` + +## Data Set G: Sherloc + Lithology + +Create Data and matrix from prior datasets by taking on appropriate combinations. + +```{r} +# Combine the Lithology and SHERLOC dataframes +sherloc_lithology.df <- cbind(sherloc.df,lithology.df ) + +# Review what we have +# summary(sherloc_lithology.df) + +# Combine the Lithology and SHERLOC matrices +sherloc_lithology.matrix<-cbind(sherloc.matrix,lithology.matrix) + +# Review the resulting matrix +# str(sherloc_lithology.matrix) + +``` +## Data Set H: Sherloc + Lithology + PIXL + +Create data frame and matrix from prior datasets by making on appropriate combinations. + +```{r} +# Combine the Lithology and SHERLOC dataframes +sherloc_lithology_pixl.df <- cbind(sherloc.df,lithology.df, pixl.df ) + +# Review what we have +# summary(sherloc_lithology_pixl.df) + +# Combine the Lithology, SHERLOC and PIXLmatrices +sherloc_lithology_pixl.matrix<-cbind(sherloc.matrix,lithology.matrix,pixl.matrix) + +# Review the resulting matrix +# str(sherloc_lithology_pixl.matrix) + +``` + +# Analysis of Data (Part 3) + +Each team has been assigned one of six datasets: + +1. Dataset B: PIXL: The PIXL team's goal is to understand and explain how scaling changes results from Assignment 1. The matrix version was scaled above but not in Assignment 1. + +2. Dataset C: LIBS (with appropriate scaling as necessary. Not scaled yet.) + +3. Dataset D: Sherloc (with appropriate scaling as necessary. Not scaled yet.) + +4. Dataset E: PIXL + Sherloc (with appropriate scaling as necessary. Not scaled yet.) + +5. Dataset F: PIXL + Lithography (with appropriate scaling as necessary. Not scaled yet.) + +6. Dataset G: Sherloc + Lithograpy (with appropriate scaling as necessary. Not scaled yet.) + +7. Dataset H: PIXL + Sherloc + Lithograpy (with appropriate scaling as necessary. Not scaled yet.) + +**For the data set assigned to your team, perform the following steps.** Feel free to use the methods/code from Assignment 1 as desired. Communicate with your teammates. Make sure that you are doing different variations of below analysis so that no team member does the exact same analysis. If you want to use the same clustering for your team (which is okay but then vary rest), make sure you use the same random seeds. + +1. _Describe the data set contained in the data frame and matrix:_ How many rows does it have and how many features? Which features are measurements and which features are metadata about the samples? (3 pts) + +Metadata: sample name, campaign, abrasion, location +Type (igneous, sedimentary, N/A) +PIXL: + 13 continuous quantitative features (concentrations) +Sherloc: + 35 discrete quantitative features (concentration? likelihood?) + Values 0, 0.25, 0.5, 1 + +2. _Scale this data appropriately (you can choose the scaling method or decide to not scale data):_ Explain why you chose a scaling method or to not scale. (3 pts) + +```{r} +# TODO: maybe sherloc should not be scaled +pixl_sherloc.scaled<-cbind(scale(pixl.matrix),sherloc.matrix) +# pixl_sherloc.scaled <- scale(pixl_sherloc.matrix) + +pixl_sherloc.scaled <- pixl_sherloc.scaled[, colSums(is.na(pixl_sherloc.scaled)) == 0] +# pixl_sherloc.scaled <- unique(pixl_sherloc.scaled) + +# summary(pixl_sherloc.scaled) +# str(pixl_sherloc.scaled) +``` + +I chose to scale PIXL so that different minerals would contribute the same to clusters despite different absolute quantities. +Conversely, SHERLOC remains unscaled since it is already both heavily processed and in the range of 0 to 1. + +3. _Cluster the data using k-means or your favorite clustering method (like hierarchical clustering):_ Describe how you picked the best number of clusters. Indicate the number of points in each clusters. Coordinate with your team so you try different approaches. If you want to share results with your team mates, make sure to use the same random seeds. (6 pts) + +I chose to compare two clustering algorithms, K-means and DBSCAN. I rather arbitrarily chose 4 clusters for K-means (as a point somewhere along the elbow), and chose epsilon +for DBSCAN to create a number of clusters equal to the clusters for K-means. + +```{r} + +# A user-defined function to examine clusters and plot the results +wssplot <- function(data, nc=15, seed=10){ + wss <- data.frame(cluster=1:nc, quality=c(0)) + for (i in 1:nc){ + set.seed(seed) + wss[i,2] <- kmeans(data, centers=i)$tot.withinss} + ggplot(data=wss,aes(x=cluster,y=quality)) + + geom_line() + + ggtitle("Quality of k-means by Cluster") +} + +# Apply `wssplot()` to our data +wssplot(pixl_sherloc.scaled, nc=10, seed=2) +``` + +```{r} +dbscan_plot <- function(data, eps_values, minPts=5) { + results <- data.frame(eps=eps_values, clusters=integer(length(eps_values)), noise=integer(length(eps_values))) + + for (i in seq_along(eps_values)) { + db <- dbscan(data, eps=eps_values[i], minPts=minPts) + results$clusters[i] <- length(unique(db$cluster[db$cluster != 0])) # Excluding noise + results$noise[i] <- sum(db$cluster == 0) + } + + ggplot(results, aes(x=eps)) + + geom_line(aes(y=clusters, color="Number of Clusters")) + + geom_line(aes(y=noise, color="Number of Noise Points")) + + labs(title="DBSCAN Clustering by Eps Parameter", x="Eps", y="Count") + + scale_color_manual("", values = c("Number of Clusters"="blue", "Number of Noise Points"="red")) +} + +# Apply the dbscan_plot function to our data +eps_values <- seq(2, 6, by=0.1) +dbscan_plot(pixl_sherloc.scaled, eps_values, minPts=1) +``` + +```{r} +set.seed(2) +k <- 4 +km <- kmeans(pixl_sherloc.scaled,k) +pheatmap(km$centers,scale="none", main="K-means Heatmap") + +eps <- 4.5 +minPts <- 1 +db <- dbscan(pixl_sherloc.scaled, eps=eps, minPts=minPts) + +# Extracting the core points to calculate cluster centers +core_points <- pixl_sherloc.scaled[db$cluster > 0,] +core_clusters <- db$cluster[db$cluster > 0] +centers <- aggregate(core_points, by=list(cluster=core_clusters), FUN=mean) +centers <- centers[,-1] # Remove the cluster number column + +# Plot the centers using pheatmap +pheatmap(centers, scale="none", main="DBSCAN Heatmap") +``` + + +4. _Perform a **creative analysis** that provides insights into what one or more of the clusters are and what they tell you about the MARS data: Alternatively do another creative analysis of your datasets that leads to one of more findings. Make sure to explain what your analysis and discuss your the results. + +```{r} +plot_by_cluster <- function(cluster_assignments, types, name="") { + # Create a data frame with cluster assignments and rock types + type_counts <- data.frame( + cluster = cluster_assignments, + type = types + ) + + # Summarize rock types by cluster + type_summary <- type_counts %>% + count(cluster, type) %>% + pivot_wider(names_from = type, values_from = n, values_fill = 0) + + # Generate the plot + ggplot(type_summary %>% pivot_longer(-cluster, names_to = "type", values_to = "count")) + + geom_col(aes(x = factor(cluster), y = count, fill = type)) + + labs(x = "Cluster", y = "Count", title = name) + + theme_minimal() + + theme(legend.title = element_blank()) +} + +plot_by_cluster(km$cluster, pixl.df$type, name = "Rock type by K-means cluster") +plot_by_cluster(db$cluster, pixl.df$type, name = "Rock type by DBSCAN cluster") +plot_by_cluster(km$cluster, pixl.df$campaign, name = "Campaign by K-means cluster") +plot_by_cluster(db$cluster, pixl.df$campaign, name = "Campaign by DBSCAN cluster") +plot_by_cluster(km$cluster, pixl.df$abrasion, name = "Abrasion by K-means cluster") +plot_by_cluster(db$cluster, pixl.df$abrasion, name = "Abrasion by DBSCAN cluster") +``` + + +```{r} +num_duplicates <- sum(duplicated(pixl_sherloc.scaled)) +print(paste("Number of duplicate rows:", num_duplicates)) +``` +```{r} +pca_result <- prcomp(pixl_sherloc.scaled, scale. = FALSE) +pca_data <- as.data.frame(pca_result$x[, 1:3]) # Extract the first 3 principal components + +# Add cluster assignments +pca_data$km_cluster <- as.factor(km$cluster) +pca_data$db_cluster <- as.factor(db$cluster) + +plot_pca_3d <- function(pca_data, cluster_col, title) { + p <- plot_ly() + + # Add rays from the origin (0,0,0) to each point + for (i in 1:nrow(pca_data)) { + p <- p %>% + add_trace(x = c(0, pca_data$PC1[i]), + y = c(0, pca_data$PC2[i]), + z = c(0, pca_data$PC3[i]), + type = "scatter3d", mode = "lines", + line = list(color = 'gray', width = 1), + showlegend = FALSE) + } + + # Add the points + p <- p %>% + add_trace(data = pca_data, + x = ~PC1, y = ~PC2, z = ~PC3, + color = ~get(cluster_col), + colors = "Set1", + type = "scatter3d", mode = "markers") %>% + layout(title = title, + scene = list(xaxis = list(title = 'PC1'), + yaxis = list(title = 'PC2'), + zaxis = list(title = 'PC3'))) + + return(p) +} + +# Step 3: Create 3D PCA plots for K-means and DBSCAN clusters +plot_pca_3d(pca_data, "km_cluster", "3D PCA - K-means Clusters") +# plot_pca_3d(pca_data, "db_cluster", "3D PCA - DBSCAN Clusters") +``` + +```{r} +plot_pca_3d(pca_data, "db_cluster", "3D PCA - DBSCAN Clusters") +``` + + +```{r} +# Compute the correlation matrix +corr <- cor(scale(pixl.matrix)) +corr2 <- cor(sherloc.matrix) +corr3 <- cor(scale(pixl.matrix), sherloc.matrix) + +# Plot the correlation heatmap +corrplot(corr, method = "color", type = "upper", + tl.col = "black", tl.srt = 45, + number.cex = 0.7, + col = colorRampPalette(c("blue", "white", "yellow"))(200)) +corrplot(corr2, method = "color", type = "upper", + tl.col = "black", tl.srt = 45, + number.cex = 0.7, + col = colorRampPalette(c("blue", "white", "yellow"))(200)) +corrplot(corr3, method = "color", type = "upper", + tl.col = "black", tl.srt = 45, + number.cex = 0.7, + col = colorRampPalette(c("blue", "white", "yellow"))(200)) +``` +```{r} +# Count unique pairs with 1 or -1 correlation for corr (excluding the diagonal and ignoring NAs) +n_unique_corr_1_minus1 <- sum(((corr[upper.tri(corr, diag = FALSE)] == 1) | + (corr[upper.tri(corr, diag = FALSE)] == -1)), na.rm = TRUE) + +# Count unique pairs with 1 or -1 correlation for corr2 (excluding the diagonal and ignoring NAs) +n_unique_corr2_1_minus1 <- sum(((corr2[upper.tri(corr2, diag = FALSE)] == 1) | + (corr2[upper.tri(corr2, diag = FALSE)] == -1)), na.rm = TRUE) + +# Count unique pairs with 1 or -1 correlation for corr3 (excluding the diagonal and ignoring NAs) +n_unique_corr3_1_minus1 <- sum(((corr3[upper.tri(corr3, diag = FALSE)] == 1) | + (corr3[upper.tri(corr3, diag = FALSE)] == -1)), na.rm = TRUE) + +# Print results +n_unique_corr_1_minus1 +n_unique_corr2_1_minus1 +n_unique_corr3_1_minus1 + +``` + + +```{r} +# Compute the correlation matrix +corr <- cor(pixl_sherloc.scaled) + +# Convert the upper triangle of the correlation matrix (excluding the diagonal) to a long format +corr_upper <- as.data.frame(as.table(corr)) +corr_upper <- corr_upper[upper.tri(corr, diag = FALSE), ] + +# Sort by absolute correlation values (optional) +corr_upper <- corr_upper[order(-abs(corr_upper$Freq)), ] + +# Print the list of correlations +print(corr_upper) +``` +```{r} +# Reintroduce the abrasion column into the scaled matrix +pixl_sherloc.scaledab <- cbind(pixl_sherloc.scaled, abrasion = pixl.df$abrasion) + +# Identify features (excluding 'abrasion') +features <- colnames(pixl_sherloc.scaledab)[colnames(pixl_sherloc.scaledab) != "abrasion"] + +# Convert to data.frame and apply dplyr functions +result <- as.data.frame(pixl_sherloc.scaledab) %>% + group_by(abrasion) %>% + summarise(across(all_of(features), sd, na.rm = TRUE)) %>% + mutate(avg_stdev = rowMeans(across(all_of(features)), na.rm = TRUE)) %>% + ungroup() %>% + mutate(abrasion = levels(pixl.df$abrasion)[abrasion]) # Convert numeric to factor names + +# View the result +print(result$abrasion) +print(result$avg_stdev) +# Create a data frame with abrasion levels and corresponding standard deviations +table_data <- data.frame(Abrasion = result$abrasion, StdDev = result$avg_stdev) + +# Print the table +print(table_data) +``` + +```{r} +pixl.df$abrasion +``` + +Both clustering algorithms split up the same two abbrasions: Bellegrade and Dourbes. This begs the question of why these ones are inconsistent while the rest are consistent. I believe all 4 samples are igneous. + +```{r} +test <- cbind(pixl.matrix, sherloc.matrix) +num_duplicates_combined <- sum(duplicated(test)) +print(paste("Number of duplicate rows in the combined matrix:", num_duplicates_combined)) + +num_duplicates_pixl <- sum(duplicated(pixl.matrix)) +print(paste("Number of duplicate rows in pixl.matrix:", num_duplicates_pixl)) + +num_duplicates_sherloc <- sum(duplicated(sherloc.matrix)) +print(paste("Number of duplicate rows in sherloc.matrix:", num_duplicates_sherloc)) +``` + +It turns out 5 of our data points are duplicates. +Additionally, only looking at SHERLOC or PIXL individually, 7 are duplicates. +Begs the question of why these are duplicated. THey are from the same abbrasions, but surely noise would change the measurements? + +# Preparation of Team Presentation (Part 4) + +Prepare a presentation of your teams result to present in class on **September 11** starting at 9am in AE217 (20 pts) +The presentation should include the following elements + +0.Your teams names and members +1. A **Description** of the data set that you analyzed including how many observations and how many features. (<= 1.5 mins) +2. Each team member gets **three minutes** to explain their analysis: + * what analysis they performed + * the results of that analysis + * a brief discussion of their interpretation of these results + * <= 18 mins _total!_ +3. A **Conclusion** slide indicating major findings of the teams (<= 1.5 mins) +4. Thoughts on **potential next steps** for the MARS team (<= 1.5 mins) + +* A template for your team presentation is included here: https://bit.ly/dar-template-f24 + +* The rubric for the presentation is here: + +https://docs.google.com/document/d/1-4o1O4h2r8aMjAplmE-ItblQnyDAKZwNs5XCnmwacjs/pub + + +* Post a link to your teams presentation in the MARS webex chat before class. You can continue to edit until the last minute. + + + + +# When you're done: SAVE, COMMIT and PUSH YOUR CHANGES! + +When you are satisfied with your edits and your notebook knits successfully, remember to push your changes to the repo using the following steps: + +* `git branch` + * To double-check that you are in your working branch +* `git add ` +* `git commit -m "Some useful comments"` +* `git push origin ` +* do a pull request + + + + + +# APPENDIX: Accessing RStudio Server on the IDEA Cluster + +The IDEA Cluster provides seven compute nodes (4x 48 cores, 3x 80 cores, 1x storage server) + +* The Cluster requires RCS credentials, enabled via registration in class + * email John Erickson for problems `erickj4@rpi.edu` +* RStudio, Jupyter, MATLAB, GPUs (on two nodes); lots of storage and computes +* Access via RPI physical network or VPN only + +# More info about Rstudio on our Cluster + +## RStudio GUI Access: + +* Use: + * http://lp01.idea.rpi.edu/rstudio-ose/ + * http://lp01.idea.rpi.edu/rstudio-ose-3/ + * http://lp01.idea.rpi.edu/rstudio-ose-6/ + * http://lp01.idea.rpi.edu/rstudio-ose-7/ +* Linux terminal accessible from within RStudio "Terminal" or via ssh (below) \ No newline at end of file diff --git a/StudentNotebooks/Assignment02/fitchs2-dar-f24-assignment2.html b/StudentNotebooks/Assignment02/fitchs2-dar-f24-assignment2.html new file mode 100644 index 0000000..8c9bc40 --- /dev/null +++ b/StudentNotebooks/Assignment02/fitchs2-dar-f24-assignment2.html @@ -0,0 +1,5777 @@ + + + + + + + + + + + + + + + +Mars 2020 Mission Data Notebook: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+

1 DAR ASSIGNMENT 2 +(Introduction): Introductory DAR Notebook

+

This notebook is broken into two main parts:

+
    +
  • Part 1: Preparing your local repo for +DAR Assignment 2

  • +
  • Part 2: Loading and some analysis of the Mars +2020 (M20) Datasets

    +
      +
    • Lithology: Summarizes the mineral characteristics of samples +collected at certain sample locations.
    • +
    • PIXL: Planetary Instrument for X-ray Lithochemistry. Measures +elemental chemistry of samples at sub-millimeter scales of +samples.
    • +
    • SHERLOC: Scanning Habitable Environments with Raman and Luminescence +for Organics and Chemicals. Uses cameras, a spectrometer, and a +laser of samples to search for organic compounds and minerals that have +been altered in watery environments and may be signs of past microbial +life.
    • +
    • LIBS: Laser-induced breakdown spectroscopy. Uses a laser beam to +help identify minerals in samples and other areas that are beyond the +reach of the rover’s robotic arm or in areas too steep for the rover to +travel.
    • +
  • +
  • Part 3: Individual analysis of your team’s +dataset

  • +
  • Part 4: Preparation of Team +Presentation

  • +
+

NOTE: The RPI github repository for all the code and +data required for this notebook may be found at:

+ +
+
+

2 DAR ASSIGNMENT 2 (Part +1): Preparing your local repo for Assignment 2

+

In this assignment you’ll start by making a copy of the Assignment 2 +template notebook, then you’ll add to your copy with your original work. +The instructions which follow explain how to accomplish this.

+

NOTE: You already cloned the +DAR-Mars-F24 repository for Assignment 1; you do +not need to make another clone of the repo, but you must begin +by updating your copy as instructed below:

+
+

2.1 Updating your local +clone of the DAR-Mars-F24 repository

+
    +
  • Access RStudio Server on the IDEA Cluster at http://lp01.idea.rpi.edu/rstudio-ose/ +
      +
    • REMINDER: You must be on the RPI VPN!!
    • +
  • +
  • Access the Linux shell on the IDEA Cluster by clicking the +Terminal tab of RStudio Server (lower left panel). +
      +
    • You now see the Linux shell on the IDEA Cluster
    • +
    • cd (change directory) to enter your home directory +using: cd ~
    • +
    • Type pwd to confirm where you are
    • +
  • +
  • In the Linux shell, cd to DAR-Mars-F24 +
      +
    • Type git pull origin main to pull any updates
    • +
    • Always do this when you being work; we might have added or changed +something!
    • +
  • +
  • In the Linux shell, cd into Assignment02 +
      +
    • Type ls -al to list the current contents
    • +
    • Don’t be surprised if you see many files!
    • +
  • +
  • In the Linux shell, type git branch to verify your +current working branch +
      +
    • If it is not dar-yourrcs, type +git checkout dar-yourrcs (where yourrcs is +your RCS id)
    • +
    • Re-type git branch to confirm
    • +
  • +
  • Now in the RStudio Server UI, navigate to the +DAR-Mars-F24/StudentNotebooks/Assignment02 directory via +the Files panel (lower right panel) +
      +
    • Under the More menu, set this to be your R working +directory
    • +
    • Setting the correct working directory is essential for interactive R +use!
    • +
  • +
+

You’re now ready to start coding Assignment 2!

+
+
+

2.2 Creating your copy of +the Assignment 2 notebook

+
    +
  1. In RStudio, make a copy of +dar-f24-assignment2-template.Rmd file using a new, +original, descriptive filename that includes your RCS +ID! +
      +
    • Open dar-f24-assignment2-template.Rmd
    • +
    • Save As… using a new filename that includes your +RCS ID
    • +
    • Example filename for user erickj4: +erickj4-assignment2-f24.Rmd
    • +
    • POINTS OFF IF: +
        +
      • You don’t create a new filename!
      • +
      • You don’t include your RCS ID!
      • +
      • You include template in your new filename!
      • +
    • +
  2. +
  3. Edit your new notebook using RStudio and save +
      +
    • Change the title: and subtitle: headers +(at the top of the file)
    • +
    • Change the author:
    • +
    • Don’t bother changing the date:; it should update +automagically…
    • +
    • Save your changes
    • +
  4. +
  5. Use the RStudio Knit command to create an PDF file; +repeat as necessary +
      +
    • Use the down arrow next to the word Knit and select +Knit to PDF
    • +
    • You may also knit to HTML…
    • +
  6. +
  7. In the Linux terminal, use git add to add each new file +you want to add to the repository +
      +
    • Type: git add yourfilename.Rmd
    • +
    • Type: git add yourfilename.pdf (created when you +knitted)
    • +
    • Add your HTML if you also created one…
    • +
  8. +
  9. When you’re ready, in Linux commit your changes: +
      +
    • Type: git commit -m "some comment" where “some comment” +is a useful comment describing your changes
    • +
    • This commits your changes to your local repo, and sets the stage for +your next operation.
    • +
  10. +
  11. Finally, push your commits to the RPI github repo +
      +
    • Type: git push origin dar-yourrcs (where +dar-yourrcs is the branch you’ve been working in)
    • +
    • Your changes are now safely on the RPI github.
    • +
  12. +
  13. REQUIRED: On the RPI github, submit a pull +request. +
      +
    • In a web browser, navigate to https://github.rpi.edu/DataINCITE/DAR-Mars-F24
    • +
    • In the branch selector drop-down (by default says +master), select your branch
    • +
    • Submit a pull request for your branch
    • +
    • One of the DAR instructors will merge your branch, and your new +files will be added to the master branch of the repo. Do not merge +your branch yourself!
    • +
  14. +
+
+
+
+

3 DAR ASSIGNMENT 2 (Part +2): Loading the Mars 2020 (M20) Datasets

+

In this assignment there are four datasets from separate instruments +on the Mars Perserverance rover available for analysis:

+
    +
  • Lithology: Summarizes the mineral characteristics +of samples collected at certain sample locations
  • +
  • PIXL: Planetary Instrument for X-ray Lithochemistry +of collected samples
  • +
  • SHERLOC: Scanning Habitable Environments with Raman +and Luminescence for Organics and Chemicals for collected samples
  • +
  • LIBS: Laser-induced breakdown spectroscopy which +are measured in many areas (not just samples)
  • +
+

Each dataset provides data about the mineralogy of the surface of +Mars. Based on the purpose and nature of the instrument, the data is +collected at different intervals along the path of Perseverance as it +makes it way across the Jezero crater. Some of the data (esp. LIBS) is +collected almost every Martian day, or sol. Some of the data +(PIXL and SHERLOC) is only collected at certain sample locations of +interest

+

Your objective is to perform an analysis of the your team’s assigned +dataset in order to learn all you can about these Mars samples.

+

NOTES:

+
    +
  • All of these datasets can be found in +/academics/MATP-4910-F24/DAR-Mars-F24/Data
  • +
  • We have included a comprehensive samples.Rds dataset +that includes useful details about the sample locations, including +Martian latitude and longitude and the sol that individual samples were +collected.
  • +
  • Also included is rover.waypoints.Rds that provides +detailed location information (lat/lon) for the Perseverance rover +throughout its journey, up to the present. This can be updated when +necessary using the included roverStatus-f24.R script.
  • +
  • A general guide to the available Mars 2020 data is available here: +https://pds-geosciences.wustl.edu/missions/mars2020/index.htm
  • +
  • Other useful MARS 2020 sites https://science.nasa.gov/mission/mars-2020-perseverance/mars-rock-samples/ +and https://an.rsl.wustl.edu/m20/AN/an3.aspx?AspxAutoDetectCookieSupport=1
  • +
  • Note that PIXL, SHERLOC, and Lithology describe 16 sample that were +physically collected. There will eventually be 38 samples. These +datasets can be merged by sample. The LIBS data includes observations +collected at many more locations so how to combine the LIBS data with +the other datasets is an open research question.
  • +
+
+

3.1 Data Set A: Load the +Lithology Data

+

The first five features of the dataset describe twenty-four (24) +rover sample locations.

+

The remaining features provides a simple binary (1 or +0) summary of presence or absence of 35 minerals at the 24 +rover sample locations.

+

Only the first sixteen (16) samples are maintained, as the remaining +are missing the mineral descriptors.

+

The following code “cleans” the dataset to prepare for analysis. It +first creates a dataframe with metadata and measurements for samples, +and then creates a matrix containing only numeric measurements for later +analysis.

+
# Load the saved lithology data with locations added
+lithology.df<- readRDS("/academics/MATP-4910-F24/DAR-Mars-F24/Data/mineral_data_static.Rds")
+
+# Cast samples as numbers
+lithology.df$sample <- as.numeric(lithology.df$sample)
+
+# Convert rest into factors
+lithology.df[sapply(lithology.df, is.character)] <-
+  lapply(lithology.df[sapply(lithology.df, is.character)], 
+                                       as.factor)
+
+# Keep only first 16 samples because the data for the rest of the samples is not available yet
+lithology.df<-lithology.df[1:16,]
+
+# Look at summary of cleaned data frame
+# summary(lithology.df)
+
+# Create a matrix containing only the numeric measurements.  The remaining features are metadata about the sample. 
+lithology.matrix <- sapply(lithology.df[,6:40],as.numeric)-1            
+
+# Review the structure of our matrix
+# str(lithology.matrix)
+
+
+

3.2 Data Set B: Load the +PIXL Data

+

The PIXL data provides summaries of the mineral compositions measured +at selected sample sites by the PIXL instrument. Note that here we scale +pixl.mat so features have mean 0 and standard deviation so results will +be different than in Assignment 1.

+
# Load the saved PIXL data with locations added
+pixl.df <- readRDS("/academics/MATP-4910-F24/DAR-Mars-F24/Data/samples_pixl_wide.Rds")
+
+# Convert to factors
+pixl.df[sapply(pixl.df, is.character)] <- lapply(pixl.df[sapply(pixl.df, is.character)], 
+                                       as.factor)
+
+# Review our dataframe
+# summary(pixl.df)
+
+# Make the matrix of just mineral percentage measurements
+pixl.matrix <- pixl.df[,2:14] %>% scale()
+
+# Review the structure
+# str(pixl.matrix)
+
+
+

3.3 Data Set C: Load the +LIBS Data

+

The LIBS data provides summaries of the mineral compositions measured +at selected sample sites by the LIBS instrument, part of the +Perseverance SuperCam.

+
# Load the saved LIBS data with locations added
+libs.df <- readRDS("/academics/MATP-4910-F24/DAR-Mars-F24/Data/supercam_libs_moc_loc.Rds")
+
+#Drop  features that are not to be used in the analysis for this notebook
+libs.df <- libs.df %>% 
+  select(!(c(distance_mm,Tot.Em.,SiO2_stdev,TiO2_stdev,Al2O3_stdev,FeOT_stdev,
+             MgO_stdev,Na2O_stdev,CaO_stdev,K2O_stdev,Total)))
+
+# Convert the points to numeric
+libs.df$point <- as.numeric(libs.df$point)
+
+# Review what we have
+# summary(libs.df)
+
+# Make the a matrix contain only the libs measurements for each mineral
+libs.matrix <- as.matrix(libs.df[,6:13]) 
+
+# Check to see scaling
+# str(libs.matrix)
+
+
+

3.4 Dataset D: Load the +SHERLOC Data

+

The SHERLOC data you will be using for this lab is the result of +scientists’ interpretations of extensive spectral analysis of abrasion +samples provided by the SHERLOC instrument.

+

NOTE: This dataset presents minerals as rows and +sample sites as columns. You’ll probably want to rotate the dataset for +easier analysis….

+
# Read in data as provided.  
+sherloc_abrasion_raw <- readRDS("/academics/MATP-4910-F24/DAR-Mars-F24/Data/abrasions_sherloc_samples.Rds")
+
+# Clean up data types
+sherloc_abrasion_raw$Mineral<-as.factor(sherloc_abrasion_raw$Mineral)
+sherloc_abrasion_raw[sapply(sherloc_abrasion_raw, is.character)] <- lapply(sherloc_abrasion_raw[sapply(sherloc_abrasion_raw, is.character)], 
+                                       as.numeric)
+# Transform NA's to 0
+sherloc_abrasion_raw <- sherloc_abrasion_raw %>% replace(is.na(.), 0)
+
+# Reformat data so that rows are "abrasions" and columns list the presence of minerals. 
+# Do this by "pivoting" to a long format, and then back to the desired wide format.  
+
+sherloc_long <- sherloc_abrasion_raw %>%
+  pivot_longer(!Mineral, names_to = "Name", values_to = "Presence")
+
+# Make abrasion a factor 
+sherloc_long$Name <- as.factor(sherloc_long$Name)
+
+# Make it a matrix
+sherloc.matrix <- sherloc_long %>%
+  pivot_wider(names_from = Mineral, values_from = Presence)
+
+# Get sample information from PIXL and add to measurements -- assumes order is the same
+
+sherloc.df <- cbind(pixl.df[,c("sample","type","campaign","abrasion")],sherloc.matrix)
+
+# Review what we have
+# summary(sherloc.df)
+
+# Measurements are everything except first column
+sherloc.matrix<-as.matrix(sherloc.matrix[,-1])
+
+# Sherlock measurement matrix
+# Review the structure 
+# str(sherloc.matrix)
+
+
+

3.5 Data Set E: PIXL + +Sherloc

+
# Combine PIXL and SHERLOC dataframes 
+pixl_sherloc.df <- cbind(pixl.df,sherloc.df )
+
+# Review what we have
+str(pixl_sherloc.df)
+
## 'data.frame':    16 obs. of  59 variables:
+##  $ sample                     : int  1 2 3 4 5 6 7 8 9 10 ...
+##  $ Na20                       : num  5.55 4.67 1.93 1.87 4.5 1.87 1.87 4.5 4.5 1.8 ...
+##  $ Mgo                        : num  2.64 2.21 19.24 12.8 0.73 ...
+##  $ Al203                      : num  7.56 6.97 2.42 2.36 11.6 2.36 2.36 11.6 11.6 1.7 ...
+##  $ Si02                       : num  38.3 43.8 39.4 40.3 57.1 ...
+##  $ P205                       : num  1.65 2.76 0.48 0.28 0.84 0.28 0.28 0.84 0.84 0.1 ...
+##  $ S03                        : num  2.69 3.21 0.78 1.66 1 1.66 1.66 1 1 2.6 ...
+##  $ Cl                         : num  3.4 1.48 0.66 0.94 2.08 0.94 0.94 2.08 2.08 4.5 ...
+##  $ K20                        : num  0.75 1.06 0.18 0.2 1.9 0.2 0.2 1.9 1.9 0.3 ...
+##  $ Cao                        : num  7.77 7.62 2.94 2.94 4.31 2.94 2.94 4.31 4.31 1.8 ...
+##  $ Ti02                       : num  1.47 2.49 0.37 0.99 0.59 0.99 0.99 0.59 0.59 0.2 ...
+##  $ Cr203                      : num  0.03 0.01 0.26 0.29 0 0.29 0.29 0 0 0.2 ...
+##  $ Mno                        : num  0.46 0.44 0.69 0.58 0.28 0.58 0.58 0.28 0.28 0.4 ...
+##  $ FeO-T                      : num  18.7 23.2 30.1 25.7 13.2 ...
+##  $ name                       : Factor w/ 16 levels "Atsah","Bearwallow",..: 12 10 9 13 3 11 8 4 1 16 ...
+##  $ type                       : Factor w/ 3 levels "Igneous","N/A",..: 2 1 1 1 1 1 1 1 1 3 ...
+##  $ campaign                   : Factor w/ 2 levels "Crater Floor",..: 1 1 1 1 1 1 1 1 1 2 ...
+##  $ location                   : Factor w/ 16 levels "01","02","03",..: 1 2 3 4 5 6 7 8 9 10 ...
+##  $ abrasion                   : Factor w/ 9 levels "Alfalfa","Bellegrade",..: 5 2 2 4 4 7 7 1 1 8 ...
+##  $ sample                     : int  1 2 3 4 5 6 7 8 9 10 ...
+##  $ type                       : Factor w/ 3 levels "Igneous","N/A",..: 2 1 1 1 1 1 1 1 1 3 ...
+##  $ campaign                   : Factor w/ 2 levels "Crater Floor",..: 1 1 1 1 1 1 1 1 1 2 ...
+##  $ abrasion                   : Factor w/ 9 levels "Alfalfa","Bellegrade",..: 5 2 2 4 4 7 7 1 1 8 ...
+##  $ Name                       : Factor w/ 16 levels "Atsah","Bearwallow",..: 12 10 9 13 3 11 8 4 1 16 ...
+##  $ Plagioclase                : num  1 1 1 0 0 0 0 0 0 0 ...
+##  $ Sulfate                    : num  1 1 1 1 1 1 1 0 0 0 ...
+##  $ Ca-sulfate                 : num  1 1 1 0 0 0 0 0 0 0 ...
+##  $ Hydrated Ca-sulfate        : num  0 1 1 0 0 0 0 0 0 0 ...
+##  $ Mg-sulfate                 : num  0 0 0 0 0 0 0 0 0 0 ...
+##  $ Hydrated Sulfates          : num  0 0 0 0 0 1 1 0 0 0 ...
+##  $ Hydrated Mg-Fe sulfate     : num  0 0 0 0 0 0 0 0 0 0 ...
+##  $ Perchlorates               : num  1 0 0 0 0 0 0 0 0 0 ...
+##  $ Na-perchlorate             : num  0.5 0 0 0 0 0 0 0 0 0 ...
+##  $ Amorphous Silicate         : num  0.25 0.25 0.25 0.5 0.5 0.25 0.25 0 0 0 ...
+##  $ Phosphate                  : num  0.25 1 1 0 0 0 0 0 0 0 ...
+##  $ Pyroxene                   : num  1 1 1 1 1 1 1 1 1 1 ...
+##  $ Olivine                    : num  0 0 0 1 1 1 1 0.25 0.25 1 ...
+##  $ Carbonate                  : num  0 1 1 1 1 1 1 0.5 0.5 1 ...
+##  $ Fe-Mg carbonate            : num  0 0 0 0 0 0 0 0 0 1 ...
+##  $ Hydrated Carbonates        : num  0 0 0 0 0 0 0 0 0 0 ...
+##  $ Disordered Silicates       : num  0 0 0 0 0 0 0 1 1 0 ...
+##  $ Feldspar                   : num  0 0 0 0 0 0 0 1 1 0 ...
+##  $ Quartz                     : num  0 0 0 0 0 0 0 0.25 0.25 0 ...
+##  $ Apatite                    : num  0.25 0 0 0 0 0 0 0 0 0 ...
+##  $ FeTi oxides                : num  0.25 1 1 0 0 0 0 0 0 0 ...
+##  $ Halite                     : num  0.25 0 0 0 0 0 0 0 0 0.25 ...
+##  $ Iron oxide                 : num  1 1 1 0 0 0 0 0.5 0.5 0.25 ...
+##  $ Hydrated Iron oxide        : num  0.25 0 0 0 0 0 0 0 0 0 ...
+##  $ Organic matter             : num  0 0 0 1 1 1 1 1 1 0 ...
+##  $ Sulfate+Organic matter     : num  0 0 0 0 0 1 1 0 0 0 ...
+##  $ Other hydrated phases      : num  0 0 0 1 1 1 1 0.5 0.5 1 ...
+##  $ Phyllosilicates            : num  0 0 0 0 0 0 0 0.5 0.5 0.25 ...
+##  $ Chlorite                   : num  0 0 0 0 0 0 0 0.5 0.5 0 ...
+##  $ Kaolinite (hydrous Al-clay): num  0 0 0 0 0 0 0 0 0 0 ...
+##  $ Chromite                   : num  0 0 0 0 0 0 0 0 0 0 ...
+##  $ Ilmenite                   : num  0 0 0 0 0 0 0 0 0 0 ...
+##  $ Zircon/Baddeleyite         : num  0 0 0 0 0 0 0 0 0 0 ...
+##  $ Fe-Mg-clay minerals        : num  0 0 0 0 0 0 0 0 0 0 ...
+##  $ Spinels                    : num  0 0 0 0 0 0 0 0 0 0 ...
+
# Combine PIXL and SHERLOC matrices
+pixl_sherloc.matrix<-cbind(pixl.matrix,sherloc.matrix)
+
+# Review the structure of our matrix
+str(pixl_sherloc.matrix)
+
##  num [1:16, 1:48] 1.928 1.338 -0.498 -0.538 1.225 ...
+##  - attr(*, "dimnames")=List of 2
+##   ..$ : NULL
+##   ..$ : chr [1:48] "Na20" "Mgo" "Al203" "Si02" ...
+
summary(pixl_sherloc.matrix)
+
##       Na20              Mgo              Al203              Si02         
+##  Min.   :-1.1206   Min.   :-1.3765   Min.   :-0.8991   Min.   :-1.44691  
+##  1st Qu.:-0.5494   1st Qu.:-1.1500   1st Qu.:-0.7605   1st Qu.:-0.66513  
+##  Median :-0.5176   Median : 0.1404   Median :-0.3631   Median : 0.02732  
+##  Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.00000  
+##  3rd Qu.: 1.2245   3rd Qu.: 0.9322   3rd Qu.: 0.5455   3rd Qu.: 0.23751  
+##  Max.   : 1.9280   Max.   : 1.3847   Max.   : 1.7407   Max.   : 1.68204  
+##       P205              S03                Cl                K20         
+##  Min.   :-0.7945   Min.   :-0.6389   Min.   :-1.11146   Min.   :-0.8190  
+##  1st Qu.:-0.5999   1st Qu.:-0.5433   1st Qu.:-0.69646   1st Qu.:-0.5931  
+##  Median :-0.1820   Median :-0.3957   Median :-0.08165   Median :-0.5366  
+##  Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.00000   Mean   : 0.0000  
+##  3rd Qu.: 0.2720   3rd Qu.:-0.2354   3rd Qu.: 0.17964   3rd Qu.: 0.3495  
+##  Max.   : 3.0392   Max.   : 2.1333   Max.   : 2.03944   Max.   : 1.8640  
+##       Cao               Ti02             Cr203              Mno         
+##  Min.   :-1.1256   Min.   :-1.1321   Min.   :-0.5791   Min.   :-1.5772  
+##  1st Qu.:-0.5313   1st Qu.:-0.4192   1st Qu.:-0.5383   1st Qu.:-0.5678  
+##  Median :-0.2920   Median :-0.2182   Median :-0.3263   Median : 0.1051  
+##  Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000  
+##  3rd Qu.: 0.3203   3rd Qu.: 0.3119   3rd Qu.:-0.1060   3rd Qu.: 0.6099  
+##  Max.   : 2.1006   Max.   : 3.0535   Max.   : 2.5204   Max.   : 1.7314  
+##      FeO-T          Plagioclase        Sulfate         Ca-sulfate    
+##  Min.   :-1.3848   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
+##  1st Qu.:-0.7989   1st Qu.:0.0000   1st Qu.:0.1875   1st Qu.:0.0000  
+##  Median : 0.4077   Median :0.0000   Median :1.0000   Median :0.0000  
+##  Mean   : 0.0000   Mean   :0.1875   Mean   :0.6562   Mean   :0.3438  
+##  3rd Qu.: 0.7173   3rd Qu.:0.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  
+##  Max.   : 1.4512   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
+##  Hydrated Ca-sulfate   Mg-sulfate     Hydrated Sulfates Hydrated Mg-Fe sulfate
+##  Min.   :0.000       Min.   :0.0000   Min.   :0.000     Min.   :0.0000        
+##  1st Qu.:0.000       1st Qu.:0.0000   1st Qu.:0.000     1st Qu.:0.0000        
+##  Median :0.000       Median :0.0000   Median :0.000     Median :0.0000        
+##  Mean   :0.125       Mean   :0.1875   Mean   :0.125     Mean   :0.1875        
+##  3rd Qu.:0.000       3rd Qu.:0.0000   3rd Qu.:0.000     3rd Qu.:0.0000        
+##  Max.   :1.000       Max.   :1.0000   Max.   :1.000     Max.   :1.0000        
+##   Perchlorates    Na-perchlorate    Amorphous Silicate   Phosphate     
+##  Min.   :0.0000   Min.   :0.00000   Min.   :0.0000     Min.   :0.0000  
+##  1st Qu.:0.0000   1st Qu.:0.00000   1st Qu.:0.0000     1st Qu.:0.0000  
+##  Median :0.0000   Median :0.00000   Median :0.0000     Median :0.0000  
+##  Mean   :0.0625   Mean   :0.03125   Mean   :0.1406     Mean   :0.2031  
+##  3rd Qu.:0.0000   3rd Qu.:0.00000   3rd Qu.:0.2500     3rd Qu.:0.3125  
+##  Max.   :1.0000   Max.   :0.50000   Max.   :0.5000     Max.   :1.0000  
+##     Pyroxene         Olivine         Carbonate      Fe-Mg carbonate
+##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.000  
+##  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.4375   1st Qu.:0.000  
+##  Median :1.0000   Median :0.6250   Median :1.0000   Median :0.000  
+##  Mean   :0.6875   Mean   :0.5312   Mean   :0.7344   Mean   :0.125  
+##  3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:0.000  
+##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.000  
+##  Hydrated Carbonates Disordered Silicates    Feldspar         Quartz       
+##  Min.   :0           Min.   :0.000        Min.   :0.000   Min.   :0.00000  
+##  1st Qu.:0           1st Qu.:0.000        1st Qu.:0.000   1st Qu.:0.00000  
+##  Median :0           Median :0.000        Median :0.000   Median :0.00000  
+##  Mean   :0           Mean   :0.125        Mean   :0.125   Mean   :0.03125  
+##  3rd Qu.:0           3rd Qu.:0.000        3rd Qu.:0.000   3rd Qu.:0.00000  
+##  Max.   :0           Max.   :1.000        Max.   :1.000   Max.   :0.25000  
+##     Apatite        FeTi oxides         Halite          Iron oxide    
+##  Min.   :0.0000   Min.   :0.0000   Min.   :0.00000   Min.   :0.0000  
+##  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.00000   1st Qu.:0.0000  
+##  Median :0.0000   Median :0.0000   Median :0.00000   Median :0.0000  
+##  Mean   :0.1406   Mean   :0.1406   Mean   :0.04688   Mean   :0.2812  
+##  3rd Qu.:0.0000   3rd Qu.:0.0000   3rd Qu.:0.00000   3rd Qu.:0.5000  
+##  Max.   :1.0000   Max.   :1.0000   Max.   :0.25000   Max.   :1.0000  
+##  Hydrated Iron oxide Organic matter   Sulfate+Organic matter
+##  Min.   :0.00000     Min.   :0.0000   Min.   :0.0000        
+##  1st Qu.:0.00000     1st Qu.:0.0000   1st Qu.:0.0000        
+##  Median :0.00000     Median :1.0000   Median :0.0000        
+##  Mean   :0.01562     Mean   :0.5938   Mean   :0.2188        
+##  3rd Qu.:0.00000     3rd Qu.:1.0000   3rd Qu.:0.2500        
+##  Max.   :0.25000     Max.   :1.0000   Max.   :1.0000        
+##  Other hydrated phases Phyllosilicates      Chlorite     
+##  Min.   :0.0000        Min.   :0.00000   Min.   :0.0000  
+##  1st Qu.:0.0000        1st Qu.:0.00000   1st Qu.:0.0000  
+##  Median :0.2500        Median :0.00000   Median :0.0000  
+##  Mean   :0.4375        Mean   :0.09375   Mean   :0.0625  
+##  3rd Qu.:1.0000        3rd Qu.:0.06250   3rd Qu.:0.0000  
+##  Max.   :1.0000        Max.   :0.50000   Max.   :0.5000  
+##  Kaolinite (hydrous Al-clay)    Chromite        Ilmenite     Zircon/Baddeleyite
+##  Min.   :0.0000              Min.   :0.000   Min.   :0.000   Min.   :0.000     
+##  1st Qu.:0.0000              1st Qu.:0.000   1st Qu.:0.000   1st Qu.:0.000     
+##  Median :0.0000              Median :0.000   Median :0.000   Median :0.000     
+##  Mean   :0.1875              Mean   :0.125   Mean   :0.125   Mean   :0.125     
+##  3rd Qu.:0.0000              3rd Qu.:0.000   3rd Qu.:0.000   3rd Qu.:0.000     
+##  Max.   :1.0000              Max.   :1.000   Max.   :1.000   Max.   :1.000     
+##  Fe-Mg-clay minerals    Spinels      
+##  Min.   :0.0000      Min.   :0.0000  
+##  1st Qu.:0.0000      1st Qu.:0.0000  
+##  Median :0.0000      Median :0.0000  
+##  Mean   :0.1875      Mean   :0.0625  
+##  3rd Qu.:0.0000      3rd Qu.:0.0000  
+##  Max.   :1.0000      Max.   :0.5000
+
pixl_sherloc.scaled<-cbind(scale(pixl.matrix),sherloc.matrix)
+pixl_sherloc.scaled <- pixl_sherloc.scaled[, colSums(is.na(pixl_sherloc.scaled)) == 0]
+num_duplicates <- sum(duplicated(pixl_sherloc.scaled))
+print(paste("Number of duplicate rows:", num_duplicates))
+
## [1] "Number of duplicate rows: 5"
+
+
+

3.6 Data Set F: PIXL + +Lithography

+

Create data and matrix from prior datasets

+
# Combine our PIXL and Lithology dataframes
+pixl_lithology.df <- cbind(pixl.df,lithology.df )
+
+# Review what we have
+# summary(pixl_lithology.df)
+
+# Combine PIXL and Lithology matrices
+pixl_lithology.matrix<-cbind(pixl.matrix,lithology.matrix)
+
+
+# Review the structure
+# str(pixl_lithology.matrix)
+
+
+

3.7 Data Set G: Sherloc + +Lithology

+

Create Data and matrix from prior datasets by taking on appropriate +combinations.

+
# Combine the Lithology and SHERLOC dataframes
+sherloc_lithology.df <- cbind(sherloc.df,lithology.df )
+
+# Review what we have
+# summary(sherloc_lithology.df)
+
+# Combine the Lithology and SHERLOC matrices
+sherloc_lithology.matrix<-cbind(sherloc.matrix,lithology.matrix)
+
+# Review the resulting matrix
+# str(sherloc_lithology.matrix)
+
+
+

3.8 Data Set H: Sherloc + +Lithology + PIXL

+

Create data frame and matrix from prior datasets by making on +appropriate combinations.

+
# Combine the Lithology and SHERLOC dataframes
+sherloc_lithology_pixl.df <- cbind(sherloc.df,lithology.df, pixl.df )
+
+# Review what we have
+# summary(sherloc_lithology_pixl.df)
+
+# Combine the Lithology, SHERLOC and PIXLmatrices
+sherloc_lithology_pixl.matrix<-cbind(sherloc.matrix,lithology.matrix,pixl.matrix)
+
+# Review the resulting matrix
+# str(sherloc_lithology_pixl.matrix)
+
+
+
+

4 Analysis of Data (Part +3)

+

Each team has been assigned one of six datasets:

+
    +
  1. Dataset B: PIXL: The PIXL team’s goal is to understand and +explain how scaling changes results from Assignment 1. The matrix +version was scaled above but not in Assignment 1.

  2. +
  3. Dataset C: LIBS (with appropriate scaling as necessary. Not +scaled yet.)

  4. +
  5. Dataset D: Sherloc (with appropriate scaling as necessary. Not +scaled yet.)

  6. +
  7. Dataset E: PIXL + Sherloc (with appropriate scaling as necessary. +Not scaled yet.)

  8. +
  9. Dataset F: PIXL + Lithography (with appropriate scaling as +necessary. Not scaled yet.)

  10. +
  11. Dataset G: Sherloc + Lithograpy (with appropriate scaling as +necessary. Not scaled yet.)

  12. +
  13. Dataset H: PIXL + Sherloc + Lithograpy (with appropriate scaling +as necessary. Not scaled yet.)

  14. +
+

For the data set assigned to your team, perform the following +steps. Feel free to use the methods/code from Assignment 1 as +desired. Communicate with your teammates. Make sure that you are doing +different variations of below analysis so that no team member does the +exact same analysis. If you want to use the same clustering for your +team (which is okay but then vary rest), make sure you use the same +random seeds.

+
    +
  1. Describe the data set contained in the data frame and +matrix: How many rows does it have and how many features? Which +features are measurements and which features are metadata about the +samples? (3 pts)
  2. +
+

Metadata: sample name, campaign, abrasion, location Type (igneous, +sedimentary, N/A) PIXL: 13 continuous quantitative features +(concentrations) Sherloc: 35 discrete quantitative features +(concentration? likelihood?) Values 0, 0.25, 0.5, 1

+
    +
  1. Scale this data appropriately (you can choose the scaling method +or decide to not scale data): Explain why you chose a scaling +method or to not scale. (3 pts)
  2. +
+
# TODO: maybe sherloc should not be scaled
+pixl_sherloc.scaled<-cbind(scale(pixl.matrix),sherloc.matrix)
+# pixl_sherloc.scaled <- scale(pixl_sherloc.matrix)
+
+pixl_sherloc.scaled <- pixl_sherloc.scaled[, colSums(is.na(pixl_sherloc.scaled)) == 0]
+# pixl_sherloc.scaled <- unique(pixl_sherloc.scaled)
+
+# summary(pixl_sherloc.scaled)
+# str(pixl_sherloc.scaled)
+

I chose to scale PIXL so that different minerals would contribute the +same to clusters despite different absolute quantities. Conversely, +SHERLOC remains unscaled since it is already both heavily processed and +in the range of 0 to 1.

+
    +
  1. Cluster the data using k-means or your favorite clustering +method (like hierarchical clustering): Describe how you picked the +best number of clusters. Indicate the number of points in each clusters. +Coordinate with your team so you try different approaches. If you want +to share results with your team mates, make sure to use the same random +seeds. (6 pts)
  2. +
+

I chose to compare two clustering algorithms, K-means and DBSCAN. I +rather arbitrarily chose 4 clusters for K-means (as a point somewhere +along the elbow), and chose epsilon for DBSCAN to create a number of +clusters equal to the clusters for K-means.

+
# A user-defined function to examine clusters and plot the results
+wssplot <- function(data, nc=15, seed=10){
+  wss <- data.frame(cluster=1:nc, quality=c(0))
+  for (i in 1:nc){
+    set.seed(seed)
+    wss[i,2] <- kmeans(data, centers=i)$tot.withinss}
+  ggplot(data=wss,aes(x=cluster,y=quality)) + 
+    geom_line() + 
+    ggtitle("Quality of k-means by Cluster")
+}
+
+# Apply `wssplot()` to our data
+wssplot(pixl_sherloc.scaled, nc=10, seed=2) 
+

+
dbscan_plot <- function(data, eps_values, minPts=5) {
+  results <- data.frame(eps=eps_values, clusters=integer(length(eps_values)), noise=integer(length(eps_values)))
+
+  for (i in seq_along(eps_values)) {
+    db <- dbscan(data, eps=eps_values[i], minPts=minPts)
+    results$clusters[i] <- length(unique(db$cluster[db$cluster != 0]))  # Excluding noise
+    results$noise[i] <- sum(db$cluster == 0)
+  }
+
+  ggplot(results, aes(x=eps)) +
+    geom_line(aes(y=clusters, color="Number of Clusters")) +
+    geom_line(aes(y=noise, color="Number of Noise Points")) +
+    labs(title="DBSCAN Clustering by Eps Parameter", x="Eps", y="Count") +
+    scale_color_manual("", values = c("Number of Clusters"="blue", "Number of Noise Points"="red"))
+}
+
+# Apply the dbscan_plot function to our data
+eps_values <- seq(2, 6, by=0.1)
+dbscan_plot(pixl_sherloc.scaled, eps_values, minPts=1)
+

+
set.seed(2)
+k <- 4
+km <- kmeans(pixl_sherloc.scaled,k)
+pheatmap(km$centers,scale="none", main="K-means Heatmap")
+

+
eps <- 4.5
+minPts <- 1
+db <- dbscan(pixl_sherloc.scaled, eps=eps, minPts=minPts)
+
+# Extracting the core points to calculate cluster centers
+core_points <- pixl_sherloc.scaled[db$cluster > 0,]
+core_clusters <- db$cluster[db$cluster > 0]
+centers <- aggregate(core_points, by=list(cluster=core_clusters), FUN=mean)
+centers <- centers[,-1]  # Remove the cluster number column
+
+# Plot the centers using pheatmap
+pheatmap(centers, scale="none", main="DBSCAN Heatmap")
+

+
    +
  1. _Perform a creative analysis that provides insights +into what one or more of the clusters are and what they tell you about +the MARS data: Alternatively do another creative analysis of your +datasets that leads to one of more findings. Make sure to explain what +your analysis and discuss your the results.
  2. +
+
plot_by_cluster <- function(cluster_assignments, types, name="") {
+  # Create a data frame with cluster assignments and rock types
+  type_counts <- data.frame(
+    cluster = cluster_assignments,
+    type = types
+  )
+  
+  # Summarize rock types by cluster
+  type_summary <- type_counts %>%
+    count(cluster, type) %>%
+    pivot_wider(names_from = type, values_from = n, values_fill = 0)
+  
+  # Generate the plot
+  ggplot(type_summary %>% pivot_longer(-cluster, names_to = "type", values_to = "count")) +
+    geom_col(aes(x = factor(cluster), y = count, fill = type)) +
+    labs(x = "Cluster", y = "Count", title = name) +
+    theme_minimal() +
+    theme(legend.title = element_blank())
+}
+
+plot_by_cluster(km$cluster, pixl.df$type, name = "Rock type by K-means cluster")
+

+
plot_by_cluster(db$cluster, pixl.df$type, name = "Rock type by DBSCAN cluster")
+

+
plot_by_cluster(km$cluster, pixl.df$campaign, name = "Campaign by K-means cluster")
+

+
plot_by_cluster(db$cluster, pixl.df$campaign, name = "Campaign by DBSCAN cluster")
+

+
plot_by_cluster(km$cluster, pixl.df$abrasion, name = "Abrasion by K-means cluster")
+

+
plot_by_cluster(db$cluster, pixl.df$abrasion, name = "Abrasion by DBSCAN cluster")
+

+
num_duplicates <- sum(duplicated(pixl_sherloc.scaled))
+print(paste("Number of duplicate rows:", num_duplicates))
+
## [1] "Number of duplicate rows: 5"
+
pca_result <- prcomp(pixl_sherloc.scaled, scale. = FALSE)
+pca_data <- as.data.frame(pca_result$x[, 1:3])  # Extract the first 3 principal components
+
+# Add cluster assignments
+pca_data$km_cluster <- as.factor(km$cluster)
+pca_data$db_cluster <- as.factor(db$cluster)
+
+plot_pca_3d <- function(pca_data, cluster_col, title) {
+  p <- plot_ly()
+  
+  # Add rays from the origin (0,0,0) to each point
+  for (i in 1:nrow(pca_data)) {
+    p <- p %>% 
+      add_trace(x = c(0, pca_data$PC1[i]), 
+                y = c(0, pca_data$PC2[i]), 
+                z = c(0, pca_data$PC3[i]), 
+                type = "scatter3d", mode = "lines",
+                line = list(color = 'gray', width = 1),
+                showlegend = FALSE)
+  }
+  
+  # Add the points
+  p <- p %>%
+    add_trace(data = pca_data, 
+              x = ~PC1, y = ~PC2, z = ~PC3, 
+              color = ~get(cluster_col), 
+              colors = "Set1", 
+              type = "scatter3d", mode = "markers") %>%
+    layout(title = title,
+           scene = list(xaxis = list(title = 'PC1'),
+                        yaxis = list(title = 'PC2'),
+                        zaxis = list(title = 'PC3')))
+  
+  return(p)
+}
+
+# Step 3: Create 3D PCA plots for K-means and DBSCAN clusters
+plot_pca_3d(pca_data, "km_cluster", "3D PCA - K-means Clusters")
+
+ +
# plot_pca_3d(pca_data, "db_cluster", "3D PCA - DBSCAN Clusters")
+
plot_pca_3d(pca_data, "db_cluster", "3D PCA - DBSCAN Clusters")
+
+ +
# Compute the correlation matrix
+corr <- cor(scale(pixl.matrix))
+corr2 <- cor(sherloc.matrix)
+
## Warning in cor(sherloc.matrix): the standard deviation is zero
+
corr3 <- cor(scale(pixl.matrix), sherloc.matrix)
+
## Warning in cor(scale(pixl.matrix), sherloc.matrix): the standard deviation is
+## zero
+
# Plot the correlation heatmap
+corrplot(corr, method = "color", type = "upper", 
+         tl.col = "black", tl.srt = 45, 
+         number.cex = 0.7, 
+         col = colorRampPalette(c("blue", "white", "yellow"))(200))
+

+
corrplot(corr2, method = "color", type = "upper", 
+         tl.col = "black", tl.srt = 45, 
+         number.cex = 0.7, 
+         col = colorRampPalette(c("blue", "white", "yellow"))(200))
+

+
corrplot(corr3, method = "color", type = "upper", 
+         tl.col = "black", tl.srt = 45, 
+         number.cex = 0.7, 
+         col = colorRampPalette(c("blue", "white", "yellow"))(200))
+

+
# Count unique pairs with 1 or -1 correlation for corr (excluding the diagonal and ignoring NAs)
+n_unique_corr_1_minus1 <- sum(((corr[upper.tri(corr, diag = FALSE)] == 1) | 
+                               (corr[upper.tri(corr, diag = FALSE)] == -1)), na.rm = TRUE)
+
+# Count unique pairs with 1 or -1 correlation for corr2 (excluding the diagonal and ignoring NAs)
+n_unique_corr2_1_minus1 <- sum(((corr2[upper.tri(corr2, diag = FALSE)] == 1) | 
+                                (corr2[upper.tri(corr2, diag = FALSE)] == -1)), na.rm = TRUE)
+
+# Count unique pairs with 1 or -1 correlation for corr3 (excluding the diagonal and ignoring NAs)
+n_unique_corr3_1_minus1 <- sum(((corr3[upper.tri(corr3, diag = FALSE)] == 1) | 
+                                (corr3[upper.tri(corr3, diag = FALSE)] == -1)), na.rm = TRUE)
+
+# Print results
+n_unique_corr_1_minus1
+
## [1] 0
+
n_unique_corr2_1_minus1
+
## [1] 15
+
n_unique_corr3_1_minus1
+
## [1] 0
+
# Compute the correlation matrix
+corr <- cor(pixl_sherloc.scaled)
+
## Warning in cor(pixl_sherloc.scaled): the standard deviation is zero
+
# Convert the upper triangle of the correlation matrix (excluding the diagonal) to a long format
+corr_upper <- as.data.frame(as.table(corr))
+corr_upper <- corr_upper[upper.tri(corr, diag = FALSE), ]
+
+# Sort by absolute correlation values (optional)
+corr_upper <- corr_upper[order(-abs(corr_upper$Freq)), ]
+
+# Print the list of correlations
+print(corr_upper)
+
##                             Var1                        Var2          Freq
+## 1029                Perchlorates              Na-perchlorate  1.0000000000
+## 1470        Disordered Silicates                    Feldspar  1.0000000000
+## 1518        Disordered Silicates                      Quartz  1.0000000000
+## 1519                    Feldspar                      Quartz  1.0000000000
+## 1749                Perchlorates         Hydrated Iron oxide  1.0000000000
+## 1750              Na-perchlorate         Hydrated Iron oxide  1.0000000000
+## 1998        Disordered Silicates                    Chlorite  1.0000000000
+## 1999                    Feldspar                    Chlorite  1.0000000000
+## 2000                      Quartz                    Chlorite  1.0000000000
+## 2156                    Chromite                    Ilmenite  1.0000000000
+## 2204                    Chromite          Zircon/Baddeleyite  1.0000000000
+## 2205                    Ilmenite          Zircon/Baddeleyite  1.0000000000
+## 2300                    Chromite                     Spinels  1.0000000000
+## 2301                    Ilmenite                     Spinels  1.0000000000
+## 2302          Zircon/Baddeleyite                     Spinels  1.0000000000
+## 930                   Mg-sulfate      Hydrated Mg-Fe sulfate  1.0000000000
+## 2034                  Mg-sulfate Kaolinite (hydrous Al-clay)  1.0000000000
+## 2036      Hydrated Mg-Fe sulfate Kaolinite (hydrous Al-clay)  1.0000000000
+## 2226                  Mg-sulfate         Fe-Mg-clay minerals  1.0000000000
+## 2228      Hydrated Mg-Fe sulfate         Fe-Mg-clay minerals  1.0000000000
+## 2251 Kaolinite (hydrous Al-clay)         Fe-Mg-clay minerals  1.0000000000
+## 822                          S03                  Mg-sulfate  0.9908121837
+## 918                          S03      Hydrated Mg-Fe sulfate  0.9908121837
+## 2022                         S03 Kaolinite (hydrous Al-clay)  0.9908121837
+## 2214                         S03         Fe-Mg-clay minerals  0.9908121837
+## 2075                       Cr203                    Chromite  0.9838544333
+## 2123                       Cr203                    Ilmenite  0.9838544333
+## 2171                       Cr203          Zircon/Baddeleyite  0.9838544333
+## 2267                       Cr203                     Spinels  0.9838544333
+## 1601         Hydrated Ca-sulfate                 FeTi oxides  0.9832408372
+## 2097                     Apatite                    Chromite  0.9832408372
+## 2145                     Apatite                    Ilmenite  0.9832408372
+## 2193                     Apatite          Zircon/Baddeleyite  0.9832408372
+## 2289                     Apatite                     Spinels  0.9832408372
+## 1547                       Cr203                     Apatite  0.9590554469
+## 339                        Al203                         K20  0.9286555796
+## 98                           Mgo                       Al203 -0.9092394151
+## 1694                 Plagioclase                  Iron oxide  0.8991420601
+## 49                          Na20                         Mgo -0.8979764687
+## 1598                 Plagioclase                 FeTi oxides  0.8861348088
+## 1950        Disordered Silicates             Phyllosilicates  0.8824975033
+## 1951                    Feldspar             Phyllosilicates  0.8824975033
+## 1952                      Quartz             Phyllosilicates  0.8824975033
+## 2009             Phyllosilicates                    Chlorite  0.8824975033
+## 1608                   Phosphate                 FeTi oxides  0.8808938536
+## 1121         Hydrated Ca-sulfate                   Phosphate  0.8734874619
+## 1639                          Cl                      Halite  0.8720402201
+## 146                          Mgo                        Si02 -0.8612542468
+## 579                        Al203                       FeO-T -0.8583700413
+## 97                          Na20                       Al203  0.8580456367
+## 340                         Si02                         K20  0.8548365742
+## 1216                  Ca-sulfate                     Olivine -0.8391051501
+## 337                         Na20                         K20  0.8383362757
+## 437                         P205                        Ti02  0.8360715088
+## 338                          Mgo                         K20 -0.8303923790
+## 147                        Al203                        Si02  0.8277457715
+## 389                         P205                         Cao  0.8033969872
+## 1714                 FeTi oxides                  Iron oxide  0.7967610775
+## 1303                          Cl             Fe-Mg carbonate  0.7961163858
+## 782                  Plagioclase         Hydrated Ca-sulfate  0.7867957925
+## 1660             Fe-Mg carbonate                      Halite  0.7867957925
+## 1935                     Sulfate             Phyllosilicates -0.7864561806
+## 193                         Na20                        P205  0.7772797467
+## 1843           Hydrated Sulfates      Sulfate+Organic matter  0.7689578149
+## 1158                         S03                    Pyroxene -0.7687784543
+## 1118                 Plagioclase                   Phosphate  0.7618904238
+## 828                          Mno                  Mg-sulfate -0.7546939718
+## 924                          Mno      Hydrated Mg-Fe sulfate -0.7546939718
+## 2028                         Mno Kaolinite (hydrous Al-clay) -0.7546939718
+## 2220                         Mno         Fe-Mg-clay minerals -0.7546939718
+## 534                          S03                         Mno -0.7538043162
+## 588                          Mno                       FeO-T  0.7529946385
+## 385                         Na20                         Cao  0.7395463442
+## 1274                     Olivine                   Carbonate  0.7365832281
+## 1400                         K20        Disordered Silicates  0.7276331294
+## 1448                         K20                    Feldspar  0.7276331294
+## 1496                         K20                      Quartz  0.7276331294
+## 1976                         K20                    Chlorite  0.7276331294
+## 1898                     Olivine       Other hydrated phases  0.7186173264
+## 578                          Mgo                       FeO-T  0.7133217450
+## 1170                  Mg-sulfate                    Pyroxene -0.7125253032
+## 1172      Hydrated Mg-Fe sulfate                    Pyroxene -0.7125253032
+## 2041                    Pyroxene Kaolinite (hydrous Al-clay) -0.7125253032
+## 2233                    Pyroxene         Fe-Mg-clay minerals -0.7125253032
+## 1888                  Ca-sulfate       Other hydrated phases -0.7080927544
+## 1697         Hydrated Ca-sulfate                  Iron oxide  0.7074411897
+## 145                         Na20                        Si02  0.7040282550
+## 194                          Mgo                        P205 -0.7037536663
+## 629                         P205                 Plagioclase  0.6998593491
+## 1685                        P205                  Iron oxide  0.6903052460
+## 734                  Plagioclase                  Ca-sulfate  0.6880009153
+## 584                          K20                       FeO-T -0.6853519425
+## 441                          Cao                        Ti02  0.6835069814
+## 1395                       Al203        Disordered Silicates  0.6795164068
+## 1443                       Al203                    Feldspar  0.6795164068
+## 1491                       Al203                      Quartz  0.6795164068
+## 1971                       Al203                    Chlorite  0.6795164068
+## 1261                       FeO-T                   Carbonate  0.6734543926
+## 386                          Mgo                         Cao -0.6672783607
+## 679                           Cl                     Sulfate -0.6626262084
+## 1396                        Si02        Disordered Silicates  0.6566006973
+## 1444                        Si02                    Feldspar  0.6566006973
+## 1492                        Si02                      Quartz  0.6566006973
+## 1972                        Si02                    Chlorite  0.6566006973
+## 1800                   Phosphate              Organic matter -0.6524114100
+## 1266                  Mg-sulfate                   Carbonate -0.6487021502
+## 1268      Hydrated Mg-Fe sulfate                   Carbonate -0.6487021502
+## 2043                   Carbonate Kaolinite (hydrous Al-clay) -0.6487021502
+## 2235                   Carbonate         Fe-Mg-clay minerals -0.6487021502
+## 1260                         Mno                   Carbonate  0.6386191184
+## 1897                    Pyroxene       Other hydrated phases  0.6363636364
+## 1704                   Phosphate                  Iron oxide  0.6305843036
+## 1254                         S03                   Carbonate -0.6298887781
+## 577                         Na20                       FeO-T -0.6254473487
+## 1681                        Na20                  Iron oxide  0.6221447500
+## 633                          Cao                 Plagioclase  0.6184294415
+## 1928                         K20             Phyllosilicates  0.6181853507
+## 1589                        P205                 FeTi oxides  0.6159455008
+## 1790                 Plagioclase              Organic matter -0.6112095349
+## 1811                      Halite              Organic matter -0.6112095349
+## 1071                     Sulfate          Amorphous Silicate  0.6105878546
+## 1600                  Ca-sulfate                 FeTi oxides  0.6096615595
+## 1164                         Mno                    Pyroxene  0.6062230587
+## 1689                         Cao                  Iron oxide  0.6007992083
+## 1205                        P205                     Olivine -0.5945962540
+## 1783                          Cl              Organic matter -0.5888489519
+## 1812                  Iron oxide              Organic matter -0.5830997732
+## 735                      Sulfate                  Ca-sulfate  0.5735627887
+## 725                         P205                  Ca-sulfate  0.5670889435
+## 634                         Ti02                 Plagioclase  0.5658180888
+## 1300                        Si02             Fe-Mg carbonate -0.5648173283
+## 1706                     Olivine                  Iron oxide -0.5622051706
+## 481                         Na20                       Cr203 -0.5615999086
+## 2089                    Pyroxene                    Chromite -0.5606119106
+## 2137                    Pyroxene                    Ilmenite -0.5606119106
+## 2185                    Pyroxene          Zircon/Baddeleyite -0.5606119106
+## 2281                    Pyroxene                     Spinels -0.5606119106
+## 969                          Cao                Perchlorates  0.5601675975
+## 1017                         Cao              Na-perchlorate  0.5601675975
+## 1737                         Cao         Hydrated Iron oxide  0.5601675975
+## 587                        Cr203                       FeO-T  0.5581221270
+## 1896                   Phosphate       Other hydrated phases -0.5560265981
+## 1311                     Sulfate             Fe-Mg carbonate -0.5516772844
+## 1407                     Sulfate        Disordered Silicates -0.5516772844
+## 1455                     Sulfate                    Feldspar -0.5516772844
+## 1503                     Sulfate                      Quartz -0.5516772844
+## 1983                     Sulfate                    Chlorite -0.5516772844
+## 1789                       FeO-T              Organic matter -0.5504348425
+## 773                         P205         Hydrated Ca-sulfate  0.5450203744
+## 1810                 FeTi oxides              Organic matter -0.5416140443
+## 784                   Ca-sulfate         Hydrated Ca-sulfate  0.5413162253
+## 1405                       FeO-T        Disordered Silicates -0.5405640193
+## 1453                       FeO-T                    Feldspar -0.5405640193
+## 1501                       FeO-T                      Quartz -0.5405640193
+## 1981                       FeO-T                    Chlorite -0.5405640193
+## 1298                         Mgo             Fe-Mg carbonate  0.5405260852
+## 1175          Amorphous Silicate                    Pyroxene  0.5384300729
+## 1264                  Ca-sulfate                   Carbonate -0.5377173347
+## 974                  Plagioclase                Perchlorates  0.5374838499
+## 1022                 Plagioclase              Na-perchlorate  0.5374838499
+## 1653                Perchlorates                      Halite  0.5374838499
+## 1654              Na-perchlorate                      Halite  0.5374838499
+## 1742                 Plagioclase         Hydrated Iron oxide  0.5374838499
+## 1763                      Halite         Hydrated Iron oxide  0.5374838499
+## 1394                         Mgo        Disordered Silicates -0.5373371408
+## 1442                         Mgo                    Feldspar -0.5373371408
+## 1490                         Mgo                      Quartz -0.5373371408
+## 1970                         Mgo                    Chlorite -0.5373371408
+## 1214                 Plagioclase                     Olivine -0.5373186101
+## 1218                  Mg-sulfate                     Olivine -0.5373186101
+## 1220      Hydrated Mg-Fe sulfate                     Olivine -0.5373186101
+## 2042                     Olivine Kaolinite (hydrous Al-clay) -0.5373186101
+## 2234                     Olivine         Fe-Mg-clay minerals -0.5373186101
+## 195                        Al203                        P205  0.5372825256
+## 1068                         Mno          Amorphous Silicate  0.5338525965
+## 1163                       Cr203                    Pyroxene -0.5304652306
+## 1561                    Pyroxene                     Apatite -0.5293500837
+## 1269                Perchlorates                   Carbonate -0.5286240538
+## 1270              Na-perchlorate                   Carbonate -0.5286240538
+## 1755                   Carbonate         Hydrated Iron oxide -0.5286240538
+## 580                         Si02                       FeO-T -0.5274034294
+## 1696                  Ca-sulfate                  Iron oxide  0.5161491838
+## 961                         Na20                Perchlorates  0.5141449883
+## 1009                        Na20              Na-perchlorate  0.5141449883
+## 1729                        Na20         Hydrated Iron oxide  0.5141449883
+## 1117                       FeO-T                   Phosphate  0.5133305422
+## 832                   Ca-sulfate                  Mg-sulfate  0.5132705241
+## 928                   Ca-sulfate      Hydrated Mg-Fe sulfate  0.5132705241
+## 2032                  Ca-sulfate Kaolinite (hydrous Al-clay)  0.5132705241
+## 2224                  Ca-sulfate         Fe-Mg-clay minerals  0.5132705241
+## 1899                   Carbonate       Other hydrated phases  0.5110137668
+## 1153                        Na20                    Pyroxene  0.5097133510
+## 1206                         S03                     Olivine -0.5083170619
+## 726                          S03                  Ca-sulfate  0.5054131472
+## 434                          Mgo                        Ti02 -0.4993259327
+## 1878                         S03       Other hydrated phases -0.4977472167
+## 1594                        Ti02                 FeTi oxides  0.4942483036
+## 1705                    Pyroxene                  Iron oxide  0.4937904603
+## 1160                         K20                    Pyroxene  0.4936054315
+## 387                        Al203                         Cao  0.4935747133
+## 682                         Ti02                     Sulfate  0.4924250563
+## 482                          Mgo                       Cr203  0.4856546606
+## 483                        Al203                       Cr203 -0.4849935469
+## 1701                Perchlorates                  Iron oxide  0.4832743361
+## 1702              Na-perchlorate                  Iron oxide  0.4832743361
+## 1764                  Iron oxide         Hydrated Iron oxide  0.4832743361
+## 1636                        Si02                      Halite -0.4825361802
+## 1793         Hydrated Ca-sulfate              Organic matter -0.4808970904
+## 1804             Fe-Mg carbonate              Organic matter -0.4808970904
+## 1923                       Al203             Phyllosilicates  0.4790173640
+## 1393                        Na20        Disordered Silicates  0.4779960081
+## 1441                        Na20                    Feldspar  0.4779960081
+## 1489                        Na20                      Quartz  0.4779960081
+## 1969                        Na20                    Chlorite  0.4779960081
+## 1610                     Olivine                 FeTi oxides -0.4761367238
+## 1780                        Si02              Organic matter  0.4729399100
+## 341                         P205                         K20  0.4681250524
+## 1891           Hydrated Sulfates       Other hydrated phases  0.4586824723
+## 1900             Fe-Mg carbonate       Other hydrated phases  0.4586824723
+## 625                         Na20                 Plagioclase  0.4579272235
+## 823                           Cl                  Mg-sulfate -0.4573881934
+## 919                           Cl      Hydrated Mg-Fe sulfate -0.4573881934
+## 2023                          Cl Kaolinite (hydrous Al-clay) -0.4573881934
+## 2215                          Cl         Fe-Mg-clay minerals -0.4573881934
+## 1211                       Cr203                     Olivine  0.4550494090
+## 1886                 Plagioclase       Other hydrated phases -0.4534251929
+## 1890                  Mg-sulfate       Other hydrated phases -0.4534251929
+## 1892      Hydrated Mg-Fe sulfate       Other hydrated phases -0.4534251929
+## 2056       Other hydrated phases Kaolinite (hydrous Al-clay) -0.4534251929
+## 2248       Other hydrated phases         Fe-Mg-clay minerals -0.4534251929
+## 1213                       FeO-T                     Olivine  0.4505670967
+## 730                         Ti02                  Ca-sulfate  0.4488998246
+## 1120                  Ca-sulfate                   Phosphate  0.4481096450
+## 433                         Na20                        Ti02  0.4480112208
+## 1927                          Cl             Phyllosilicates  0.4449521238
+## 488                          K20                       Cr203 -0.4422329710
+## 1306                        Ti02             Fe-Mg carbonate -0.4419131639
+## 1109                        P205                   Phosphate  0.4413796040
+## 1156                        Si02                    Pyroxene  0.4396441847
+## 2065                        Na20                    Chromite -0.4374546230
+## 2113                        Na20                    Ilmenite -0.4374546230
+## 2161                        Na20          Zircon/Baddeleyite -0.4374546230
+## 2257                        Na20                     Spinels -0.4374546230
+## 531                        Al203                         Mno -0.4368663728
+## 392                          K20                         Cao  0.4365276084
+## 1251                       Al203                   Carbonate -0.4364108192
+## 778                         Ti02         Hydrated Ca-sulfate  0.4356701929
+## 876                          Mno           Hydrated Sulfates  0.4350811826
+## 1201                        Na20                     Olivine -0.4331163554
+## 1114                        Ti02                   Phosphate  0.4326705782
+## 2077                       FeO-T                    Chromite  0.4314880541
+## 2125                       FeO-T                    Ilmenite  0.4314880541
+## 2173                       FeO-T          Zircon/Baddeleyite  0.4314880541
+## 2269                       FeO-T                     Spinels  0.4314880541
+## 1943          Amorphous Silicate             Phyllosilicates -0.4303096215
+## 1116                         Mno                   Phosphate  0.4261542917
+## 1062                         S03          Amorphous Silicate -0.4253089791
+## 1596                         Mno                 FeTi oxides  0.4242674764
+## 1593                         Cao                 FeTi oxides  0.4228381804
+## 1217         Hydrated Ca-sulfate                     Olivine -0.4227600216
+## 1203                       Al203                     Olivine -0.4215016055
+## 829                        FeO-T                  Mg-sulfate -0.4183581733
+## 925                        FeO-T      Hydrated Mg-Fe sulfate -0.4183581733
+## 2029                       FeO-T Kaolinite (hydrous Al-clay) -0.4183581733
+## 2221                       FeO-T         Fe-Mg-clay minerals -0.4183581733
+## 1933                       FeO-T             Phyllosilicates -0.4182346397
+## 1794                  Mg-sulfate              Organic matter  0.4181959976
+## 1796      Hydrated Mg-Fe sulfate              Organic matter  0.4181959976
+## 2054              Organic matter Kaolinite (hydrous Al-clay)  0.4181959976
+## 2246              Organic matter         Fe-Mg-clay minerals  0.4181959976
+## 1860                  Iron oxide      Sulfate+Organic matter -0.4172185430
+## 485                         P205                       Cr203 -0.4155035971
+## 1060                        Si02          Amorphous Silicate  0.4148913120
+## 636                          Mno                 Plagioclase  0.4138644362
+## 1209                         Cao                     Olivine -0.4097004039
+## 1690                        Ti02                  Iron oxide  0.4094895904
+## 1549                       FeO-T                     Apatite  0.4094869965
+## 294                          S03                          Cl -0.4094617942
+## 1202                         Mgo                     Olivine  0.4064148031
+## 196                         Si02                        P205  0.4054654578
+## 1936                  Ca-sulfate             Phyllosilicates -0.4042163378
+## 780                          Mno         Hydrated Ca-sulfate  0.4022448669
+## 1905                     Apatite       Other hydrated phases -0.4017958466
+## 1906                 FeTi oxides       Other hydrated phases -0.4017958466
+## 388                         Si02                         Cao  0.3972382480
+## 1788                         Mno              Organic matter -0.3970577399
+## 1212                         Mno                     Olivine  0.3958377687
+## 1895          Amorphous Silicate       Other hydrated phases  0.3948487202
+## 1250                         Mgo                   Carbonate  0.3912903114
+## 1778                         Mgo              Organic matter -0.3859992947
+## 965                         P205                Perchlorates  0.3838496996
+## 1013                        P205              Na-perchlorate  0.3838496996
+## 1733                        P205         Hydrated Iron oxide  0.3838496996
+## 1074                  Mg-sulfate          Amorphous Silicate -0.3836450510
+## 1076      Hydrated Mg-Fe sulfate          Amorphous Silicate -0.3836450510
+## 2039          Amorphous Silicate Kaolinite (hydrous Al-clay) -0.3836450510
+## 2231          Amorphous Silicate         Fe-Mg-clay minerals -0.3836450510
+## 1305                         Cao             Fe-Mg carbonate -0.3791188342
+## 1249                        Na20                   Carbonate -0.3758287273
+## 342                          S03                         K20 -0.3736302522
+## 1219           Hydrated Sulfates                     Olivine  0.3730235485
+## 1322                     Olivine             Fe-Mg carbonate  0.3730235485
+## 2090                     Olivine                    Chromite  0.3730235485
+## 2138                     Olivine                    Ilmenite  0.3730235485
+## 2186                     Olivine          Zircon/Baddeleyite  0.3730235485
+## 2282                     Olivine                     Spinels  0.3730235485
+## 244                         Si02                         S03 -0.3698069173
+## 976                   Ca-sulfate                Perchlorates  0.3697893807
+## 1024                  Ca-sulfate              Na-perchlorate  0.3697893807
+## 1744                  Ca-sulfate         Hydrated Iron oxide  0.3697893807
+## 1877                        P205       Other hydrated phases -0.3690552462
+## 1113                         Cao                   Phosphate  0.3677757358
+## 686                  Plagioclase                     Sulfate  0.3672793098
+## 831                      Sulfate                  Mg-sulfate  0.3672793098
+## 927                      Sulfate      Hydrated Mg-Fe sulfate  0.3672793098
+## 2031                     Sulfate Kaolinite (hydrous Al-clay)  0.3672793098
+## 2223                     Sulfate         Fe-Mg-clay minerals  0.3672793098
+## 1259                       Cr203                   Carbonate  0.3658568899
+## 582                          S03                       FeO-T -0.3658013015
+## 1779                       Al203              Organic matter  0.3657855912
+## 1930                        Ti02             Phyllosilicates -0.3655279213
+## 1862              Organic matter      Sulfate+Organic matter  0.3651185496
+## 2066                         Mgo                    Chromite  0.3639076231
+## 2114                         Mgo                    Ilmenite  0.3639076231
+## 2162                         Mgo          Zircon/Baddeleyite  0.3639076231
+## 2258                         Mgo                     Spinels  0.3639076231
+## 1945                    Pyroxene             Phyllosilicates  0.3632696098
+## 1686                         S03                  Iron oxide -0.3604042830
+## 1889         Hydrated Ca-sulfate       Other hydrated phases -0.3567530340
+## 2104       Other hydrated phases                    Chromite -0.3567530340
+## 2152       Other hydrated phases                    Ilmenite -0.3567530340
+## 2200       Other hydrated phases          Zircon/Baddeleyite -0.3567530340
+## 2296       Other hydrated phases                     Spinels -0.3567530340
+## 484                         Si02                       Cr203 -0.3556625391
+## 1924                        Si02             Phyllosilicates  0.3556253454
+## 1159                          Cl                    Pyroxene  0.3522452156
+## 1698                  Mg-sulfate                  Iron oxide -0.3518381974
+## 1700      Hydrated Mg-Fe sulfate                  Iron oxide -0.3518381974
+## 2052                  Iron oxide Kaolinite (hydrous Al-clay) -0.3518381974
+## 2244                  Iron oxide         Fe-Mg-clay minerals -0.3518381974
+## 727                           Cl                  Ca-sulfate -0.3512427652
+## 1066                        Ti02          Amorphous Silicate  0.3510298085
+## 1299                       Al203             Fe-Mg carbonate -0.3509804705
+## 1273                    Pyroxene                   Carbonate  0.3465495660
+## 1682                         Mgo                  Iron oxide -0.3464982845
+## 1921                        Na20             Phyllosilicates  0.3458360245
+## 1647                     Sulfate                      Halite -0.3450199577
+## 1271          Amorphous Silicate                   Carbonate  0.3440193243
+## 1537                        Na20                     Apatite -0.3437595979
+## 1782                         S03              Organic matter  0.3432071208
+## 1881                         Cao       Other hydrated phases -0.3419810270
+## 781                        FeO-T         Hydrated Ca-sulfate  0.3419222804
+## 1832                         K20      Sulfate+Organic matter -0.3418153543
+## 2079                     Sulfate                    Chromite -0.3415145094
+## 2127                     Sulfate                    Ilmenite -0.3415145094
+## 2175                     Sulfate          Zircon/Baddeleyite -0.3415145094
+## 2271                     Sulfate                     Spinels -0.3415145094
+## 2067                       Al203                    Chromite -0.3405714112
+## 2115                       Al203                    Ilmenite -0.3405714112
+## 2163                       Al203          Zircon/Baddeleyite -0.3405714112
+## 2259                       Al203                     Spinels -0.3405714112
+## 1908                  Iron oxide       Other hydrated phases -0.3401667615
+## 1688                         K20                  Iron oxide  0.3394416366
+## 1825                        Na20      Sulfate+Organic matter -0.3394412745
+## 1948             Fe-Mg carbonate             Phyllosilicates  0.3394221167
+## 678                          S03                     Sulfate  0.3393094803
+## 1207                          Cl                     Olivine  0.3391213641
+## 1809                     Apatite              Organic matter -0.3389046944
+## 1884                         Mno       Other hydrated phases  0.3367905881
+## 1692                         Mno                  Iron oxide  0.3340540806
+## 1560                   Phosphate                     Apatite  0.3322105774
+## 1795           Hydrated Sulfates              Organic matter  0.3290348513
+## 1806        Disordered Silicates              Organic matter  0.3290348513
+## 1807                    Feldspar              Organic matter  0.3290348513
+## 1808                      Quartz              Organic matter  0.3290348513
+## 2006              Organic matter                    Chlorite  0.3290348513
+## 1797                Perchlorates              Organic matter -0.3285152539
+## 1798              Na-perchlorate              Organic matter -0.3285152539
+## 1813         Hydrated Iron oxide              Organic matter -0.3285152539
+## 1691                       Cr203                  Iron oxide -0.3283737460
+## 1879                          Cl       Other hydrated phases  0.3270943988
+## 1058                         Mgo          Amorphous Silicate -0.3270275887
+## 1599                     Sulfate                 FeTi oxides  0.3254589810
+## 2088                   Phosphate                    Chromite  0.3254168976
+## 2136                   Phosphate                    Ilmenite  0.3254168976
+## 2184                   Phosphate          Zircon/Baddeleyite  0.3254168976
+## 2280                   Phosphate                     Spinels  0.3254168976
+## 1210                        Ti02                     Olivine -0.3253298966
+## 1166                 Plagioclase                    Pyroxene  0.3238751378
+## 1657                    Pyroxene                      Halite  0.3238751378
+## 1154                         Mgo                    Pyroxene -0.3225282004
+## 731                        Cr203                  Ca-sulfate -0.3211544658
+## 677                         P205                     Sulfate  0.3211083523
+## 1562                     Olivine                     Apatite  0.3205364872
+## 777                          Cao         Hydrated Ca-sulfate  0.3198658243
+## 1597                       FeO-T                 FeTi oxides  0.3198210933
+## 2072                         K20                    Chromite -0.3197175871
+## 2120                         K20                    Ilmenite -0.3197175871
+## 2168                         K20          Zircon/Baddeleyite -0.3197175871
+## 2264                         K20                     Spinels -0.3197175871
+## 967                           Cl                Perchlorates  0.3184205497
+## 1015                          Cl              Na-perchlorate  0.3184205497
+## 1735                          Cl         Hydrated Iron oxide  0.3184205497
+## 1944                   Phosphate             Phyllosilicates -0.3174090312
+## 970                         Ti02                Perchlorates  0.3171154519
+## 1018                        Ti02              Na-perchlorate  0.3171154519
+## 1738                        Ti02         Hydrated Iron oxide  0.3171154519
+## 1215                     Sulfate                     Olivine -0.3155425480
+## 1831                          Cl      Sulfate+Organic matter -0.3154499959
+## 824                          K20                  Mg-sulfate -0.3152746253
+## 920                          K20      Hydrated Mg-Fe sulfate -0.3152746253
+## 2024                         K20 Kaolinite (hydrous Al-clay) -0.3152746253
+## 2216                         K20         Fe-Mg-clay minerals -0.3152746253
+## 581                         P205                       FeO-T -0.3149656236
+## 1115                       Cr203                   Phosphate  0.3126373124
+## 1301                        P205             Fe-Mg carbonate -0.3101341744
+## 2069                        P205                    Chromite -0.3101341744
+## 2117                        P205                    Ilmenite -0.3101341744
+## 2165                        P205          Zircon/Baddeleyite -0.3101341744
+## 2261                        P205                     Spinels -0.3101341744
+## 1272                   Phosphate                   Carbonate  0.3099059141
+## 1538                         Mgo                     Apatite  0.3087985525
+## 1539                       Al203                     Apatite -0.3085421576
+## 1544                         K20                     Apatite -0.3083481270
+## 1959      Sulfate+Organic matter             Phyllosilicates -0.3069375160
+## 1551                     Sulfate                     Apatite -0.3057341942
+## 1827                       Al203      Sulfate+Organic matter -0.3053154442
+## 683                        Cr203                     Sulfate -0.3038810180
+## 962                          Mgo                Perchlorates -0.3030578279
+## 1010                         Mgo              Na-perchlorate -0.3030578279
+## 1730                         Mgo         Hydrated Iron oxide -0.3030578279
+## 1319          Amorphous Silicate             Fe-Mg carbonate -0.3018503119
+## 1415          Amorphous Silicate        Disordered Silicates -0.3018503119
+## 1463          Amorphous Silicate                    Feldspar -0.3018503119
+## 1511          Amorphous Silicate                      Quartz -0.3018503119
+## 1991          Amorphous Silicate                    Chlorite -0.3018503119
+## 2087          Amorphous Silicate                    Chromite -0.3018503119
+## 2135          Amorphous Silicate                    Ilmenite -0.3018503119
+## 2183          Amorphous Silicate          Zircon/Baddeleyite -0.3018503119
+## 2279          Amorphous Silicate                     Spinels -0.3018503119
+## 1882                        Ti02       Other hydrated phases -0.3017854452
+## 1839                     Sulfate      Sulfate+Organic matter  0.2997797018
+## 1926                         S03             Phyllosilicates -0.2995049013
+## 1070                 Plagioclase          Amorphous Silicate  0.2983905952
+## 1683                       Al203                  Iron oxide  0.2947820124
+## 820                         Si02                  Mg-sulfate -0.2894992096
+## 916                         Si02      Hydrated Mg-Fe sulfate -0.2894992096
+## 2020                        Si02 Kaolinite (hydrous Al-clay) -0.2894992096
+## 2212                        Si02         Fe-Mg-clay minerals -0.2894992096
+## 783                      Sulfate         Hydrated Ca-sulfate  0.2889738156
+## 879                      Sulfate           Hydrated Sulfates  0.2889738156
+## 1221                Perchlorates                     Olivine -0.2888000751
+## 1222              Na-perchlorate                     Olivine -0.2888000751
+## 1754                     Olivine         Hydrated Iron oxide -0.2888000751
+## 1609                    Pyroxene                 FeTi oxides  0.2869970333
+## 585                          Cao                       FeO-T -0.2845931065
+## 880                   Ca-sulfate           Hydrated Sulfates -0.2835465942
+## 1312                  Ca-sulfate             Fe-Mg carbonate -0.2835465942
+## 1408                  Ca-sulfate        Disordered Silicates -0.2835465942
+## 1456                  Ca-sulfate                    Feldspar -0.2835465942
+## 1504                  Ca-sulfate                      Quartz -0.2835465942
+## 1984                  Ca-sulfate                    Chlorite -0.2835465942
+## 2080                  Ca-sulfate                    Chromite -0.2835465942
+## 2128                  Ca-sulfate                    Ilmenite -0.2835465942
+## 2176                  Ca-sulfate          Zircon/Baddeleyite -0.2835465942
+## 2272                  Ca-sulfate                     Spinels -0.2835465942
+## 729                          Cao                  Ca-sulfate  0.2833257714
+## 1122                  Mg-sulfate                   Phosphate -0.2829878717
+## 1124      Hydrated Mg-Fe sulfate                   Phosphate -0.2829878717
+## 2040                   Phosphate Kaolinite (hydrous Al-clay) -0.2829878717
+## 2232                   Phosphate         Fe-Mg-clay minerals -0.2829878717
+## 867                        Al203           Hydrated Sulfates -0.2822806787
+## 1057                        Na20          Amorphous Silicate  0.2810880590
+## 1787                       Cr203              Organic matter -0.2803659994
+## 877                        FeO-T           Hydrated Sulfates  0.2800165250
+## 1265         Hydrated Ca-sulfate                   Carbonate  0.2798946477
+## 1267           Hydrated Sulfates                   Carbonate  0.2798946477
+## 1323                   Carbonate             Fe-Mg carbonate  0.2798946477
+## 2091                   Carbonate                    Chromite  0.2798946477
+## 2139                   Carbonate                    Ilmenite  0.2798946477
+## 2187                   Carbonate          Zircon/Baddeleyite  0.2798946477
+## 2283                   Carbonate                     Spinels  0.2798946477
+## 2102              Organic matter                    Chromite -0.2784141050
+## 2150              Organic matter                    Ilmenite -0.2784141050
+## 2198              Organic matter          Zircon/Baddeleyite -0.2784141050
+## 2294              Organic matter                     Spinels -0.2784141050
+## 1224                   Phosphate                     Olivine -0.2772761262
+## 1699           Hydrated Sulfates                  Iron oxide -0.2768248134
+## 2100                  Iron oxide                    Chromite -0.2768248134
+## 2148                  Iron oxide                    Ilmenite -0.2768248134
+## 2196                  Iron oxide          Zircon/Baddeleyite -0.2768248134
+## 2292                  Iron oxide                     Spinels -0.2768248134
+## 292                         Si02                          Cl -0.2767775156
+## 1883                       Cr203       Other hydrated phases -0.2760236639
+## 1540                        Si02                     Apatite -0.2759846731
+## 2068                        Si02                    Chromite -0.2745092758
+## 2116                        Si02                    Ilmenite -0.2745092758
+## 2164                        Si02          Zircon/Baddeleyite -0.2745092758
+## 2260                        Si02                     Spinels -0.2745092758
+## 1715                      Halite                  Iron oxide  0.2736519313
+## 1838                 Plagioclase      Sulfate+Organic matter -0.2736519313
+## 1859                      Halite      Sulfate+Organic matter -0.2736519313
+## 1257                         Cao                   Carbonate -0.2729845054
+## 1559          Amorphous Silicate                     Apatite -0.2728083976
+## 1253                        P205                   Carbonate -0.2722480335
+## 871                           Cl           Hydrated Sulfates -0.2718720583
+## 1803                   Carbonate              Organic matter -0.2712846428
+## 241                         Na20                         S03 -0.2710234329
+## 1634                         Mgo                      Halite  0.2700492903
+## 1960       Other hydrated phases             Phyllosilicates  0.2663977138
+## 1829                        P205      Sulfate+Organic matter -0.2663406290
+## 439                           Cl                        Ti02 -0.2653799744
+## 1791                     Sulfate              Organic matter  0.2653000009
+## 1607          Amorphous Silicate                 FeTi oxides  0.2644142930
+## 1931                       Cr203             Phyllosilicates -0.2617499719
+## 1065                         Cao          Amorphous Silicate  0.2604181707
+## 1067                       Cr203          Amorphous Silicate -0.2593874752
+## 1934                 Plagioclase             Phyllosilicates -0.2588387888
+## 1938                  Mg-sulfate             Phyllosilicates -0.2588387888
+## 1940      Hydrated Mg-Fe sulfate             Phyllosilicates -0.2588387888
+## 2057             Phyllosilicates Kaolinite (hydrous Al-clay) -0.2588387888
+## 2249             Phyllosilicates         Fe-Mg-clay minerals -0.2588387888
+## 1585                        Na20                 FeTi oxides  0.2584947798
+## 1157                        P205                    Pyroxene  0.2581630512
+## 1169         Hydrated Ca-sulfate                    Pyroxene  0.2548235957
+## 1171           Hydrated Sulfates                    Pyroxene  0.2548235957
+## 1321                    Pyroxene             Fe-Mg carbonate  0.2548235957
+## 1417                    Pyroxene        Disordered Silicates  0.2548235957
+## 1465                    Pyroxene                    Feldspar  0.2548235957
+## 1513                    Pyroxene                      Quartz  0.2548235957
+## 1993                    Pyroxene                    Chlorite  0.2548235957
+## 1922                         Mgo             Phyllosilicates -0.2538223960
+## 1684                        Si02                  Iron oxide  0.2501466712
+## 1840                  Ca-sulfate      Sulfate+Organic matter -0.2497496051
+## 1419                   Carbonate        Disordered Silicates -0.2469658656
+## 1467                   Carbonate                    Feldspar -0.2469658656
+## 1515                   Carbonate                      Quartz -0.2469658656
+## 1995                   Carbonate                    Chlorite -0.2469658656
+## 680                          K20                     Sulfate -0.2453114087
+## 1910              Organic matter       Other hydrated phases  0.2437979154
+## 1893                Perchlorates       Other hydrated phases -0.2437087183
+## 1894              Na-perchlorate       Other hydrated phases -0.2437087183
+## 1909         Hydrated Iron oxide       Other hydrated phases -0.2437087183
+## 1858                 FeTi oxides      Sulfate+Organic matter -0.2424925018
+## 1061                        P205          Amorphous Silicate  0.2415474855
+## 1110                         S03                   Phosphate -0.2404345874
+## 1541                        P205                     Apatite -0.2401650624
+## 1155                       Al203                    Pyroxene  0.2391238409
+## 1398                         S03        Disordered Silicates -0.2379085375
+## 1446                         S03                    Feldspar -0.2379085375
+## 1494                         S03                      Quartz -0.2379085375
+## 1974                         S03                    Chlorite -0.2379085375
+## 1907                      Halite       Other hydrated phases  0.2375084344
+## 1073         Hydrated Ca-sulfate          Amorphous Silicate  0.2347724648
+## 1075           Hydrated Sulfates          Amorphous Silicate  0.2347724648
+## 817                         Na20                  Mg-sulfate -0.2346426850
+## 913                         Na20      Hydrated Mg-Fe sulfate -0.2346426850
+## 2017                        Na20 Kaolinite (hydrous Al-clay) -0.2346426850
+## 2209                        Na20         Fe-Mg-clay minerals -0.2346426850
+## 775                           Cl         Hydrated Ca-sulfate -0.2328724803
+## 830                  Plagioclase                  Mg-sulfate -0.2307692308
+## 926                  Plagioclase      Hydrated Mg-Fe sulfate -0.2307692308
+## 1650                  Mg-sulfate                      Halite -0.2307692308
+## 1652      Hydrated Mg-Fe sulfate                      Halite -0.2307692308
+## 2030                 Plagioclase Kaolinite (hydrous Al-clay) -0.2307692308
+## 2051                      Halite Kaolinite (hydrous Al-clay) -0.2307692308
+## 2222                 Plagioclase         Fe-Mg-clay minerals -0.2307692308
+## 2243                      Halite         Fe-Mg-clay minerals -0.2307692308
+## 1784                         K20              Organic matter  0.2304873659
+## 1168                  Ca-sulfate                    Pyroxene -0.2299002449
+## 681                          Cao                     Sulfate  0.2298355225
+## 1953                     Apatite             Phyllosilicates -0.2293660607
+## 1954                 FeTi oxides             Phyllosilicates -0.2293660607
+## 1297                        Na20             Fe-Mg carbonate -0.2282087645
+## 626                          Mgo                 Plagioclase -0.2277517874
+## 1223          Amorphous Silicate                     Olivine  0.2276967106
+## 1403                       Cr203        Disordered Silicates -0.2260636400
+## 1451                       Cr203                    Feldspar -0.2260636400
+## 1499                       Cr203                      Quartz -0.2260636400
+## 1979                       Cr203                    Chlorite -0.2260636400
+## 1418                     Olivine        Disordered Silicates -0.2238141291
+## 1466                     Olivine                    Feldspar -0.2238141291
+## 1514                     Olivine                      Quartz -0.2238141291
+## 1994                     Olivine                    Chlorite -0.2238141291
+## 1792                  Ca-sulfate              Organic matter -0.2237816226
+## 530                          Mgo                         Mno  0.2237294565
+## 1161                         Cao                    Pyroxene  0.2233893875
+## 1123           Hydrated Sulfates                   Phosphate -0.2226536668
+## 1320                   Phosphate             Fe-Mg carbonate -0.2226536668
+## 1416                   Phosphate        Disordered Silicates -0.2226536668
+## 1464                   Phosphate                    Feldspar -0.2226536668
+## 1512                   Phosphate                      Quartz -0.2226536668
+## 1992                   Phosphate                    Chlorite -0.2226536668
+## 1063                          Cl          Amorphous Silicate -0.2222977723
+## 1404                         Mno        Disordered Silicates -0.2216451308
+## 1452                         Mno                    Feldspar -0.2216451308
+## 1500                         Mno                      Quartz -0.2216451308
+## 1980                         Mno                    Chlorite -0.2216451308
+## 630                          S03                 Plagioclase -0.2210688666
+## 1850                     Olivine      Sulfate+Organic matter  0.2195277333
+## 1848                   Phosphate      Sulfate+Organic matter -0.2175700229
+## 721                         Na20                  Ca-sulfate  0.2172153294
+## 1552                  Ca-sulfate                     Apatite -0.2161234100
+## 1710        Disordered Silicates                  Iron oxide  0.2153081882
+## 1711                    Feldspar                  Iron oxide  0.2153081882
+## 1712                      Quartz                  Iron oxide  0.2153081882
+## 1841         Hydrated Ca-sulfate      Sulfate+Organic matter -0.2153081882
+## 1852             Fe-Mg carbonate      Sulfate+Organic matter -0.2153081882
+## 1854        Disordered Silicates      Sulfate+Organic matter -0.2153081882
+## 1855                    Feldspar      Sulfate+Organic matter -0.2153081882
+## 1856                      Quartz      Sulfate+Organic matter -0.2153081882
+## 2004                  Iron oxide                    Chlorite  0.2153081882
+## 2007      Sulfate+Organic matter                    Chlorite -0.2153081882
+## 436                         Si02                        Ti02  0.2150277102
+## 637                        FeO-T                 Plagioclase  0.2135996526
+## 865                         Na20           Hydrated Sulfates -0.2098997518
+## 872                          K20           Hydrated Sulfates -0.2094701433
+## 869                         P205           Hydrated Sulfates -0.2088658725
+## 1785                         Cao              Organic matter -0.2072022588
+## 635                        Cr203                 Plagioclase -0.2063861335
+## 1590                         S03                 FeTi oxides -0.2049682677
+## 1554                  Mg-sulfate                     Apatite -0.2044926482
+## 1556      Hydrated Mg-Fe sulfate                     Apatite -0.2044926482
+## 1602                  Mg-sulfate                 FeTi oxides -0.2044926482
+## 1604      Hydrated Mg-Fe sulfate                 FeTi oxides -0.2044926482
+## 2049                     Apatite Kaolinite (hydrous Al-clay) -0.2044926482
+## 2050                 FeTi oxides Kaolinite (hydrous Al-clay) -0.2044926482
+## 2241                     Apatite         Fe-Mg-clay minerals -0.2044926482
+## 2242                 FeTi oxides         Fe-Mg-clay minerals -0.2044926482
+## 827                        Cr203                  Mg-sulfate -0.2036882755
+## 923                        Cr203      Hydrated Mg-Fe sulfate -0.2036882755
+## 2027                       Cr203 Kaolinite (hydrous Al-clay) -0.2036882755
+## 2219                       Cr203         Fe-Mg-clay minerals -0.2036882755
+## 1937         Hydrated Ca-sulfate             Phyllosilicates -0.2036532700
+## 1939           Hydrated Sulfates             Phyllosilicates -0.2036532700
+## 2105             Phyllosilicates                    Chromite -0.2036532700
+## 2153             Phyllosilicates                    Ilmenite -0.2036532700
+## 2201             Phyllosilicates          Zircon/Baddeleyite -0.2036532700
+## 2297             Phyllosilicates                     Spinels -0.2036532700
+## 870                          S03           Hydrated Sulfates -0.2034885600
+## 674                          Mgo                     Sulfate -0.2031052602
+## 1687                          Cl                  Iron oxide  0.2017685027
+## 1955                      Halite             Phyllosilicates  0.2013190580
+## 1309                       FeO-T             Fe-Mg carbonate  0.2009879012
+## 1781                        P205              Organic matter -0.2007257846
+## 825                          Cao                  Mg-sulfate -0.1993355303
+## 921                          Cao      Hydrated Mg-Fe sulfate -0.1993355303
+## 2025                         Cao Kaolinite (hydrous Al-clay) -0.1993355303
+## 2217                         Cao         Fe-Mg-clay minerals -0.1993355303
+## 975                      Sulfate                Perchlorates  0.1974066974
+## 1023                     Sulfate              Na-perchlorate  0.1974066974
+## 1743                     Sulfate         Hydrated Iron oxide  0.1974066974
+## 536                          K20                         Mno -0.1972889909
+## 1638                         S03                      Halite -0.1943345718
+## 289                         Na20                          Cl  0.1914581341
+## 1932                         Mno             Phyllosilicates -0.1911431258
+## 732                          Mno                  Ca-sulfate -0.1910794273
+## 1956                  Iron oxide             Phyllosilicates  0.1900089385
+## 1713                     Apatite                  Iron oxide -0.1886052792
+## 1635                       Al203                      Halite -0.1876685738
+## 1225                    Pyroxene                     Olivine  0.1863081957
+## 774                          S03         Hydrated Ca-sulfate -0.1860178139
+## 1880                         K20       Other hydrated phases  0.1848562174
+## 1563                   Carbonate                     Apatite  0.1833711199
+## 1611                   Carbonate                 FeTi oxides  0.1833711199
+## 343                           Cl                         K20  0.1823920866
+## 833          Hydrated Ca-sulfate                  Mg-sulfate -0.1815682598
+## 878                  Plagioclase           Hydrated Sulfates -0.1815682598
+## 882                   Mg-sulfate           Hydrated Sulfates -0.1815682598
+## 929          Hydrated Ca-sulfate      Hydrated Mg-Fe sulfate -0.1815682598
+## 931            Hydrated Sulfates      Hydrated Mg-Fe sulfate -0.1815682598
+## 1310                 Plagioclase             Fe-Mg carbonate -0.1815682598
+## 1314                  Mg-sulfate             Fe-Mg carbonate -0.1815682598
+## 1316      Hydrated Mg-Fe sulfate             Fe-Mg carbonate -0.1815682598
+## 1406                 Plagioclase        Disordered Silicates -0.1815682598
+## 1410                  Mg-sulfate        Disordered Silicates -0.1815682598
+## 1412      Hydrated Mg-Fe sulfate        Disordered Silicates -0.1815682598
+## 1454                 Plagioclase                    Feldspar -0.1815682598
+## 1458                  Mg-sulfate                    Feldspar -0.1815682598
+## 1460      Hydrated Mg-Fe sulfate                    Feldspar -0.1815682598
+## 1502                 Plagioclase                      Quartz -0.1815682598
+## 1506                  Mg-sulfate                      Quartz -0.1815682598
+## 1508      Hydrated Mg-Fe sulfate                      Quartz -0.1815682598
+## 1649         Hydrated Ca-sulfate                      Halite -0.1815682598
+## 1651           Hydrated Sulfates                      Halite -0.1815682598
+## 1662        Disordered Silicates                      Halite -0.1815682598
+## 1663                    Feldspar                      Halite -0.1815682598
+## 1664                      Quartz                      Halite -0.1815682598
+## 1982                 Plagioclase                    Chlorite -0.1815682598
+## 1986                  Mg-sulfate                    Chlorite -0.1815682598
+## 1988      Hydrated Mg-Fe sulfate                    Chlorite -0.1815682598
+## 2003                      Halite                    Chlorite -0.1815682598
+## 2033         Hydrated Ca-sulfate Kaolinite (hydrous Al-clay) -0.1815682598
+## 2035           Hydrated Sulfates Kaolinite (hydrous Al-clay) -0.1815682598
+## 2044             Fe-Mg carbonate Kaolinite (hydrous Al-clay) -0.1815682598
+## 2046        Disordered Silicates Kaolinite (hydrous Al-clay) -0.1815682598
+## 2047                    Feldspar Kaolinite (hydrous Al-clay) -0.1815682598
+## 2048                      Quartz Kaolinite (hydrous Al-clay) -0.1815682598
+## 2058                    Chlorite Kaolinite (hydrous Al-clay) -0.1815682598
+## 2078                 Plagioclase                    Chromite -0.1815682598
+## 2082                  Mg-sulfate                    Chromite -0.1815682598
+## 2084      Hydrated Mg-Fe sulfate                    Chromite -0.1815682598
+## 2099                      Halite                    Chromite -0.1815682598
+## 2107 Kaolinite (hydrous Al-clay)                    Chromite -0.1815682598
+## 2126                 Plagioclase                    Ilmenite -0.1815682598
+## 2130                  Mg-sulfate                    Ilmenite -0.1815682598
+## 2132      Hydrated Mg-Fe sulfate                    Ilmenite -0.1815682598
+## 2147                      Halite                    Ilmenite -0.1815682598
+## 2155 Kaolinite (hydrous Al-clay)                    Ilmenite -0.1815682598
+## 2174                 Plagioclase          Zircon/Baddeleyite -0.1815682598
+## 2178                  Mg-sulfate          Zircon/Baddeleyite -0.1815682598
+## 2180      Hydrated Mg-Fe sulfate          Zircon/Baddeleyite -0.1815682598
+## 2195                      Halite          Zircon/Baddeleyite -0.1815682598
+## 2203 Kaolinite (hydrous Al-clay)          Zircon/Baddeleyite -0.1815682598
+## 2225         Hydrated Ca-sulfate         Fe-Mg-clay minerals -0.1815682598
+## 2227           Hydrated Sulfates         Fe-Mg-clay minerals -0.1815682598
+## 2236             Fe-Mg carbonate         Fe-Mg-clay minerals -0.1815682598
+## 2238        Disordered Silicates         Fe-Mg-clay minerals -0.1815682598
+## 2239                    Feldspar         Fe-Mg-clay minerals -0.1815682598
+## 2240                      Quartz         Fe-Mg-clay minerals -0.1815682598
+## 2250                    Chlorite         Fe-Mg-clay minerals -0.1815682598
+## 2252                    Chromite         Fe-Mg-clay minerals -0.1815682598
+## 2253                    Ilmenite         Fe-Mg-clay minerals -0.1815682598
+## 2254          Zircon/Baddeleyite         Fe-Mg-clay minerals -0.1815682598
+## 2270                 Plagioclase                     Spinels -0.1815682598
+## 2274                  Mg-sulfate                     Spinels -0.1815682598
+## 2276      Hydrated Mg-Fe sulfate                     Spinels -0.1815682598
+## 2291                      Halite                     Spinels -0.1815682598
+## 2299 Kaolinite (hydrous Al-clay)                     Spinels -0.1815682598
+## 2303         Fe-Mg-clay minerals                     Spinels -0.1815682598
+## 728                          K20                  Ca-sulfate -0.1800308360
+## 1646                 Plagioclase                      Halite  0.1794871795
+## 1263                     Sulfate                   Carbonate -0.1786329339
+## 1887                     Sulfate       Other hydrated phases -0.1780684931
+## 1642                        Ti02                      Halite -0.1777745648
+## 1064                         K20          Amorphous Silicate  0.1772989893
+## 1204                        Si02                     Olivine -0.1769612490
+## 963                        Al203                Perchlorates  0.1769241309
+## 1011                       Al203              Na-perchlorate  0.1769241309
+## 1731                       Al203         Hydrated Iron oxide  0.1769241309
+## 489                          Cao                       Cr203 -0.1748322510
+## 1591                          Cl                 FeTi oxides -0.1748026870
+## 1173                Perchlorates                    Pyroxene  0.1740776560
+## 1174              Na-perchlorate                    Pyroxene  0.1740776560
+## 1753                    Pyroxene         Hydrated Iron oxide  0.1740776560
+## 1643                       Cr203                      Halite -0.1713139801
+## 1107                       Al203                   Phosphate -0.1699001388
+## 1208                         K20                     Olivine -0.1688862261
+## 1656                   Phosphate                      Halite -0.1668902833
+## 290                          Mgo                          Cl  0.1664966527
+## 1595                       Cr203                 FeTi oxides -0.1661512760
+## 1911      Sulfate+Organic matter       Other hydrated phases  0.1645968201
+## 769                         Na20         Hydrated Ca-sulfate  0.1641272203
+## 1402                        Ti02        Disordered Silicates -0.1636550264
+## 1450                        Ti02                    Feldspar -0.1636550264
+## 1498                        Ti02                      Quartz -0.1636550264
+## 1978                        Ti02                    Chlorite -0.1636550264
+## 1830                         S03      Sulfate+Organic matter  0.1635662083
+## 435                        Al203                        Ti02  0.1630311039
+## 390                          S03                         Cao -0.1619254652
+## 1553         Hydrated Ca-sulfate                     Apatite -0.1608939552
+## 1555           Hydrated Sulfates                     Apatite -0.1608939552
+## 1564             Fe-Mg carbonate                     Apatite -0.1608939552
+## 1566        Disordered Silicates                     Apatite -0.1608939552
+## 1567                    Feldspar                     Apatite -0.1608939552
+## 1568                      Quartz                     Apatite -0.1608939552
+## 1603           Hydrated Sulfates                 FeTi oxides -0.1608939552
+## 1612             Fe-Mg carbonate                 FeTi oxides -0.1608939552
+## 1614        Disordered Silicates                 FeTi oxides -0.1608939552
+## 1615                    Feldspar                 FeTi oxides -0.1608939552
+## 1616                      Quartz                 FeTi oxides -0.1608939552
+## 2001                     Apatite                    Chlorite -0.1608939552
+## 2002                 FeTi oxides                    Chlorite -0.1608939552
+## 2098                 FeTi oxides                    Chromite -0.1608939552
+## 2146                 FeTi oxides                    Ilmenite -0.1608939552
+## 2194                 FeTi oxides          Zircon/Baddeleyite -0.1608939552
+## 2290                 FeTi oxides                     Spinels -0.1608939552
+## 1077                Perchlorates          Amorphous Silicate  0.1603801259
+## 1078              Na-perchlorate          Amorphous Silicate  0.1603801259
+## 1751          Amorphous Silicate         Hydrated Iron oxide  0.1603801259
+## 1655          Amorphous Silicate                      Halite -0.1562998356
+## 1302                         S03             Fe-Mg carbonate -0.1544661678
+## 1304                         K20             Fe-Mg carbonate -0.1543464214
+## 1801                    Pyroxene              Organic matter -0.1535023912
+## 539                        Cr203                         Mno  0.1530795952
+## 873                          Cao           Hydrated Sulfates -0.1501411012
+## 1119                     Sulfate                   Phosphate  0.1480294770
+## 1845                Perchlorates      Sulfate+Organic matter -0.1470834936
+## 1846              Na-perchlorate      Sulfate+Organic matter -0.1470834936
+## 1861         Hydrated Iron oxide      Sulfate+Organic matter -0.1470834936
+## 1836                         Mno      Sulfate+Organic matter  0.1467009984
+## 1617                     Apatite                 FeTi oxides -0.1454138702
+## 1111                          Cl                   Phosphate -0.1453505946
+## 538                         Ti02                         Mno  0.1437108550
+## 1842                  Mg-sulfate      Sulfate+Organic matter  0.1433414878
+## 1844      Hydrated Mg-Fe sulfate      Sulfate+Organic matter  0.1433414878
+## 2055      Sulfate+Organic matter Kaolinite (hydrous Al-clay)  0.1433414878
+## 2247      Sulfate+Organic matter         Fe-Mg-clay minerals  0.1433414878
+## 881          Hydrated Ca-sulfate           Hydrated Sulfates -0.1428571429
+## 1313         Hydrated Ca-sulfate             Fe-Mg carbonate -0.1428571429
+## 1315           Hydrated Sulfates             Fe-Mg carbonate -0.1428571429
+## 1409         Hydrated Ca-sulfate        Disordered Silicates -0.1428571429
+## 1411           Hydrated Sulfates        Disordered Silicates -0.1428571429
+## 1420             Fe-Mg carbonate        Disordered Silicates -0.1428571429
+## 1457         Hydrated Ca-sulfate                    Feldspar -0.1428571429
+## 1459           Hydrated Sulfates                    Feldspar -0.1428571429
+## 1468             Fe-Mg carbonate                    Feldspar -0.1428571429
+## 1505         Hydrated Ca-sulfate                      Quartz -0.1428571429
+## 1507           Hydrated Sulfates                      Quartz -0.1428571429
+## 1516             Fe-Mg carbonate                      Quartz -0.1428571429
+## 1985         Hydrated Ca-sulfate                    Chlorite -0.1428571429
+## 1987           Hydrated Sulfates                    Chlorite -0.1428571429
+## 1996             Fe-Mg carbonate                    Chlorite -0.1428571429
+## 2081         Hydrated Ca-sulfate                    Chromite -0.1428571429
+## 2083           Hydrated Sulfates                    Chromite -0.1428571429
+## 2092             Fe-Mg carbonate                    Chromite -0.1428571429
+## 2094        Disordered Silicates                    Chromite -0.1428571429
+## 2095                    Feldspar                    Chromite -0.1428571429
+## 2096                      Quartz                    Chromite -0.1428571429
+## 2106                    Chlorite                    Chromite -0.1428571429
+## 2129         Hydrated Ca-sulfate                    Ilmenite -0.1428571429
+## 2131           Hydrated Sulfates                    Ilmenite -0.1428571429
+## 2140             Fe-Mg carbonate                    Ilmenite -0.1428571429
+## 2142        Disordered Silicates                    Ilmenite -0.1428571429
+## 2143                    Feldspar                    Ilmenite -0.1428571429
+## 2144                      Quartz                    Ilmenite -0.1428571429
+## 2154                    Chlorite                    Ilmenite -0.1428571429
+## 2177         Hydrated Ca-sulfate          Zircon/Baddeleyite -0.1428571429
+## 2179           Hydrated Sulfates          Zircon/Baddeleyite -0.1428571429
+## 2188             Fe-Mg carbonate          Zircon/Baddeleyite -0.1428571429
+## 2190        Disordered Silicates          Zircon/Baddeleyite -0.1428571429
+## 2191                    Feldspar          Zircon/Baddeleyite -0.1428571429
+## 2192                      Quartz          Zircon/Baddeleyite -0.1428571429
+## 2202                    Chlorite          Zircon/Baddeleyite -0.1428571429
+## 2273         Hydrated Ca-sulfate                     Spinels -0.1428571429
+## 2275           Hydrated Sulfates                     Spinels -0.1428571429
+## 2284             Fe-Mg carbonate                     Spinels -0.1428571429
+## 2286        Disordered Silicates                     Spinels -0.1428571429
+## 2287                    Feldspar                     Spinels -0.1428571429
+## 2288                      Quartz                     Spinels -0.1428571429
+## 2298                    Chlorite                     Spinels -0.1428571429
+## 1849                    Pyroxene      Sulfate+Organic matter -0.1426505774
+## 1826                         Mgo      Sulfate+Organic matter  0.1415728453
+## 971                        Cr203                Perchlorates -0.1413803702
+## 1019                       Cr203              Na-perchlorate -0.1413803702
+## 1739                       Cr203         Hydrated Iron oxide -0.1413803702
+## 779                        Cr203         Hydrated Ca-sulfate -0.1400957769
+## 1941                Perchlorates             Phyllosilicates -0.1391216687
+## 1942              Na-perchlorate             Phyllosilicates -0.1391216687
+## 1957         Hydrated Iron oxide             Phyllosilicates -0.1391216687
+## 1707                   Carbonate                  Iron oxide -0.1382518100
+## 722                          Mgo                  Ca-sulfate -0.1371022896
+## 1658                     Olivine                      Halite  0.1369635673
+## 1837                       FeO-T      Sulfate+Organic matter  0.1327652878
+## 1876                        Si02       Other hydrated phases  0.1316548589
+## 490                         Ti02                       Cr203 -0.1306255703
+## 1069                       FeO-T          Amorphous Silicate  0.1275086785
+## 1255                          Cl                   Carbonate  0.1260685362
+## 724                         Si02                  Ca-sulfate -0.1260461599
+## 1633                        Na20                      Halite  0.1254936674
+## 1401                         Cao        Disordered Silicates  0.1250338937
+## 1449                         Cao                    Feldspar  0.1250338937
+## 1497                         Cao                      Quartz  0.1250338937
+## 1977                         Cao                    Chlorite  0.1250338937
+## 1799          Amorphous Silicate              Organic matter  0.1247857526
+## 978                   Mg-sulfate                Perchlorates -0.1240347346
+## 980       Hydrated Mg-Fe sulfate                Perchlorates -0.1240347346
+## 1026                  Mg-sulfate              Na-perchlorate -0.1240347346
+## 1028      Hydrated Mg-Fe sulfate              Na-perchlorate -0.1240347346
+## 1746                  Mg-sulfate         Hydrated Iron oxide -0.1240347346
+## 1748      Hydrated Mg-Fe sulfate         Hydrated Iron oxide -0.1240347346
+## 2037                Perchlorates Kaolinite (hydrous Al-clay) -0.1240347346
+## 2038              Na-perchlorate Kaolinite (hydrous Al-clay) -0.1240347346
+## 2053         Hydrated Iron oxide Kaolinite (hydrous Al-clay) -0.1240347346
+## 2229                Perchlorates         Fe-Mg-clay minerals -0.1240347346
+## 2230              Na-perchlorate         Fe-Mg-clay minerals -0.1240347346
+## 2245         Hydrated Iron oxide         Fe-Mg-clay minerals -0.1240347346
+## 242                          Mgo                         S03  0.1237414346
+## 973                        FeO-T                Perchlorates -0.1227356789
+## 1021                       FeO-T              Na-perchlorate -0.1227356789
+## 1741                       FeO-T         Hydrated Iron oxide -0.1227356789
+## 874                         Ti02           Hydrated Sulfates  0.1217379352
+## 1256                         K20                   Carbonate -0.1213432472
+## 1112                         K20                   Phosphate -0.1209411691
+## 972                          Mno                Perchlorates  0.1177652385
+## 1020                         Mno              Na-perchlorate  0.1177652385
+## 1740                         Mno         Hydrated Iron oxide  0.1177652385
+## 1162                        Ti02                    Pyroxene  0.1162915975
+## 486                          S03                       Cr203 -0.1159931216
+## 1828                        Si02      Sulfate+Organic matter -0.1155307351
+## 1786                        Ti02              Organic matter -0.1147956647
+## 1542                         S03                     Apatite -0.1107296086
+## 684                          Mno                     Sulfate  0.1101998842
+## 529                         Na20                         Mno -0.1092055691
+## 1835                       Cr203      Sulfate+Organic matter  0.1090008885
+## 1127          Amorphous Silicate                   Phosphate  0.1085668965
+## 1703          Amorphous Silicate                  Iron oxide  0.1083180729
+## 772                         Si02         Hydrated Ca-sulfate  0.1080246884
+## 1644                         Mno                      Halite  0.1078134245
+## 1588                        Si02                 FeTi oxides  0.1069769425
+## 1397                        P205        Disordered Silicates  0.1061910665
+## 1445                        P205                    Feldspar  0.1061910665
+## 1493                        P205                      Quartz  0.1061910665
+## 1973                        P205                    Chlorite  0.1061910665
+## 1543                          Cl                     Apatite  0.1045061970
+## 1586                         Mgo                 FeTi oxides -0.1025440196
+## 966                          S03                Perchlorates -0.1023141192
+## 1014                         S03              Na-perchlorate -0.1023141192
+## 1734                         S03         Hydrated Iron oxide -0.1023141192
+## 1947                   Carbonate             Phyllosilicates -0.1017084879
+## 1307                       Cr203             Fe-Mg carbonate -0.0987038428
+## 977          Hydrated Ca-sulfate                Perchlorates -0.0975900073
+## 979            Hydrated Sulfates                Perchlorates -0.0975900073
+## 1025         Hydrated Ca-sulfate              Na-perchlorate -0.0975900073
+## 1027           Hydrated Sulfates              Na-perchlorate -0.0975900073
+## 1317                Perchlorates             Fe-Mg carbonate -0.0975900073
+## 1318              Na-perchlorate             Fe-Mg carbonate -0.0975900073
+## 1413                Perchlorates        Disordered Silicates -0.0975900073
+## 1414              Na-perchlorate        Disordered Silicates -0.0975900073
+## 1461                Perchlorates                    Feldspar -0.0975900073
+## 1462              Na-perchlorate                    Feldspar -0.0975900073
+## 1509                Perchlorates                      Quartz -0.0975900073
+## 1510              Na-perchlorate                      Quartz -0.0975900073
+## 1745         Hydrated Ca-sulfate         Hydrated Iron oxide -0.0975900073
+## 1747           Hydrated Sulfates         Hydrated Iron oxide -0.0975900073
+## 1756             Fe-Mg carbonate         Hydrated Iron oxide -0.0975900073
+## 1758        Disordered Silicates         Hydrated Iron oxide -0.0975900073
+## 1759                    Feldspar         Hydrated Iron oxide -0.0975900073
+## 1760                      Quartz         Hydrated Iron oxide -0.0975900073
+## 1989                Perchlorates                    Chlorite -0.0975900073
+## 1990              Na-perchlorate                    Chlorite -0.0975900073
+## 2005         Hydrated Iron oxide                    Chlorite -0.0975900073
+## 2085                Perchlorates                    Chromite -0.0975900073
+## 2086              Na-perchlorate                    Chromite -0.0975900073
+## 2101         Hydrated Iron oxide                    Chromite -0.0975900073
+## 2133                Perchlorates                    Ilmenite -0.0975900073
+## 2134              Na-perchlorate                    Ilmenite -0.0975900073
+## 2149         Hydrated Iron oxide                    Ilmenite -0.0975900073
+## 2181                Perchlorates          Zircon/Baddeleyite -0.0975900073
+## 2182              Na-perchlorate          Zircon/Baddeleyite -0.0975900073
+## 2197         Hydrated Iron oxide          Zircon/Baddeleyite -0.0975900073
+## 2277                Perchlorates                     Spinels -0.0975900073
+## 2278              Na-perchlorate                     Spinels -0.0975900073
+## 2293         Hydrated Iron oxide                     Spinels -0.0975900073
+## 440                          K20                        Ti02  0.0969258479
+## 1059                       Al203          Amorphous Silicate  0.0963605322
+## 1645                       FeO-T                      Halite  0.0941833393
+## 2070                         S03                    Chromite -0.0918843906
+## 2118                         S03                    Ilmenite -0.0918843906
+## 2166                         S03          Zircon/Baddeleyite -0.0918843906
+## 2262                         S03                     Spinels -0.0918843906
+## 1640                         K20                      Halite -0.0910793362
+## 1262                 Plagioclase                   Carbonate -0.0906787952
+## 1659                   Carbonate                      Halite -0.0906787952
+## 733                        FeO-T                  Ca-sulfate -0.0900671371
+## 628                         Si02                 Plagioclase  0.0875753389
+## 1557                Perchlorates                     Apatite  0.0854867190
+## 1558              Na-perchlorate                     Apatite  0.0854867190
+## 1605                Perchlorates                 FeTi oxides  0.0854867190
+## 1606              Na-perchlorate                 FeTi oxides  0.0854867190
+## 1761                     Apatite         Hydrated Iron oxide  0.0854867190
+## 1762                 FeTi oxides         Hydrated Iron oxide  0.0854867190
+## 2074                        Ti02                    Chromite -0.0851719620
+## 2122                        Ti02                    Ilmenite -0.0851719620
+## 2170                        Ti02          Zircon/Baddeleyite -0.0851719620
+## 2266                        Ti02                     Spinels -0.0851719620
+## 1258                        Ti02                   Carbonate -0.0847476476
+## 1958              Organic matter             Phyllosilicates  0.0841908243
+## 676                         Si02                     Sulfate  0.0839274655
+## 1550                 Plagioclase                     Apatite -0.0833118196
+## 1665                     Apatite                      Halite -0.0833118196
+## 1666                 FeTi oxides                      Halite -0.0833118196
+## 1851                   Carbonate      Sulfate+Organic matter  0.0815331187
+## 391                           Cl                         Cao  0.0794361483
+## 2073                         Cao                    Chromite -0.0778323434
+## 2121                         Cao                    Ilmenite -0.0778323434
+## 2169                         Cao          Zircon/Baddeleyite -0.0778323434
+## 2265                         Cao                     Spinels -0.0778323434
+## 627                        Al203                 Plagioclase  0.0764841081
+## 1106                         Mgo                   Phosphate  0.0762736262
+## 818                          Mgo                  Mg-sulfate  0.0746701617
+## 914                          Mgo      Hydrated Mg-Fe sulfate  0.0746701617
+## 2018                         Mgo Kaolinite (hydrous Al-clay)  0.0746701617
+## 2210                         Mgo         Fe-Mg-clay minerals  0.0746701617
+## 1399                          Cl        Disordered Silicates  0.0701242412
+## 1447                          Cl                    Feldspar  0.0701242412
+## 1495                          Cl                      Quartz  0.0701242412
+## 1975                          Cl                    Chlorite  0.0701242412
+## 1875                       Al203       Other hydrated phases -0.0677010816
+## 826                         Ti02                  Mg-sulfate -0.0659333933
+## 922                         Ti02      Hydrated Mg-Fe sulfate -0.0659333933
+## 2026                        Ti02 Kaolinite (hydrous Al-clay) -0.0659333933
+## 2218                        Ti02         Fe-Mg-clay minerals -0.0659333933
+## 1167                     Sulfate                    Pyroxene -0.0656041817
+## 533                         P205                         Mno -0.0652643524
+## 723                        Al203                  Ca-sulfate  0.0644104381
+## 968                          K20                Perchlorates  0.0640163407
+## 1016                         K20              Na-perchlorate  0.0640163407
+## 1736                         K20         Hydrated Iron oxide  0.0640163407
+## 535                           Cl                         Mno  0.0630583835
+## 1548                         Mno                     Apatite  0.0626642035
+## 1252                        Si02                   Carbonate -0.0621272168
+## 537                          Cao                         Mno  0.0618362366
+## 868                         Si02           Hydrated Sulfates  0.0618232240
+## 1929                         Cao             Phyllosilicates -0.0613238913
+## 1874                         Mgo       Other hydrated phases  0.0609526229
+## 632                          K20                 Plagioclase  0.0583841899
+## 673                         Na20                     Sulfate  0.0575978475
+## 1885                       FeO-T       Other hydrated phases  0.0574006138
+## 293                         P205                          Cl -0.0565121116
+## 243                        Al203                         S03 -0.0549471942
+## 866                          Mgo           Hydrated Sulfates  0.0548253143
+## 675                        Al203                     Sulfate -0.0537755729
+## 1902        Disordered Silicates       Other hydrated phases  0.0509647191
+## 1903                    Feldspar       Other hydrated phases  0.0509647191
+## 1904                      Quartz       Other hydrated phases  0.0509647191
+## 2008       Other hydrated phases                    Chlorite  0.0509647191
+## 770                          Mgo         Hydrated Ca-sulfate -0.0469756049
+## 1925                        P205             Phyllosilicates -0.0464508867
+## 1873                        Na20       Other hydrated phases -0.0464224059
+## 2071                          Cl                    Chromite  0.0461245009
+## 2119                          Cl                    Ilmenite  0.0461245009
+## 2167                          Cl          Zircon/Baddeleyite  0.0461245009
+## 2263                          Cl                     Spinels  0.0461245009
+## 1165                       FeO-T                    Pyroxene  0.0444197638
+## 821                         P205                  Mg-sulfate -0.0437970729
+## 917                         P205      Hydrated Mg-Fe sulfate -0.0437970729
+## 2021                        P205 Kaolinite (hydrous Al-clay) -0.0437970729
+## 2213                        P205         Fe-Mg-clay minerals -0.0437970729
+## 875                        Cr203           Hydrated Sulfates -0.0413919341
+## 1308                         Mno             Fe-Mg carbonate  0.0410453946
+## 2076                         Mno                    Chromite  0.0410453946
+## 2124                         Mno                    Ilmenite  0.0410453946
+## 2172                         Mno          Zircon/Baddeleyite  0.0410453946
+## 2268                         Mno                     Spinels  0.0410453946
+## 771                        Al203         Hydrated Ca-sulfate -0.0392291425
+## 1105                        Na20                   Phosphate  0.0378650525
+## 245                         P205                         S03 -0.0361441396
+## 1946                     Olivine             Phyllosilicates -0.0354514839
+## 1125                Perchlorates                   Phosphate  0.0351003256
+## 1126              Na-perchlorate                   Phosphate  0.0351003256
+## 1752                   Phosphate         Hydrated Iron oxide  0.0351003256
+## 1592                         K20                 FeTi oxides  0.0338010251
+## 1834                        Ti02      Sulfate+Organic matter  0.0313958021
+## 1708             Fe-Mg carbonate                  Iron oxide -0.0307583126
+## 2103      Sulfate+Organic matter                    Chromite  0.0307583126
+## 2151      Sulfate+Organic matter                    Ilmenite  0.0307583126
+## 2199      Sulfate+Organic matter          Zircon/Baddeleyite  0.0307583126
+## 2295      Sulfate+Organic matter                     Spinels  0.0307583126
+## 438                          S03                        Ti02 -0.0299693508
+## 1833                         Cao      Sulfate+Organic matter  0.0297318305
+## 1108                        Si02                   Phosphate -0.0291546263
+## 1693                       FeO-T                  Iron oxide  0.0276058922
+## 1546                        Ti02                     Apatite -0.0271761233
+## 1641                         Cao                      Halite  0.0261667772
+## 586                         Ti02                       FeO-T  0.0255419671
+## 1637                        P205                      Halite -0.0247289595
+## 1545                         Cao                     Apatite  0.0246954087
+## 776                          K20         Hydrated Ca-sulfate  0.0220494888
+## 583                           Cl                       FeO-T  0.0193132908
+## 487                           Cl                       Cr203  0.0187969087
+## 1072                  Ca-sulfate          Amorphous Silicate -0.0181551635
+## 1695                     Sulfate                  Iron oxide  0.0169686624
+## 1802                     Olivine              Organic matter -0.0132179113
+## 685                        FeO-T                     Sulfate  0.0117397497
+## 1777                        Na20              Organic matter  0.0112376426
+## 1648                  Ca-sulfate                      Halite -0.0109206494
+## 532                         Si02                         Mno  0.0096880125
+## 291                        Al203                          Cl -0.0082296630
+## 1847          Amorphous Silicate      Sulfate+Organic matter  0.0072212049
+## 1587                       Al203                 FeTi oxides -0.0068630053
+## 964                         Si02                Perchlorates -0.0063788309
+## 1012                        Si02              Na-perchlorate -0.0063788309
+## 1732                        Si02         Hydrated Iron oxide -0.0063788309
+## 1176                   Phosphate                    Pyroxene  0.0061101824
+## 819                        Al203                  Mg-sulfate  0.0046028274
+## 915                        Al203      Hydrated Mg-Fe sulfate  0.0046028274
+## 2019                       Al203 Kaolinite (hydrous Al-clay)  0.0046028274
+## 2211                       Al203         Fe-Mg-clay minerals  0.0046028274
+## 1857                     Apatite      Sulfate+Organic matter  0.0038490873
+## 631                           Cl                 Plagioclase  0.0001588705
+## 1345                        Na20         Hydrated Carbonates            NA
+## 1346                         Mgo         Hydrated Carbonates            NA
+## 1347                       Al203         Hydrated Carbonates            NA
+## 1348                        Si02         Hydrated Carbonates            NA
+## 1349                        P205         Hydrated Carbonates            NA
+## 1350                         S03         Hydrated Carbonates            NA
+## 1351                          Cl         Hydrated Carbonates            NA
+## 1352                         K20         Hydrated Carbonates            NA
+## 1353                         Cao         Hydrated Carbonates            NA
+## 1354                        Ti02         Hydrated Carbonates            NA
+## 1355                       Cr203         Hydrated Carbonates            NA
+## 1356                         Mno         Hydrated Carbonates            NA
+## 1357                       FeO-T         Hydrated Carbonates            NA
+## 1358                 Plagioclase         Hydrated Carbonates            NA
+## 1359                     Sulfate         Hydrated Carbonates            NA
+## 1360                  Ca-sulfate         Hydrated Carbonates            NA
+## 1361         Hydrated Ca-sulfate         Hydrated Carbonates            NA
+## 1362                  Mg-sulfate         Hydrated Carbonates            NA
+## 1363           Hydrated Sulfates         Hydrated Carbonates            NA
+## 1364      Hydrated Mg-Fe sulfate         Hydrated Carbonates            NA
+## 1365                Perchlorates         Hydrated Carbonates            NA
+## 1366              Na-perchlorate         Hydrated Carbonates            NA
+## 1367          Amorphous Silicate         Hydrated Carbonates            NA
+## 1368                   Phosphate         Hydrated Carbonates            NA
+## 1369                    Pyroxene         Hydrated Carbonates            NA
+## 1370                     Olivine         Hydrated Carbonates            NA
+## 1371                   Carbonate         Hydrated Carbonates            NA
+## 1372             Fe-Mg carbonate         Hydrated Carbonates            NA
+## 1421         Hydrated Carbonates        Disordered Silicates            NA
+## 1469         Hydrated Carbonates                    Feldspar            NA
+## 1517         Hydrated Carbonates                      Quartz            NA
+## 1565         Hydrated Carbonates                     Apatite            NA
+## 1613         Hydrated Carbonates                 FeTi oxides            NA
+## 1661         Hydrated Carbonates                      Halite            NA
+## 1709         Hydrated Carbonates                  Iron oxide            NA
+## 1757         Hydrated Carbonates         Hydrated Iron oxide            NA
+## 1805         Hydrated Carbonates              Organic matter            NA
+## 1853         Hydrated Carbonates      Sulfate+Organic matter            NA
+## 1901         Hydrated Carbonates       Other hydrated phases            NA
+## 1949         Hydrated Carbonates             Phyllosilicates            NA
+## 1997         Hydrated Carbonates                    Chlorite            NA
+## 2045         Hydrated Carbonates Kaolinite (hydrous Al-clay)            NA
+## 2093         Hydrated Carbonates                    Chromite            NA
+## 2141         Hydrated Carbonates                    Ilmenite            NA
+## 2189         Hydrated Carbonates          Zircon/Baddeleyite            NA
+## 2237         Hydrated Carbonates         Fe-Mg-clay minerals            NA
+## 2285         Hydrated Carbonates                     Spinels            NA
+
# Reintroduce the abrasion column into the scaled matrix
+pixl_sherloc.scaledab <- cbind(pixl_sherloc.scaled, abrasion = pixl.df$abrasion)
+
+# Identify features (excluding 'abrasion')
+features <- colnames(pixl_sherloc.scaledab)[colnames(pixl_sherloc.scaledab) != "abrasion"]
+
+# Convert to data.frame and apply dplyr functions
+result <- as.data.frame(pixl_sherloc.scaledab) %>%
+    group_by(abrasion) %>%
+    summarise(across(all_of(features), sd, na.rm = TRUE)) %>%
+    mutate(avg_stdev = rowMeans(across(all_of(features)), na.rm = TRUE)) %>%
+    ungroup() %>%
+    mutate(abrasion = levels(pixl.df$abrasion)[abrasion])  # Convert numeric to factor names
+
## Warning: There was 1 warning in `summarise()`.
+## ℹ In argument: `across(all_of(features), sd, na.rm = TRUE)`.
+## ℹ In group 1: `abrasion = 1`.
+## Caused by warning:
+## ! The `...` argument of `across()` is deprecated as of dplyr 1.1.0.
+## Supply arguments directly to `.fns` through an anonymous function instead.
+## 
+##   # Previously
+##   across(a:b, mean, na.rm = TRUE)
+## 
+##   # Now
+##   across(a:b, \(x) mean(x, na.rm = TRUE))
+
# View the result
+print(result$abrasion)
+
## [1] "Alfalfa"       "Bellegrade"    "Berry Hollow"  "Dourbes"      
+## [5] "Guillaumes"    "Novarupta"     "Quartier"      "ThorntonGap"  
+## [9] "Uganik Island"
+
print(result$avg_stdev)
+
## [1] 0.0000000 0.2992339 0.0000000 0.2523823       NaN 0.0000000 0.0000000
+## [8] 0.0000000       NaN
+
# Create a data frame with abrasion levels and corresponding standard deviations
+table_data <- data.frame(Abrasion = result$abrasion, StdDev = result$avg_stdev)
+
+# Print the table
+print(table_data)
+
##        Abrasion    StdDev
+## 1       Alfalfa 0.0000000
+## 2    Bellegrade 0.2992339
+## 3  Berry Hollow 0.0000000
+## 4       Dourbes 0.2523823
+## 5    Guillaumes       NaN
+## 6     Novarupta 0.0000000
+## 7      Quartier 0.0000000
+## 8   ThorntonGap 0.0000000
+## 9 Uganik Island       NaN
+
pixl.df$abrasion
+
##  [1] Guillaumes    Bellegrade    Bellegrade    Dourbes       Dourbes      
+##  [6] Quartier      Quartier      Alfalfa       Alfalfa       ThorntonGap  
+## [11] ThorntonGap   Berry Hollow  Berry Hollow  Novarupta     Novarupta    
+## [16] Uganik Island
+## 9 Levels: Alfalfa Bellegrade Berry Hollow Dourbes Guillaumes ... Uganik Island
+

Both clustering algorithms split up the same two abbrasions: +Bellegrade and Dourbes. This begs the question of why these ones are +inconsistent while the rest are consistent. I believe all 4 samples are +igneous.

+
test <- cbind(pixl.matrix, sherloc.matrix)
+num_duplicates_combined <- sum(duplicated(test))
+print(paste("Number of duplicate rows in the combined matrix:", num_duplicates_combined))
+
## [1] "Number of duplicate rows in the combined matrix: 5"
+
num_duplicates_pixl <- sum(duplicated(pixl.matrix))
+print(paste("Number of duplicate rows in pixl.matrix:", num_duplicates_pixl))
+
## [1] "Number of duplicate rows in pixl.matrix: 7"
+
num_duplicates_sherloc <- sum(duplicated(sherloc.matrix))
+print(paste("Number of duplicate rows in sherloc.matrix:", num_duplicates_sherloc))
+
## [1] "Number of duplicate rows in sherloc.matrix: 7"
+

It turns out 5 of our data points are duplicates. Additionally, only +looking at SHERLOC or PIXL individually, 7 are duplicates. Begs the +question of why these are duplicated. THey are from the same abbrasions, +but surely noise would change the measurements?

+
+
+

5 Preparation of Team +Presentation (Part 4)

+

Prepare a presentation of your teams result to present in class on +September 11 starting at 9am in AE217 (20 pts) The +presentation should include the following elements

+

0.Your teams names and members 1. A Description of +the data set that you analyzed including how many observations and how +many features. (<= 1.5 mins) 2. Each team member gets three +minutes to explain their analysis: * what analysis they +performed * the results of that analysis * a brief discussion of their +interpretation of these results * <= 18 mins total! 3. A +Conclusion slide indicating major findings of the teams +(<= 1.5 mins) 4. Thoughts on potential next steps +for the MARS team (<= 1.5 mins)

+ +

https://docs.google.com/document/d/1-4o1O4h2r8aMjAplmE-ItblQnyDAKZwNs5XCnmwacjs/pub

+
    +
  • Post a link to your teams presentation in the MARS webex chat before +class. You can continue to edit until the last minute.
  • +
+
+
+

6 When you’re done: SAVE, +COMMIT and PUSH YOUR CHANGES!

+

When you are satisfied with your edits and your notebook knits +successfully, remember to push your changes to the repo using the +following steps:

+
    +
  • git branch +
      +
    • To double-check that you are in your working branch
    • +
  • +
  • git add <your changed files>
  • +
  • git commit -m "Some useful comments"
  • +
  • git push origin <your branch name>
  • +
  • do a pull request
  • +
+
+
+

7 APPENDIX: Accessing +RStudio Server on the IDEA Cluster

+

The IDEA Cluster provides seven compute nodes (4x 48 cores, 3x 80 +cores, 1x storage server)

+
    +
  • The Cluster requires RCS credentials, enabled via registration in +class +
      +
    • email John Erickson for problems erickj4@rpi.edu
    • +
  • +
  • RStudio, Jupyter, MATLAB, GPUs (on two nodes); lots of storage and +computes
  • +
  • Access via RPI physical network or VPN only
  • +
+
+
+

8 More info about Rstudio +on our Cluster

+
+

8.1 RStudio GUI +Access:

+ +
+
+ + + + +
+ + + + + + + + + + + + + + +