Skip to content

Commit e5ba1ad

Browse files
authored
Merge pull request #10 from SCCWRP/TT
Tt
2 parents 13d8c58 + dd3efa4 commit e5ba1ad

60 files changed

Lines changed: 606 additions & 1534 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DESCRIPTION

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,19 @@ Authors@R: c(
3535
email = "VanSickle.John@epa.gov"
3636
)
3737
)
38-
RoxygenNote: 6.0.1
38+
RoxygenNote: 6.1.1
3939
Collate:
4040
'ASCI.R'
4141
'STE.R'
4242
'allscr.R'
4343
'class-asci.R'
4444
'asci-methods.R'
4545
'chkinp.R'
46-
'demo_algae_sitedata.R'
4746
'demo_algae_tax.R'
48-
'diatom_rf_oe.R'
4947
'getids.R'
5048
'globalVariables.R'
51-
'hybrid_rf_oe.R'
52-
'oefun.R'
53-
'oelkup.R'
54-
'pmmi_calcmetrics.R'
55-
'pmmifun.R'
56-
'pmmilkup.R'
49+
'mmi_calmetrics.R'
50+
'mmifun.R'
51+
'mmilkup.R'
5752
'rarify.R'
58-
'rf_out_top.R'
59-
'rfpred.r'
60-
'sba_rf_oe.R'
61-
'sitcat.R'
53+
'score_metric.R'

NAMESPACE

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(ASCI)
4-
export(Supp1_OE)
54
export(Supp1_mmi)
6-
export(Supp2_OE)
75
export(chkinp)
86
export(getids)
9-
export(oefun)
10-
export(perf)
11-
export(pmmi_calcmetrics)
12-
export(pmmifun)
7+
export(mmi_calcmetrics)
8+
export(mmifun)
139
export(rarify)
14-
export(rfpred)
10+
export(score_metric)
1511
export(scores)
1612
import(purrr)
17-
import(randomForest)
1813
import(tibble)
1914
importFrom(dplyr,arrange)
2015
importFrom(dplyr,bind_rows)
2116
importFrom(dplyr,filter)
2217
importFrom(dplyr,group_by)
23-
importFrom(dplyr,inner_join)
2418
importFrom(dplyr,left_join)
2519
importFrom(dplyr,mutate)
2620
importFrom(dplyr,rename)
@@ -43,7 +37,6 @@ importFrom(stats,sd)
4337
importFrom(stats,t.test)
4438
importFrom(stats,var)
4539
importFrom(tibble,enframe)
46-
importFrom(tibble,rownames_to_column)
4740
importFrom(tidyr,gather)
4841
importFrom(tidyr,nest)
4942
importFrom(tidyr,separate)

R/ASCI.R

Lines changed: 17 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#' Score samples using the ASCI tool
22
#'
33
#' @param taxain \code{data.frame} for input taxonomy data
4-
#' @param sitein \code{data.frame} for input site data
54
#' @param tax chr string indicating output to return from a specific taxa, must one to many of \code{'diatoms'}, \code{'sba'}, or \code{'hybrid'}, defaults to all
6-
#' @param ... additional arguments passed to other funcions, e.g., \code{\link{rfpred}}
5+
#' @param ... additional arguments passed to other funcions
76
#'
87
#' @details
9-
#' Two indices for three taxonomy types are scored, pMMI and O/E for diatoms, soft-bodied algae, and hybrid. This function combines output from the \code{\link{pmmifun}} and \code{\link{oefun}} functions in a user-friendly format.
8+
#' One index for three taxonomy types are scored, MMI for diatoms, soft-bodied algae, and hybrid.
9+
#' This function outputs the reulsts of \code{\link{mmifun}} functions in a user-friendly format.
1010
#'
1111
#' @return
1212
#' A \code{\link{asci}} object with specific methods. See the examples for accessing.
13-
#'
13+
#'
1414
#' @export
1515
#'
1616
#' @importFrom dplyr bind_rows mutate select
@@ -19,120 +19,55 @@
1919
#' @import purrr
2020
#' @import tibble
2121
#'
22-
#' @seealso \code{\link{pmmifun}}, \code{\link{oefun}}
22+
#' @seealso \code{\link{mmifun}}
2323
#'
2424
#' @examples
25-
#' results <- ASCI(demo_algae_tax, demo_algae_sitedata)
25+
#' results <- ASCI(demo_algae_tax)
2626
#' scores(results)
2727
#' Supp1_mmi(results)
28-
#' Supp1_OE(results)
29-
#' Supp2_OE(results)
30-
ASCI <- function(taxain, sitein, tax = c('diatoms', 'sba', 'hybrid'), ...){
31-
32-
## sanity checks
28+
ASCI <- function(taxain, tax = c('diatoms', 'sba', 'hybrid'), ...){
3329

3430
# check tax argument
3531
if(any(!tax %in% c('diatoms', 'sba', 'hybrid')))
3632
stop('tax must match diatoms, sba, and/or hybrid')
3733

3834
# run all other checks, get output if passed
39-
dat <- chkinp(taxain, sitein)
35+
dat <- chkinp(taxain)
4036

41-
##
42-
# individual output
37+
# mmi
38+
mmind <- mmifun(dat, ...)
4339

44-
# oe
45-
oeind <- oefun(dat$taxa, dat$site, ...)
46-
47-
# pmmi
48-
pmmind <- pmmifun(dat$taxa, dat$site, ...)
49-
5040
##
5141
# main output (scores)
52-
53-
# oe
54-
oescr <- oeind %>%
55-
map(function(x){
56-
57-
x$OE_scores %>%
58-
select(SampleID, O, E, OoverE, OoverE_Percentile) %>%
59-
gather('met', 'val', -SampleID)
60-
61-
}) %>%
62-
enframe('taxa') %>%
63-
unnest
64-
65-
# pmmi
66-
pmmiscr <- pmmind %>%
42+
mmiscr <- mmind %>%
6743
map(~ .x$MMI_scores) %>%
6844
map(gather, 'met', 'val', -SampleID) %>%
6945
enframe('taxa') %>%
70-
unnest
71-
72-
# combine scrs, long format
73-
scr <- bind_rows(oescr, pmmiscr) %>%
74-
spread(met, val) %>%
75-
select(taxa, SampleID, MMI, MMI_Percentile, O, E, OoverE, OoverE_Percentile)
46+
unnest %>%
47+
spread(met, val)
7648

7749
##
7850
# supplementary info
79-
80-
# pmmi
81-
Supp1_mmi <- pmmind %>%
51+
Supp1_mmi <- mmind %>%
8252
map(~ .x$MMI_supp) %>%
8353
map(gather, 'Metric', 'Value', -SampleID) %>%
8454
enframe('taxa') %>%
8555
unnest
8656

87-
# oe capture probs
88-
Supp1_OE <- oeind %>%
89-
map(~ .x$Capture_Probs) %>%
90-
enframe('taxa') %>%
91-
unnest
92-
93-
# oe group occurrence probs
94-
Supp2_OE <- oeind %>%
95-
map(~ .x$Group_Occurrence_Probs) %>%
96-
map(gather, 'pGroup', 'Prob', -SampleID) %>%
97-
enframe('taxa') %>%
98-
unnest
99-
100-
# oe null
101-
null_OE <- oeind %>%
102-
map(function(x){
103-
104-
x$OE_scores %>%
105-
select(SampleID, Onull, Enull, OoverE.null) %>%
106-
gather('met', 'val', -SampleID)
107-
108-
}) %>%
109-
enframe('taxa') %>%
110-
unnest
111-
11257
# subset taxa if needed
11358
if(length(tax) < 3){
11459

115-
scr <- scr %>%
60+
mmiscr <- mmiscr %>%
11661
filter(taxa %in% tax)
11762

11863
Supp1_mmi <- Supp1_mmi %>%
11964
filter(taxa %in% tax)
12065

121-
Supp1_OE <- Supp1_OE %>%
122-
filter(taxa %in% tax)
123-
124-
Supp2_OE <- Supp2_OE %>%
125-
filter(taxa %in% tax)
126-
127-
null_OE <- null_OE %>%
128-
filter(taxa %in% tax)
129-
13066
}
131-
67+
13268
##
13369
# create asci class output
134-
out <- asci(scores = scr, Supp1_mmi = Supp1_mmi, Supp1_OE = Supp1_OE,
135-
Supp2_OE = Supp2_OE, null_OE = null_OE, taxa = tax)
70+
out <- asci(scores = mmiscr, Supp1_mmi = Supp1_mmi, taxa = tax)
13671

13772
return(out)
13873

R/STE.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#'
66
#' @format A \code{\link[base]{data.frame}} of taxonomic lookup data used for verifying species names in sample data, 4961 rows and five columns.
77
#'
8-
#' @details The object is used internally in \code{\link{oefun}} and \code{\link{pmmifun}}.
8+
#' @details The object is used internally in \code{\link{mmifun}}.
99
#'
1010
#' @examples
1111
#' data(STE)

0 commit comments

Comments
 (0)