Skip to content

Commit

Permalink
update docs for td sims
Browse files Browse the repository at this point in the history
  • Loading branch information
Kate Weaver committed Apr 23, 2022
1 parent 805fc43 commit 405141d
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 11 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export(sim_assess_recomb)
export(sim_autorun)
export(sim_generate_global)
export(sim_run_generative_model)
export(sim_run_generative_model_with_TD)
import(data.table)
importFrom(HMM,initHMM)
importFrom(HMM,viterbi)
Expand Down
22 changes: 11 additions & 11 deletions R/sim_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@
#' @return metric_list a named list returning precision, recall, accuracy, specificity, fpr, fdr, and f1 (the f1 score)
#'
sim_metrics <- function(tp, fp, tn, fn){
if ((tp+fp) > 0){
precision <- tp/(tp+fp)
fdr <- fp/(tp+fp)
if (sum(tp, fp, na.rm = TRUE) > 0){
precision <- tp/sum(tp, fp, na.rm = TRUE)
fdr <- fp/sum(tp, fp, na.rm = TRUE)
} else{
precision <- NA
fdr <- NA
}
if ((tp+fn) >0){
recall <- tp/(tp+fn)
if (sum(tp, fn, na.rm = TRUE) >0){
recall <- tp/sum(tp, fn, na.rm = TRUE)
} else{
recall <- NA
}
if ((tn+fp) > 0){
specificity <- tn/(tn+fp)
fpr <- fp/(tn+fp)
if (sum(tn, fp, na.rm = TRUE) > 0){
specificity <- tn/sum(tn, fp, na.rm = TRUE)
fpr <- fp/sum(tn, fp, na.rm = TRUE)
} else{
specificity <- NA
fpr <- NA
}
if ((tp+fp+tn+fn) > 0){
accuracy <- (tp + tn)/(tp + tn + fp + fn)
if (sum(tp, fp, tn, fn, na.rm = TRUE) > 0){
accuracy <- sum(tp, tn, na.rm = TRUE)/sum(tp, tn, fp, fn, na.rm = TRUE)
} else{
accuracy <- NA
}
f1 <- (2*precision*recall)/(precision+recall)
f1 <- prod(2,precision,recall, na.rm = TRUE)/sum(precision, recall, na.rm = TRUE)
metric_list <- list(precision=precision,
recall=recall,
accuracy=accuracy,
Expand Down
35 changes: 35 additions & 0 deletions man/sim_gamete_killing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions man/sim_gene_conversion.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions man/sim_run_generative_model_with_TD.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 405141d

Please sign in to comment.