Erin-Rooney/Y1_fairbanks

Unique peaks check

Erin-Rooney opened this issue · 3 comments

@kaizadp

Here is the fairbanks code for the unique peaks. Can you double check it for correctness?

Thanks!!

fticr_water_slopepos_unique =
fticr_data_water_summarized %>%
# calculate n to see which peaks were unique vs. common
group_by(formula, cover_type, plot) %>%
dplyr::mutate(n = n()) %>%
# n = 1 means unique to CON or FTC Trtmt
# n = 2 means common to both
filter(n == 1) %>%
mutate(uniquepeak = case_when(slopepos == 'Backslope' ~ "backslope",
slopepos == 'Low Backslope' ~ "low backslope",
slopepos == 'Footslope' ~ "footslope")) %>%
left_join(meta_hcoc_water) %>%
mutate(slopepos = factor (slopepos, levels = c("Backslope", "Low Backslope", "Footslope")))

The problem was here:

fticr_data_water_summarized =
fticr_water %>%
distinct(ID, slopepos, cover_type, plot, formula) %>% mutate(presence = 1)

fticr_data_water_summarized represents peaks present within each "treatment", not individual samples. So you don't want to include ID in your grouping.

fticr_data_water_summarized = 
  fticr_water %>% 
  distinct(slopepos, cover_type, plot, formula) %>% mutate(presence = 1)

I tried a Van Krevelen to confirm, and I now get unique peaks across all slope positions.

image

I see some redundancies in your processing code, I'm going to run through everything and add some notes here.

Also, you jump straight into NOSC for your analysis. I would recommend starting out larger scale for an exploratory analysis first. Do Van Krevelens, PCA, etc. before diving into NOSC for unique peaks. You may lose important pieces of the story if you skip the exploratory data analysis.

I actually did van krevelen's first but forgot to put that code.

# this does only unique loss/gain by open vs. canopy
fticr_water_covertype_unique =
fticr_data_water_summarized %>%
# calculate n to see which peaks were unique vs. common
group_by(formula, slopepos, plot) %>%
dplyr::mutate(n = n()) %>%
# n = 1 means unique to CON or FTC Trtmt
# n = 2 means common to both
filter(n == 1) %>%
#PROBLEMS START NOW
mutate(loss_gain = if_else(cover_type == "Open", "open", "Canopy")) %>%
left_join(meta_hcoc_water) %>%
mutate(slopepos = factor (slopepos, levels = c("Backslope", "Low Backslope", "Footslope")))
fticr_water_covertype_unique_common =
fticr_data_water_summarized %>%
# calculate n to see which peaks were unique vs. common
group_by(formula, slopepos, cover_type) %>%
dplyr::mutate(n = n()) %>%
# n = 1 means unique to CON or FTC Trtmt
# n = 2 means common to both
# filter(n == 1) %>%
mutate(loss_gain = case_when(n == 2 ~ "common",
(n == 1 & cover_type == "Open") ~ "open",
(n == 1 & cover_type == "Canopy") ~ "canopy")) %>%
left_join(meta_hcoc_water) %>%
mutate(slopepos = factor (slopepos, levels = c("Backslope", "Low Backslope", "Footslope")))

I think it's the same issue there:

fticr_data_water_summarized =
fticr_water %>%
distinct(ID, slopepos, cover_type, plot, formula) %>% mutate(presence = 1)

I think I understand the corrections but it would still be good to go over them tomorrow at our meeting.