2020-09-18 11:56:30 +00:00
|
|
|
# tocID <- "scripts/ABC-makeScCCnet.R"
|
2017-10-07 15:52:33 +00:00
|
|
|
#
|
|
|
|
# Create a subnetwork of high-confidence yeast genes with a "mitotic cell cycle"
|
|
|
|
# GOSlim annotation.
|
|
|
|
#
|
|
|
|
# Boris Steipe for ABC learning units
|
|
|
|
#
|
|
|
|
# Notes:
|
2020-09-23 04:06:58 +00:00
|
|
|
#
|
|
|
|
# The large source- datafiles are NOT posted to github. If you want to
|
|
|
|
# experiment with your own code, download them and place them into your
|
|
|
|
# local ./data directory.
|
|
|
|
#
|
2017-10-07 15:52:33 +00:00
|
|
|
# STRING data source:
|
2020-09-23 04:06:58 +00:00
|
|
|
# Download page:
|
|
|
|
# https://string-db.org/cgi/download.pl?species_text=Saccharomyces+cerevisiae
|
|
|
|
# Data: (20.1 mb)
|
|
|
|
# https://stringdb-static.org/download/protein.links.full.v11.0/4932.protein.links.full.v11.0.txt.gz
|
2017-10-07 15:52:33 +00:00
|
|
|
#
|
2020-09-23 04:06:58 +00:00
|
|
|
# GOSlim data source: (Note: this has moved from GO to SGD)
|
|
|
|
# Info page: https://www.yeastgenome.org/downloads
|
|
|
|
# Info page: http://sgd-archive.yeastgenome.org/curation/literature/
|
|
|
|
# Data: (3 mb)
|
|
|
|
# http://sgd-archive.yeastgenome.org/curation/literature/go_slim_mapping.tab
|
2017-10-07 15:52:33 +00:00
|
|
|
#
|
|
|
|
#
|
2020-09-23 04:06:58 +00:00
|
|
|
# Version: 1.2
|
2017-10-07 15:52:33 +00:00
|
|
|
#
|
2020-09-23 04:06:58 +00:00
|
|
|
# Date: 2017-10 - 2020-09
|
2017-10-07 15:52:33 +00:00
|
|
|
# Author: Boris Steipe (boris.steipe@utoronto.ca)
|
|
|
|
#
|
|
|
|
# Versions:
|
2020-09-23 04:06:58 +00:00
|
|
|
# 1.2 2020 Update. GO Slim Yeast mow at SGD
|
2019-01-08 07:11:25 +00:00
|
|
|
# 1.1 Change from require() to requireNamespace(),
|
|
|
|
# use <package>::<function>() idiom throughout
|
2017-10-07 15:52:33 +00:00
|
|
|
# 1.0 First code copied from 2016 material.
|
|
|
|
#
|
|
|
|
# TODO:
|
|
|
|
#
|
|
|
|
# ==============================================================================
|
2020-09-23 04:06:58 +00:00
|
|
|
# SRCDIR <- "./instructor"
|
|
|
|
|
|
|
|
|
|
|
|
#TOC> ==========================================================================
|
|
|
|
#TOC>
|
|
|
|
#TOC> Section Title Line
|
|
|
|
#TOC> ---------------------------------------------------------------
|
|
|
|
#TOC> 1 INITIALIZE 58
|
|
|
|
#TOC> 2 STRING FUNCTIONAL INTERACTION DATA 66
|
|
|
|
#TOC> 3 GOSlim FUNCTIONAL ANNOTATIONS 96
|
|
|
|
#TOC> 3.1 Intersect interactions and annotations 122
|
|
|
|
#TOC> 4 DEFINE THE CELL-CYCLE NETWORK 128
|
|
|
|
#TOC>
|
|
|
|
#TOC> ==========================================================================
|
2017-10-07 15:52:33 +00:00
|
|
|
|
2020-09-23 04:06:58 +00:00
|
|
|
|
|
|
|
# = 1 INITIALIZE ==========================================================
|
|
|
|
|
|
|
|
SRCDIR <- "./data"
|
2019-01-08 07:11:25 +00:00
|
|
|
if (! requireNamespace("readr", quietly = TRUE)) {
|
2017-10-07 15:52:33 +00:00
|
|
|
install.packages("readr")
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-23 04:06:58 +00:00
|
|
|
# = 2 STRING FUNCTIONAL INTERACTION DATA ==================================
|
2017-10-07 15:52:33 +00:00
|
|
|
|
|
|
|
# Read STRING Data (needs to be downloaded from database, see URL in Notes)
|
2020-09-23 04:06:58 +00:00
|
|
|
# The .gz compressed version is 20MB, the uncompressed versioj is 110MB -
|
|
|
|
# really not necessary to uncompress since readr:: can read from compressed
|
|
|
|
# files, and does so automatically, based on the file extension.
|
|
|
|
( fn <- file.path(SRCDIR, "4932.protein.links.full.v11.0.txt.gz") )
|
|
|
|
STR <- readr::read_delim(fn, delim = " ")
|
2017-10-07 15:52:33 +00:00
|
|
|
|
|
|
|
# Subset only IDs and combined_score column
|
|
|
|
STR <- STR[ , c("protein1", "protein2", "combined_score")]
|
|
|
|
|
|
|
|
# head(STR)
|
|
|
|
# sum(STR$combined_score > 909) # 100270 edges
|
|
|
|
# subset for 100,000 highest confidence edges
|
|
|
|
STR <- STR[(STR$combined_score > 909), ]
|
2020-09-23 04:06:58 +00:00
|
|
|
head(STR)
|
2017-10-07 15:52:33 +00:00
|
|
|
|
|
|
|
# IDs are formatted like 4932.YAL005C ... drop the "4932." prefix
|
|
|
|
STR$protein1 <- gsub("^4932\\.", "", STR$protein1)
|
|
|
|
STR$protein2 <- gsub("^4932\\.", "", STR$protein2)
|
2020-09-23 04:06:58 +00:00
|
|
|
head(STR)
|
2017-10-07 15:52:33 +00:00
|
|
|
|
|
|
|
# get a vector of gene names in this list
|
|
|
|
myIntxGenes <- unique(c(STR$protein1, STR$protein2)) # yeast systematic gene
|
|
|
|
# names
|
2020-09-23 04:06:58 +00:00
|
|
|
length(myIntxGenes)
|
|
|
|
sample(myIntxGenes, 10) # choose 10 at random (sanity check)
|
2017-10-07 15:52:33 +00:00
|
|
|
|
|
|
|
|
2020-09-23 04:06:58 +00:00
|
|
|
# = 3 GOSlim FUNCTIONAL ANNOTATIONS =======================================
|
2017-10-07 15:52:33 +00:00
|
|
|
#
|
|
|
|
# Read GOSlim data (needs to be downloaded from database, see URL in Notes)
|
2020-09-23 04:06:58 +00:00
|
|
|
( fn <- file.path(SRCDIR, "go_slim_mapping.tab") )
|
2017-10-07 15:52:33 +00:00
|
|
|
|
2020-09-23 04:06:58 +00:00
|
|
|
Gsl <- readr::read_tsv(fn,
|
2019-01-08 07:11:25 +00:00
|
|
|
col_names = c("ID",
|
|
|
|
"name",
|
|
|
|
"SGDId",
|
|
|
|
"Ontology",
|
|
|
|
"termName",
|
|
|
|
"termID",
|
|
|
|
"status"))
|
2017-10-07 15:52:33 +00:00
|
|
|
|
2020-09-23 04:06:58 +00:00
|
|
|
head(Gsl)
|
|
|
|
|
2017-10-07 15:52:33 +00:00
|
|
|
# What cell cycle names does it contain?
|
2020-09-23 04:06:58 +00:00
|
|
|
myGslTermNames <- unique(Gsl$termName) # 169 unique terms
|
|
|
|
myGslTermNames[grep("cycle", myGslTermNames)]
|
2017-10-07 15:52:33 +00:00
|
|
|
# [1] "regulation of cell cycle" "mitotic cell cycle" "meiotic cell cycle"
|
2020-09-23 04:06:58 +00:00
|
|
|
|
2017-10-07 15:52:33 +00:00
|
|
|
# Choose "mitotic cell cycle" as the GOslim term to subset with
|
|
|
|
|
|
|
|
scCCgenes <- unique(Gsl$ID[Gsl$termName == "mitotic cell cycle"])
|
2020-09-23 04:06:58 +00:00
|
|
|
length(scCCgenes) # 324 genes annotated to that term
|
|
|
|
|
|
|
|
# == 3.1 Intersect interactions and annotations ============================
|
|
|
|
|
|
|
|
sum(scCCgenes %in% myIntxGenes) # 307 of these have high-confidence
|
|
|
|
# # functional interactions
|
2017-10-07 15:52:33 +00:00
|
|
|
|
|
|
|
|
2020-09-23 04:06:58 +00:00
|
|
|
# = 4 DEFINE THE CELL-CYCLE NETWORK =======================================
|
|
|
|
#
|
2017-10-07 15:52:33 +00:00
|
|
|
# Define scCCnet ... the S. Cervisiae Cell Cycle network
|
|
|
|
# Subset all rows for which BOTH genes are in the GOslim cell cycle set
|
2020-09-23 04:06:58 +00:00
|
|
|
#
|
2017-10-07 15:52:33 +00:00
|
|
|
scCCnet <- STR[(STR$protein1 %in% scCCgenes) &
|
|
|
|
(STR$protein2 %in% scCCgenes), ]
|
|
|
|
|
|
|
|
# How many genes are there?
|
2020-09-23 04:06:58 +00:00
|
|
|
length(unique(c(scCCnet$protein1, scCCnet$protein2))) #283
|
2017-10-07 15:52:33 +00:00
|
|
|
|
|
|
|
# Each edge is listed twice - now remove duplicates.
|
2020-09-23 04:06:58 +00:00
|
|
|
|
|
|
|
# Step 1: make a vector: sort two names so the fiRst one is alphabetically
|
|
|
|
# smaller Than the second one. This brings the two names into a defined
|
2017-10-07 15:52:33 +00:00
|
|
|
# order. Then concatenate them with a "." - the resulting string
|
|
|
|
# is always the same, for any order. E.g. c("A", "B") gives "A.B"
|
|
|
|
# and c("B", "A") also gives "A.B". This identifies duplicates.
|
|
|
|
|
2020-09-23 04:06:58 +00:00
|
|
|
x <- apply(cbind(scCCnet$protein1, scCCnet$protein2),
|
2017-10-07 15:52:33 +00:00
|
|
|
1,
|
|
|
|
FUN = function(x) { return(paste(sort(x), collapse = ".")) })
|
2020-09-23 04:06:58 +00:00
|
|
|
head(x) # "YAL016W.YGR040W" "YAL016W.YOR014W" "YAL016W.YDL188C" ... etc.
|
2017-10-07 15:52:33 +00:00
|
|
|
|
2020-09-23 04:06:58 +00:00
|
|
|
sum(duplicated(x)) # 1453
|
2017-10-07 15:52:33 +00:00
|
|
|
|
|
|
|
# Step 2: drop all rows that contain duplicates in x
|
|
|
|
scCCnet <- scCCnet[! duplicated(x), ]
|
|
|
|
|
|
|
|
# Confirm we didn't loose genes
|
2020-09-23 04:06:58 +00:00
|
|
|
length(unique(c(scCCnet$protein1, scCCnet$protein2))) # 283, no change
|
|
|
|
nrow(scCCnet)
|
|
|
|
# Network has 283 nodes, 1453 edges
|
2017-10-07 15:52:33 +00:00
|
|
|
|
2020-09-21 04:28:24 +00:00
|
|
|
saveRDS(scCCnet, file = "./data/scCCnet.rds")
|
2017-10-07 15:52:33 +00:00
|
|
|
|
2020-09-21 04:28:24 +00:00
|
|
|
# scCCnet <- readRDS("./data/scCCnet.rds") # <<<- use this to restore the
|
|
|
|
# object when needed
|
2017-10-07 15:52:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
# [END]
|