silver_standard_perf: Plotting PR/ROC curves

Description Usage Arguments Details Value Examples

View source: R/silver_standard.R

Description

Given a silver standard as 'truth', plot PR/ROC curves for the trait/gene pairs and scores listed in score_table, e.g.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
silver_standard_perf(
  score_table,
  map_table,
  silver_standard,
  gwas_loci = NULL,
  gene_annotation = NULL,
  score_cols = NULL,
  trait_codes = "phecode",
  mapping_method = "greedy_map"
)

Arguments

score_table

a data.frame containing 'trait' and 'gene' as columns along with multiple columns for scores calculated by different method. Note that we interpret HIGHER score as more likely to be causal. If you have the opposite, please flip it.

map_table

a data.frame containing 'trait' as column along with 'phecode' and/or 'HPO' as columns. This table serves as the map between trait name in 'trait' column and trait codes ('phecode', 'HPO', etc). So that it is used to map trait names (in score_table) to trait code (in silver_standard).

silver_standard

shared along with the package. It is a list with meta information and a table (a data.frame) where each row pairs trait in phecode, HPO to gene. New silver_standard data set is awaiting for contribution from the community.

gwas_loci

a data.frame with columns: chromosome (e.g. chr1), start, end, trait (with trait name matching the one in score_table) indicating which GWAS loci you want to focus on. If it is specified as non-NULL, you should also specify gene_annotation as the genomic position for genes. By specifying gwas_loci and gene_annotation, it triggers a more stringent (recommended due to the sparse nature of silver standard) pre-processing step to limit analysis on a subset of trait-gene pairs in score_table, by the following 2 steps: 1. Select GWAS loci overlapping with silver standard gene 2. Select genes that overlap with selected GWAS loci as candidate genes.

gene_annotation

a data.frame with columns: chromosome (e.g. chr1), start, end, gene (Ensembl ID (no dot), e.g. ENSG00000084754)

score_cols

a vector of column names in score_table to be used as score columns. If it is NULL, all but 'trait' and 'gene' columns will be used.

trait_codes

trait codes to use for mapping: 'phecode' and/or 'HPO'.

mapping_method

the name of the mapping function used to match trait name with gene on the basis of map_table and silver_standard$table New mapping_method is awaiting for contribution from the community.

Details

> score_table = data.frame(trait = ..., gene = ..., score1 = ..., score2 = ..., ...)

Silver standard supports HPO, phecode. User should provide the corresponding HPO or phecode for their GWAS traits in map_table, e.g.

> map_table1 = data.frame(trait = ..., phecode = ...)

> map_table2 = data.frame(trait = ..., HPO = ...)

Value

list containing PR and ROC plots which are ggplot2 objects

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
silver_standard_perf(
  score_table = data.frame(
    trait = c(rep('t1', 20), rep('t2', 30), rep('t3', 50)),
    gene = paste0('g', 1:100),
    score1 = runif(100),
    score2 = runif(100),
    stringsAsFactors = FALSE
  ),
  map_table = data.frame(
    trait = c('t1', 't2', 't3'),
    phecode = c('1.1', '23', '12'),
    stringsAsFactors = FALSE
  ),
  silver_standard = list(
    table = data.frame(
      phecode = c(rep('1.1', 10), rep('23', 10), rep('12', 10), rep('2', 10)),
      gene = paste0('g', 1:40),
      stringsAsFactors = FALSE
    ),
    script_info = 'toy_example'
  ),
  gwas_loci = data.frame(
    chromosome = paste0('chr', sample(1:1, size = 10, replace = TRUE)),
    start = (1:10) * 1e3 + 300, end = (1:10) * 1e3 + 500,
    trait = sample(c('t1', 't2'), size = 10, replace = TRUE)
  ),
  gene_annot = data.frame(
    chromosome = paste0('chr', sample(1:1, size = 100, replace = TRUE)),
    gene_id = paste0('g', 1:100),
    start = 1:10 * 1e3 + 350,
    end = 1:10 * 1e3 + 450,
    gene_type = c(rep('protein_coding', 60), rep('psuedogene', 40))
  )
)

liangyy/silver-standard-performance documentation built on Dec. 5, 2019, 8:53 a.m.