Join WQP data with the TADA criteria table - #965
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
for more information, see https://pre-commit.ci
This comment was marked as resolved.
This comment was marked as resolved.
add new test using the example Data_Nutrients_UT data
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…m/USEPA/EPATADA into join-wqp-data-with-criteria-table
for more information, see https://pre-commit.ci
…e in TADA_DefineCriteriaMethodology in test
…iteria include flags for case in which the AUMLRef or AU_UsesRef contain values that are not a match when compared to the criteria table.
for more information, see https://pre-commit.ci
|
@cristinamullin @hillarymarler This is ready for review |
|
@wokenny13 I tried to run your example in the PR description and ran into this error: > Data_Nutrients_UT2 <- TADA_RunKeyFlagFunctions(Data_Nutrients_UT)
All characteristic/fraction combinations are valid in your dataframe. Returning input dataframe with TADA.SampleFraction.Flag column for tracking.
TADA_FlagSpeciation: Rows with Suspect speciations have been flagged but retained. Review these rows using the new TADA.MethodSpeciation.Flag column before proceeding and/or set clean = 'suspect_only' or 'both'.
> Data_Nutrients_UT_Harmonized <- TADA_HarmonizeSynonyms(Data_Nutrients_UT2)
Warning: Your dataframe contains suspect metadata combinations in the following flag columns:
Flag_Column Result Count
1 TADA.MethodSpeciation.Flag 4
2 TADA.ResultUnit.Flag 4
> UTAH_Criteria <- TADA_DefineCriteriaMethodology(Data_Nutrients_UT_Harmonized, org_id = "UTAHDWQ", auto_assign = TRUE, displayUniqueId = TRUE)
TADA_DefineCriteriaMethodology: auto_assign = TRUE was selected but no MLSummaryRef. Generating TADA_MLSummary with default assignment.
TADA_DefineCriteriaMethodology: auto_assign = TRUE was selected. Running TADA_ParametersForAnalysis with default assignment.
TADA_DefineCriteriaMethodology: auto_assign = TRUE was selected. Running TADA_UsesForAnalysis with default assignment.
TADA_UsesForAnalysis:
NAs were found in ATTAINS.ParameterName.
Please ensure that you have inputted all field values of interest in
the ATTAINS.ParameterName column generated from TADA_ParametersForAnalysis() function.
TADA_UsesForAnalysis: auto_assign == TRUE was selected,
assigning all unique ATTAINS.UseName, by ATTAINS.OrganizationIdentifier, to any ATTAINS.ParameterName that an
organization have not done assessments for in prior ATTAINS cycle. Please review carefully and Exclude rows as needed.
TADA_DefineCriteriaMethodology: auto_assign = TRUE was selected.
Finding an alias match between ATTAINS parameter name and Criteria Search Tool (CST) standardized pollutant names.
Finding an alias match between ATTAINS use name and Criteria Search Tool (CST) uses.
If an ATTAINS.ParameterName and ATTAINS.UseName alias was found, populating these rows with the CST magnitude values.
A many-to-many match is likely. User review is needed to ensure accuracy in crosswalk method.
Warning in TADA_DefineCriteriaMethodology: There are 2 TADA.CharacteristicName units that do not match with the CST autoassign MagnitudeUnit values. Converting these MagnitudeUnit Values from the CST to match the TADA.ResultMeasure.MeasureUnitCode in your dataframe. Please review these conversions.
Warning message:
In TADA_MLSummary(.data, displayNA = TRUE, org_id = org_id, usesRef = TADA_usesRef, :
TADA_MLSummary: displayNA = TRUE was selected: Too many sites or uses and parameters. Cannot assign all uses and parameters to each monitoring sites in the output. Defaulting to displayNA = FALSE
> UTAH_with_criteria <- TADA_Analysis_Join_WQP_Criteria(Data_Nutrients_UT_Harmonized, UTAH_Criteria)
Error in TADA_Analysis_Join_WQP_Criteria(Data_Nutrients_UT_Harmonized, :
is.data.frame(criteria) is not TRUE
Called from: TADA_Analysis_Join_WQP_Criteria(Data_Nutrients_UT_Harmonized,
UTAH_Criteria) |
Hi Cristina, the output of TADA_DefineCriteriaMethodology now has 3 df, so this line should be updated below: UTAH_Criteria <- TADA_DefineCriteriaMethodology(Data_Nutrients_UT_Harmonized, org_id = "UTAHDWQ", auto_assign = TRUE, displayUniqueId = TRUE)[[1]] |
for more information, see https://pre-commit.ci
includes the CRITERIATYPE_WATERORG crosswalk for ATTAINS Use Groups to help narrow the list down to better likely matches.
for more information, see https://pre-commit.ci
|
The ATTAINS and CST uses crosswalk function, TADA_GetTADAUsesAliasRef, needs review/edits. Too many rows are being generated with the auto assign method. Currently, for the ATTAINS.UseName there is also a UseGroup that these uses would fall under. The CST has an Aquatic Life or Human Health indicator column. If a CST use is NA for that Aquatic Life or Human Health indicator column or if that ATTAINS.UseName is NA, it will get assigned to all unique CST uses. For example, this means many CST uses are getting matched to "Domestic Source" for UT even though they are not all related to domestic source...
To do:
|
|
I compared the "like match" method currently used in TADA vs Greg's table. Greg's table after filtering only had 156 ATTAINS Uses that matched to CST Uses (filtering out NAs, filtering out any changes in ATTAINS.Uses domain as well as CST uses domain.) From there, the TADA method was able to match 147 out of those 156 matches in Greg's table. The TADA method is looking at % like matches to avoid any manual review needed, and the tolerance is meant to be adjustable. TADA identifies 7,708 close matches out of the 17281 total matches. The remaining 10k matches are based on the Human health/Aquatic Life and Organism & water or water only indicator crosswalk of ATTAINS Use Groups.
|
…re kept this approval list is further filtered down by an entity match. As the entity crosswalk is incomplete, those entities in the CST that could not be matched are not included. This results in 61 matches that are labeled as approved.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
@cristinamullin This PR is ready to review. We can work on additional approval or rejection of rows in a future PR by adding ways to differentiate the methods of the uses alias (percent match method vs A/H and O/W categories crosswalk). The use alias from Greg's table was added as approved and adding on the O/W indicator to the ATTAINS Use Group was added to help reduce the list of potential use alias match to those that are more certain. I added arg inputs to ensure that the csv file does not replace any rows that got approved (reviewing these additional inputs would be nice to test). |


This is the first PR step for joining the criteria table to the WQP data for analysis. This new function will automatically join the WQP data frame with the TADA compatible criteria table dependent on what has been filled out in the criteria table.
Join WQP results to a criteria table by the best available key:
Users can make the criteria table join only by the TADA.CharacteristicName regardless of what has been filled out in the criteria table.
For testing, please look at the example tests and test out example WQP data retrievals with criteria table filled out. You can use the autoassign method in TADA_DefineCriteriaMethodology() if desired for testing or use a criteria table from the TADACommunityHub.
Ex.