getBioMatches: Biological and Chemistry data matches.

Description Usage Arguments Details Value Examples

View source: R/getBioMatches.R

Description

Get Biological (Algae or BMI) samples and chemistry sample matches.

Usage

1
2
getBioMatches(stressors, list.data, list.SiteSummary, data.SampSummary,
  data.chem.raw, data.bio.metrics, biocomm = "BMI")

Arguments

stressors

stressors

list.data

data list

list.SiteSummary

Site summary data; output of getSiteInfo function.

data.SampSummary

x

data.chem.raw

x

data.bio.metrics

Biological metric data (algae or BMI).

biocomm

Biological community; algae or BMI. Default = "BMI"

Details

Matched biological (algae/BMI) and chem samples.

Required objects:

* data.SampSumamry; StationID_Master, CollDate, ChemSampleID, PhabSampID, BMI.Metrics.SampID, Algae.Metrics.SampID

* data.chem.raw; StationID_Master, ChemSampleID

Value

A summary list; all.b.str, cl.b.str, site.b.str, all.b.rsp, cl.b.rsp , and site.b.rsp.

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Example 1, BMI
TargetSiteID <- "SRCKN001.61"
dir_results <- file.path(getwd(), "Results")

# Data getSiteInfo
# data, example included with package
data.Stations.Info <- data_Sites        # need for getSiteInfo and getChemDataSubsets
data.SampSummary   <- data_SampSummary
data.303d.ComID    <- data_303d
data.bmi.metrics   <- data_BMIMetrics
data.algae.metrics <- data_AlgMetrics
data.cluster       <- data_Cluster_Hi   # need for getSiteInfo and getChemDataSubsets
data.mod           <- data_ReachMod

#' #' # Cluster based on elevation category  # need for getSiteInfo and getChemDataSubsets
elev_cat <- toupper(data.Stations.Info[data.Stations.Info[,"StationID_Master"]
                    ==TargetSiteID, "ElevCategory"])
if(elev_cat=="HI"){
   data.cluster <- data_Cluster_Hi
} else if(elev_cat=="LO") {
   data.cluster <- data_Cluster_Lo
}

# Map data
# San Diego
#flowline <- rgdal::readOGR(dsn = "data_gis/NHDv2_Flowline_Ecoreg85", layer = "NHDv2_eco85_Project")
#outline <- rgdal::readOGR(dsn = "data_gis/Eco85", layer = "Ecoregion85")
# AZ
map_flowline  <- data_GIS_Flow_HI
map_flowline2 <- data_GIS_Flow_LO
if(elev_cat=="HI"){
   map_flowline <- data_GIS_Flow_HI
} else if(elev_cat=="LO") {
   map_flowline <- data_GIS_Flow_LO
}
map_outline   <- data_GIS_AZ_Outline
# Project site data to USGS Albers Equal Area
usgs.aea <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23
              +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83
              +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"
# projection for outline
my.aea <- "+proj=aea +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 
           +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"
map_proj <- my.aea
#
dir_sub <- "SiteInfo"

# Run getSiteInfo
list.SiteSummary <- getSiteInfo(TargetSiteID, dir_results, data.Stations.Info
                                , data.SampSummary, data.303d.ComID
                                , data.bmi.metrics, data.algae.metrics
                                , data.cluster, data.mod
                                , map_proj, map_outline, map_flowline
                                , dir_sub=dir_sub)

# Data getChemDataSubsets
site.COMID <- list.SiteSummary$COMID
site.Clusters <- list.SiteSummary$ClustIDs
# data, example included with package
data.chem.raw <- data_Chem
data.chem.info <- data_ChemInfo

# Run getChemDataSubsets
list.data <- getChemDataSubsets(TargetSiteID, comid=site.COMID, cluster=site.Clusters
                                , data.cluster=data.cluster, data.Stations.Info=data.Stations.Info
                                , data.chem.raw=data.chem.raw, data.chem.info=data.chem.info)

# Data getStressorList
chem.info <- list.data$chem.info
cluster.chem <- list.data$cluster.chem
cluster.samps <- list.data$cluster.samps
ref.sites <- list.data$ref.sites
site.chem <- list.data$site.chem

# set cutoff for possible stressor identification
probsLow <- 0.10
probsHigh <- 0.90 
#
dir_sub <- "SiteInfo"

# Run getStressorList
list.stressors <- getStressorList(TargetSiteID, site.Clusters, chem.info, cluster.chem
                                 , cluster.samps, ref.sites, site.chem
                                 , probsHigh, probsLow, dir_sub)
                                 
# Data getBioMatches
## remove "none"
stressors <- list.stressors$stressors[list.stressors$stressors != "none"]

# Run getBioMatches
biocomm <- "BMI"
data.bio.metrics <- data_BMIMetrics
list.MatchBioData <- getBioMatches(stressors, list.data, list.SiteSummary, data.SampSummary
                                   , data.chem.raw, data.bio.metrics, biocomm)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Example 2, Algae
TargetSiteID <- "LCBEN002.57"
dir_results <- file.path(getwd(), "Results")

# Data getSiteInfo
# data, example included with package
data.Stations.Info <- data_Sites        # need for getSiteInfo and getChemDataSubsets
data.SampSummary   <- data_SampSummary
data.303d.ComID    <- data_303d
data.bmi.metrics   <- data_BMIMetrics
data.algae.metrics <- data_AlgMetrics
data.mod           <- data_ReachMod

# Cluster based on elevation category  # need for getSiteInfo and getChemDataSubsets
elev_cat <- toupper(data.Stations.Info[data.Stations.Info[,"StationID_Master"]==TargetSiteID
                    , "ElevCategory"])
if(elev_cat=="HI"){
   data.cluster <- data_Cluster_Hi
} else if(elev_cat=="LO") {
   data.cluster <- data_Cluster_Lo
}

# Map data
# San Diego
#flowline <- rgdal::readOGR(dsn = "data_gis/NHDv2_Flowline_Ecoreg85", layer = "NHDv2_eco85_Project")
#outline <- rgdal::readOGR(dsn = "data_gis/Eco85", layer = "Ecoregion85")
# AZ
map_flowline  <- data_GIS_Flow_HI
map_flowline2 <- data_GIS_Flow_LO
if(elev_cat=="HI"){
   map_flowline <- data_GIS_Flow_HI
} else if(elev_cat=="LO") {
   map_flowline <- data_GIS_Flow_LO
}
map_outline   <- data_GIS_AZ_Outline
# Project site data to USGS Albers Equal Area
usgs.aea <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23
              +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83
              +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"
# projection for outline
my.aea <- "+proj=aea +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 
           +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"
map_proj <- my.aea
#
dir_sub <- "SiteInfo"

# Run getSiteInfo
list.SiteSummary <- getSiteInfo(TargetSiteID, dir_results, data.Stations.Info
                                , data.SampSummary, data.303d.ComID
                                , data.bmi.metrics, data.algae.metrics
                                , data.cluster, data.mod
                                , map_proj, map_outline, map_flowline
                                , dir_sub=dir_sub)

# Data getChemDataSubsets
# data, example included with package
data.chem.raw <- data_Chem
data.chem.info <- data_ChemInfo
site.COMID <- list.SiteSummary$COMID
site.Clusters <- list.SiteSummary$ClustIDs

# Run getChemDataSubsets
list.data <- getChemDataSubsets(TargetSiteID, comid=site.COMID, cluster=site.Clusters
                                , data.cluster=data.cluster, data.Stations.Info=data.Stations.Info
                                , data.chem.raw=data.chem.raw, data.chem.info=data.chem.info)

# Data getStressorList
chem.info <- list.data$chem.info
cluster.chem <- list.data$cluster.chem
cluster.samps <- list.data$cluster.samps
ref.sites <- list.data$ref.sites
site.chem <- list.data$site.chem
dir_sub <- "CandidateCauses"

# set cutoff for possible stressor identification
probsLow <- 0.10
probsHigh <- 0.90 
biocomm <- "bmi"

# Run getStressorList
list.stressors <- getStressorList(TargetSiteID, site.Clusters, chem.info, cluster.chem
                                 , cluster.samps, ref.sites, site.chem
                                 , probsHigh, probsLow biocomm, dir_results
                                 , dir_sub)
                                 
# Data getBioMatches
## remove "none"
stressors <- list.stressors$stressors[list.stressors$stressors != "none"]

# Run getBioMatches
biocomm <- "algae"
data.bio.metrics <- data_AlgMetrics
list.MatchBioData <- getBioMatches(stressors, list.data, list.SiteSummary, data.SampSummary
                                   , data.chem.raw, data.bio.metrics, biocomm)

leppott/CASTfxn documentation built on Sept. 6, 2019, 11:04 p.m.