loretopaulinojr / Lifestyle

0 stars 0 forks source link

Polaris Project, finish it. #4

Closed loretopaulinojr closed 7 months ago

loretopaulinojr commented 8 months ago

How I have looked into the data.

loretopaulinojr commented 7 months ago

GIS Pro Mapping Protocol

Instructions for Using ArcGIS Pro

To follow the mapping protocol, refer to the detailed documentation provided in Protocol for Mapping your Streams using ArcGIS Pro.docx.

Accessing ArcGIS Pro

Upon reviewing the document, I obtained access to ArcGIS Pro with assistance from Nigel and Greg, who facilitated the licensing process. Since I utilized a MacBook, I ran the platform on my laptop using Parallels. Note that my trial period will conclude on December 5, 2023.

Addressing the Initial Issue

The first challenge encountered was the inability to generate a Digital Elevation Model (DEM) using my own location points. The data input resulted in an unexpected format, displayed below:

Image

This issue was resolved by obtaining data points through Google Map Pro. By inputting my location data into Google Pro and expanding the area to include more points, I retrieved data in a .kml file format. It was essential to convert this file into a .gmx format while ensuring that elevation data was preserved.

Overcoming the Challenge

Utilizing the Kiriging spatial analyst tool, I successfully created an elevation map, as illustrated below:

Image

Feel free to reach out if you have any questions or need further assistance with the GIS Pro mapping process.

loretopaulinojr commented 7 months ago

The Method Used to Calculate the Value of Q (m^3/s)

Float_area_method.pdf

Multiply the values the correlates with the location of the discharge value (That is because we only collected discharge values for certain locations). When done so the units look like mass of analyze over that of seconds.

loretopaulinojr commented 7 months ago

ArcGIS Pro Issues

I utilized the NAD 1983 map projection in ArcGIS Pro, which may be a contributing factor to the issues encountered during the mapping process.

Image

Step 7 - Stream to Feature

During Step 7, using the Stream to Feature tool resulted in displaying only one solid color, indicating a mistake. This issue may be attributed to Step 6, where the outcome was as follows:

Image

It is possible that the low-quality map contributed to this problem. To create the map, I utilized Google Earth Pro due to the apparent lack of necessary data in open sources like USGS and Alaska's elevation data for the specific area.

Even in step 6, as you can see from the picture above the locations are not on the lines that supposedly is the river network.

loretopaulinojr commented 7 months ago

Finished the First Set of Protocol

Image Image

loretopaulinojr commented 7 months ago

Facundo's Paper

Abstract Notes

it discusses the impact of beaver populations on carbon dioxide (CO2) and methane (CH4) emissions in aquatic ecosystems, particularly in the boreal biome of North America. Here's a summary of the key points:

Beaver Population Recovery

Emission Hotspots

Uncertainty in Carbon Budgets

Study Location

Beaver Pond Coverage

Contribution to Carbon Emissions

Future Projections

Climate Change Feedback Loop

loretopaulinojr commented 7 months ago

Further Reading

Facundo's paper units are shown below:

Screenshot 2023-11-29 at 3 12 36 PM Screenshot 2023-11-29 at 3 13 03 PM
loretopaulinojr commented 7 months ago

Using Similar Analysis to Previous Polaris Participant

The Author was Ellen Bradley.

Screenshot 2023-11-29 at 3 16 53 PM
loretopaulinojr commented 7 months ago

Analysis

Water Calculations

From the Water Calculations: Nothing because it's already in concentration values. You can look into it as soon as possible. Ask mentors for their thoughts.

Water Calculations

Gas Samples

The values are in ppm, which is equal to mg/L.

You collected a x ml value in the field; convert it to L to cancel out the liters. Also, have discharge values in the unit m^3/s, which can be converted to dm^3/s to cancel out the liters.

Convert values to per day instead of per second.

Ask if this value is feasible to work with.

loretopaulinojr commented 7 months ago

Notes from the meeting, consider distance and location.

NPOC - Gases, -> Ebulitions conversions.

loretopaulinojr commented 7 months ago

All Boxplots and Packages Given By Nigel and GOOMBRA

library(knitr)      #functions for producing a report of this data analysis
library(tidyverse)  #functions for manipulating, formating, and plotting
library(car)        #functions that complements regression analysis
library(MASS)       #functions useful for estimating linear models      
library(lme4)       #functions for fitting and analyzing mixed models
library(lubridate)  #functions for reading in dates and times
library(hms)        #functions for extracting time  
library(psych)      #functions for provides functions to calculate and visualize correlation matrices, data visualization, and descriptive statistics  
library(ggplot2)    #functions for communicating complex data insights visually
library(AICcmodavg) #functions for running AIC and QAIC
library(vegan)      #functions for analyzing community ecology data
library(tidyverse)  #functions for data manipulation, visualization, and analysis
library(janitor)    #functions for functions to clean, transform, and summarize data
library(vegan)      #functions for plotting vegan outputs
library(magrittr)
library(readxl)
library(dplyr)
library(tidyr)

# Plot for NPOC_mg_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = NPOC_mg_L, fill = Category_2)) +
  geom_boxplot() +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position="none") +  # Remove legend
  labs(x = NULL, y = "NPOC mg/L")  # Remove x-axis label, set y-axis label

# Assuming BeaverNetwork2023Final is your dataset
# Assuming 'Category_2' is the column name for the x-axis

# Plot for NH4_ug_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = NH4_ug_L, fill = Category_2)) +
  geom_boxplot() +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "NH4 ug/L")

# Plot for PO4_ug_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = PO4_ug_L, fill = Category_2)) +
  geom_boxplot() +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "PO4 ug/L")

# Plot for SiO2_ug_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = SiO2_mg_L, fill = Category_2)) +
  geom_boxplot() +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "SiO2 mg/L")

# Plot for TN_mg_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = TN_mg_L, fill = Category_2)) +
  geom_boxplot() +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "TN mg/L")

# Plot for DO_percent
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = DO_percent, fill = Category_2)) +
  geom_boxplot() +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "DO percent")

# Plot for DO_mgL
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = DO_mgL, fill = Category_2)) +
  geom_boxplot() +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "DO mg/L")

# Plot for pH
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = pH, fill = Category_2)) +
  geom_boxplot() +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "pH")
loretopaulinojr commented 7 months ago

1

loretopaulinojr commented 7 months ago
#ANOVA TESTs

#ANOVA NPOC

anova_resultNPOC <- aov(NPOC_mg_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultNPOC)

# P value = 0.608

#ANOVA NH4 
anova_resultNH4 <- aov(NH4_ug_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultNH4)

# P value = 0.0124

#ANOVA PO4
anova_resultPO4 <- aov(PO4_ug_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultPO4)

# P value = 0.825

#ANOVA SiO2_mg_L
anova_resultSiO2 <- aov(SiO2_mg_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultSiO2)

# P value = 0.41

#ANOVA TN_mg_L
anova_resultTN <- aov(TN_mg_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultTN)

# P value = 0.889

#ANOVA DO %
anova_resultDOpercent <- aov(DO_percent ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultDOpercent)

# P value = 0.748

#ANOVA DO_mgL
anova_resultDOmgL <- aov(DO_mgL ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultDOmgL)

# P value = 0.545

#ANOVA pH

anova_resultpH <- aov(pH ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultpH)

# P value = 0.114
loretopaulinojr commented 7 months ago
#Turkey Test on NH4
tukey_testNH4 <- TukeyHSD(anova_resultNH4)
print(tukey_testNH4)

Results

Screenshot 2023-12-02 at 8 10 00 PM
loretopaulinojr commented 7 months ago

Finds an outlier and put NA in it

# Define a function to filter out outliers based on a quantile threshold
remove_outliers <- function(x) {
  quantile_val <- quantile(x, c(0.25, 0.75))
  iqr <- IQR(x)
  lower_bound <- quantile_val[1] - 1.5 * iqr
  upper_bound <- quantile_val[2] + 1.5 * iqr
  return(ifelse(x < lower_bound | x > upper_bound, NA, x))
}

# Apply the function to 'NPOC_mg_L' within the 'BP' category
BeaverNetwork2023Final_filtered3 <- BeaverNetwork2023Final %>%
  group_by(Category_2) %>%
  mutate(NPOC_mg_L = ifelse(Category_2 == "BP", remove_outliers(NPOC_mg_L), NPOC_mg_L))
loretopaulinojr commented 7 months ago

AGU_poster_Loreto_Paulino.pdf

loretopaulinojr commented 7 months ago

Final Coding

library(knitr)      #functions for producing a report of this data analysis
library(tidyverse)  #functions for manipulating, formating, and plotting
library(car)        #functions that complements regression analysis
library(MASS)       #functions useful for estimating linear models      
library(lme4)       #functions for fitting and analyzing mixed models
library(lubridate)  #functions for reading in dates and times
library(hms)        #functions for extracting time  
library(psych)      #functions for provides functions to calculate and visualize correlation matrices, data visualization, and descriptive statistics  
library(ggplot2)    #functions for communicating complex data insights visually
library(AICcmodavg) #functions for running AIC and QAIC
library(vegan)      #functions for analyzing community ecology data
library(tidyverse)  #functions for data manipulation, visualization, and analysis
library(janitor)    #functions for functions to clean, transform, and summarize data
library(vegan)      #functions for plotting vegan outputs
library(magrittr)
library(readxl)
library(dplyr)
library(tidyr)

BeaverNetwork2023Final<- BeaverNetwork2023Final %>% 
  mutate(across(where(is.character), as.factor))

# Define a function to filter out outliers based on a quantile threshold
remove_outliers <- function(x) {
  quantile_val <- quantile(x, c(0.25, 0.75))
  iqr <- IQR(x)
  lower_bound <- quantile_val[1] - 1.5 * iqr
  upper_bound <- quantile_val[2] + 1.5 * iqr
  return(ifelse(x < lower_bound | x > upper_bound, NA, x))
}

# Apply the function to 'NPOC_mg_L' within the 'BP' category
BeaverNetwork2023Final_filtered3 <- BeaverNetwork2023Final %>%
  group_by(Category_2) %>%
  mutate(NPOC_mg_L = ifelse(Category_2 == "BP", remove_outliers(NPOC_mg_L), NPOC_mg_L))

# Plot for NPOC_mg_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = NPOC_mg_L, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position="none") +  # Remove legend
  labs(x = NULL, y = "NPOC mg/L")  # Remove x-axis label, set y-axis label

# Plot for NH4_ug_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = NH4_ug_L, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "NH4 ug/L")

# Plot for PO4_ug_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = PO4_ug_L, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "PO4 ug/L")

# Plot for SiO2_mg_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = SiO2_mg_L, fill = Category_2)) +
  geom_boxplot() + stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "SiO2 mg/L")

# Plot for TN_mg_L
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = TN_mg_L, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "TN mg/L")

# Plot for DO_percent
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = DO_percent, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "DO %")

# Plot for DO_mgL

DO_ugL <- BeaverNetwork2023Final$DO_mgL * 1000

ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = DO_ugL, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "DO ug/L")

# Plot for pH
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = pH, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "pH")

# Plot for Temperature
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = Temperature_C, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "°C")

# Plot for Cl_A
ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = ChlA_ppb_Rhodamine_avg, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position = "none") +
  labs(x = NULL, y = "ChlA ppb")

#ANOVA TESTs

#ANOVA NPOC

anova_resultNPOC <- aov(NPOC_mg_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultNPOC)

# P value = 0.608

#ANOVA NH4 
anova_resultNH4 <- aov(NH4_ug_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultNH4)

# P value = 0.0124

#ANOVA PO4
anova_resultPO4 <- aov(PO4_ug_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultPO4)

# P value = 0.825

#ANOVA SiO2_mg_L
anova_resultSiO2 <- aov(SiO2_mg_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultSiO2)

# P value = 0.41

#ANOVA TN_mg_L
anova_resultTN <- aov(TN_mg_L ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultTN)

# P value = 0.889

#ANOVA DO %
anova_resultDOpercent <- aov(DO_percent ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultDOpercent)

# P value = 0.748

#ANOVA DO_mgL
anova_resultDOmgL <- aov(DO_mgL ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultDOmgL)

# P value = 0.545

#ANOVA pH

anova_resultpH <- aov(pH ~ Category_2, data = BeaverNetwork2023Final)
summary(anova_resultpH)

# P value = 0.114

#Turkey Test

#Turkey Test on NH4
tukey_testNH4 <- TukeyHSD(anova_resultNH4)
print(tukey_testNH4)

# NPOC change to ug/L

NPOCtougL <- BeaverNetwork2023Final$NPOC_mg_L * 1000

ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = NPOCtougL, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position="none") +  # Remove legend
  labs(x = NULL, y = "NPOC ug/L")  # Remove x-axis label, set y-axis label

# TN change to ug/L

TNtougL <- BeaverNetwork2023Final$TN_mg_L * 1000

ggplot(BeaverNetwork2023Final, aes(x = Category_2, y = TNtougL, fill = Category_2)) +
  geom_boxplot() +
  stat_summary(
    fun = mean, 
    geom = "point", 
    shape = 18, 
    size = 3, 
    color = "red", 
    position = position_dodge(width = 0.75)
  ) +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824", "#03396c")) +
  theme(legend.position="none") +  # Remove legend
  labs(x = NULL, y = "TN ug/L")  # Remove x-axis label, set y-axis label

# Bar graph of NH4 in 3 specific sites

ggplot(subset(BeaverNetwork2023Final, Category_2 %in% c("DSM")), aes(x =  reorder(Site, desc(NH4_ug_L)), y = NH4_ug_L, fill = Site)) +
  geom_bar(stat = "identity", position = position_dodge2(0.9)) +
  theme(legend.position = "none") + 
  labs(x = NULL, y = "NH4 ug/L") +
  scale_fill_manual(values = c("#41ae76","#03396c","#66c2a5"))

# Site Bar graphs

# Assuming your data frame is called BeaverNetwork2023Final
agg_dataTN <- BeaverNetwork2023Final %>%
  filter(Category_2 %in% c("BP", "BPSM", "SMALK", "LK")) %>%
  group_by(Category_2) %>%
  summarise(mean_TN_mg_L = mean(as.numeric(TN_mg_L), na.rm = TRUE),
            sd_TN_mg_L = sd(as.numeric(TN_mg_L), na.rm = TRUE),
            count = n())

ggplot(agg_dataTN, aes(x = Category_2, y = mean_TN_mg_L, fill = Category_2)) +
  geom_col() +
  theme(legend.position = "none") +
  geom_errorbar(aes(ymin = mean_TN_mg_L - sd_TN_mg_L / sqrt(count),
                    ymax = mean_TN_mg_L + sd_TN_mg_L / sqrt(count)),
                position = position_dodge(0.9),
                width = 0.25) +
  labs(x = NULL, y = "TN mg/L") +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824"))

#NH4

agg_dataNH4 <- BeaverNetwork2023Final %>%
  filter(Category_2 %in% c("BP", "BPSM", "SMALK", "LK")) %>%
  group_by(Category_2) %>%
  summarise(mean_NH4_ug_L = mean(as.numeric(NH4_ug_L), na.rm = TRUE),
            sd_NH4_ug_L = sd(as.numeric(NH4_ug_L), na.rm = TRUE),
            count = n()) %>%
  ungroup()

ggplot(agg_data, aes(x = Category_2, y = mean_NH4_ug_L, fill = Category_2)) +
  geom_col() +
  theme(legend.position = "none") +
  geom_errorbar(aes(ymin = mean_NH4_ug_L - sd_NH4_ug_L / sqrt(count),
                    ymax = mean_NH4_ug_L + sd_NH4_ug_L / sqrt(count)),
                position = position_dodge(0.9),
                width = 0.25) +
  labs(x = NULL, y = "NH4 ug/L") +
  scale_fill_manual(values = c("#66c2a5", "#41ae76", "#238b45", "#005824"))