## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse  = TRUE,
  comment   = "#>",
  eval      = FALSE
)

## ----input-data---------------------------------------------------------------
# input <- data.frame(
#   Protein   = c("CHK1_HUMAN", "RFA1_HUMAN", "CLH1_HUMAN", "CRTC3_HUMAN"),
#   log2FC    = c(2.31, 1.87, 1.45, 1.12),
#   adj.pvalue = c(0.0021, 0.0089, 0.0310, 0.0490),
#   stringsAsFactors = FALSE
# )
# 
# input

## ----annotate-----------------------------------------------------------------
# library(MSstatsBioNet)
# annotated_df <- annotateProteinInfoFromIndra(input, "Uniprot_Mnemonic")

## ----subnetwork---------------------------------------------------------------
# subnetwork <- getSubnetworkFromIndra(
#   annotated_df,
#   pvalueCutoff          = 0.2,
#   logfc_cutoff          = NULL,
#   evidence_count_cutoff = 1,
#   sources_filter        = NULL,
#   force_include_other   = "HGNC:1925",
#   filter_by_curation    = FALSE
# )
# 
# # Inspect the unfiltered network
# nrow(subnetwork$nodes)
# nrow(subnetwork$edges)

## ----tags---------------------------------------------------------------------
# tags <- c(
#   "dna damage repair",
#   "cancer",
#   "oncology",
#   "dna repair",
#   "genome integrity",
#   "genomic instability",
#   "double strand_break",
#   "dsb",
#   "single strand_break",
#   "ssb",
#   "base excision repair",
#   "ber",
#   "nucleotide excision repair",
#   "ner",
#   "mismatch repair",
#   "mmr",
#   "homologous recombination",
#   "hr",
#   "non homologous end joining",
#   "nhej",
#   "brca1",
#   "brca2",
#   "atm",
#   "atr",
#   "p53",
#   "tp53",
#   "parp",
#   "tumor suppressor",
#   "oncogene",
#   "carcinogenesis",
#   "tumorigenesis",
#   "chemotherapy resistance",
#   "radiation resistance",
#   "genotoxic stress",
#   "replication stress",
#   "oxidative dna_damage",
#   "somatic mutation",
#   "tumor mutational burden",
#   "tmb"
# )

## ----filter-------------------------------------------------------------------
# filtered_network <- filterSubnetworkByContext(
#   nodes             = subnetwork$nodes,
#   edges             = subnetwork$edges,
#   method            = "tag_count",
#   cutoff = 3,
#   query             = tags
# )

## ----nodes--------------------------------------------------------------------
# filtered_network$nodes

## ----edges--------------------------------------------------------------------
# filtered_network$edges

## ----evidence-----------------------------------------------------------------
# filtered_network$evidence

## ----sort-evidence------------------------------------------------------------
# filtered_network$evidence[
#   order(filtered_network$evidence$score, decreasing = TRUE),
# ]

## ----explore-cutoff-----------------------------------------------------------
# # Run with permissive cutoff to see full score distribution
# exploratory <- filterSubnetworkByContext(
#   nodes             = subnetwork$nodes,
#   edges             = subnetwork$edges,
#   cutoff = 0.0,
#   query             = tags
# )
# 
# summary(exploratory$evidence$score)
# hist(exploratory$evidence$score,
#      breaks = 30,
#      main   = "Distribution of abstract scores",
#      xlab   = "Number of tags matched",
#      col    = "steelblue")

## ----query--------------------------------------------------------------------
# my_query <- "DNA damage repair cancer oncology DNA repair genome integrity
#   genomic instability double strand break DSB single strand break SSB
#   base excision repair BER nucleotide excision repair NER mismatch repair MMR
#   homologous recombination HR non-homologous end joining NHEJ BRCA1 BRCA2
#   ATM ATR p53 TP53 PARP tumor suppressor oncogene carcinogenesis tumorigenesis
#   chemotherapy resistance radiation resistance genotoxic stress replication stress
#   oxidative DNA damage somatic mutation tumor mutational burden TMB"

## -----------------------------------------------------------------------------
# filtered_network <- filterSubnetworkByContext(
#   nodes             = subnetwork$nodes,
#   edges             = subnetwork$edges,
#   method            = "cosine",
#   cutoff = 0.10,
#   query             = my_query
# )

## -----------------------------------------------------------------------------
# filtered_network$nodes

## -----------------------------------------------------------------------------
# filtered_network$edges

## -----------------------------------------------------------------------------
# filtered_network$evidence

## -----------------------------------------------------------------------------
# filtered_network$evidence[
#   order(filtered_network$evidence$score, decreasing = TRUE),
# ]

## -----------------------------------------------------------------------------
# # Run with permissive cutoff to see full score distribution
# exploratory <- filterSubnetworkByContext(
#   nodes             = subnetwork$nodes,
#   edges             = subnetwork$edges,
#   cutoff = 0.0,
#   method = "cosine",
#   query             = my_query
# )
# 
# summary(exploratory$evidence$score)
# hist(exploratory$evidence$score,
#      breaks = 30,
#      main   = "Distribution of abstract scores",
#      xlab   = "Cosine score to query",
#      col    = "steelblue")

## ----session-info, eval=TRUE--------------------------------------------------
sessionInfo()

