GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — detectMutations/scripts/evaluate_call.R at main · sylvainschmitt/detectMutations

Expand file tree

/

evaluate_call.R

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
42 lines (40 loc) · 1.5 KB
/

evaluate_call.R

Copy path

File metadata and controls

42 lines (40 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
callfile <- snakemake@input[[1]]
mutationsfile <- snakemake@input[[2]]
statsfile <- snakemake@output[[1]]
library(tidyverse)
library(vcfR)
mutations <- read_tsv(mutationsfile, col_types = cols(
CHROM = col_character(),
POS = col_double(),
REF = col_character(),
TYPE = col_character(),
ALT = col_character()
)) %>%
mutate(True = 1) %>%
filter(REF != "N")
call <- try(read.vcfR(callfile, verbose = F)@fix, silent = T)
if(!inherits(call, "try-error")){
call <- as.data.frame(call) %>%
mutate_at(c("CHROM", "REF", "ALT"), as.character) %>%
mutate(POS = as.numeric(as.character(POS))) %>%
mutate(Called = 1) %>%
mutate(REF = substr(REF, 1, 1), ALT = substr(ALT, 1, 1))
} else {
call <- data.frame(CHROM = character(), POS = double(), REF = character(), ALT = character(), Called = integer())
}
stats <- full_join(mutations, call, by = c("CHROM", "POS", "REF", "ALT")) %>%
mutate_at(c("True", "Called"), funs(ifelse(is.na(.), 0, .))) %>%
mutate(Confusion = recode(paste0(True, Called), "01" = "FP", "10" = "FN", "11" = "TP")) %>%
group_by(Confusion) %>%
summarise(N = n()) %>%
reshape2::dcast(mutationsfile + callfile ~ Confusion, value.var = "N")
if(!("FP" %in% names(stats)))
stats$FP <- 0
if(!("FN" %in% names(stats)))
stats$FN <- 0
if(!("TP" %in% names(stats)))
stats$TP <- 0
stats <- mutate(stats, Precision = round(TP/(TP+FP), 2), Recall = round(TP/(TP+FN), 2)) %>%
mutate(callfile = callfile) %>%
mutate(mutationsfile = mutationsfile)
write_tsv(stats, statsfile)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.