Snippets
Revised by
Dénes Türei
c925d3a
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | #!/usr/bin/env Rscript
# Copyright Saez Lab 2020
#
# Author: Denes Turei
# Contact: turei.denes@gmail.com
#
# License: MIT License https://opensource.org/licenses/MIT
#
# Combines the OmniPath PPI and transcriptional regulatory network
# with the human-SARS CoV-2 interactions from Gordon et al. 2020
require(dplyr)
require(tibble)
require(purrr)
require(openxlsx)
require(igraph)
require(qgraph)
if(!'OmnipathR' %in% installed.packages()[,"Package"]){
require(devtools)
install_github('saezlab/OmnipathR')
}
require(OmnipathR)
# URLs for supplementary tables S2 and S3 from Gordon et al. 2020
# https://www.biorxiv.org/content/10.1101/2020.03.22.002386v2
url_s2 <- paste0(
'https://www.biorxiv.org/content/biorxiv/early/',
'2020/03/23/2020.03.22.002386/DC4/embed/media-4.xlsx?download=true'
)
url_s3 <- paste0(
'https://www.biorxiv.org/content/biorxiv/early/',
'2020/03/23/2020.03.22.002386/DC5/embed/media-5.xlsx?download=true'
)
# the OmniPath PPI interaction network
ia_omnipath <- import_Omnipath_Interactions() %>% as_tibble()
# in the example we don't use these but if you need higher coverage on PPI
# add these with `bind_rows` below
ia_ligrec <- import_LigrecExtra_Interactions() %>% as_tibble()
ia_pwextra <- import_PathwayExtra_Interactions() %>% as_tibble()
ia_kinaseextra <- import_KinaseExtra_Interactions() %>% as_tibble()
# transcriptional regulation
# if you want more interactions, pass the argument
# `confidence_level = c('A', 'B', 'C', 'D')`
ia_transcriptional <- import_TFregulons_Interactions() %>% as_tibble()
# post-transcriptional regulation
# here we don't use it but if you are interested
# add these by `bind_rows` below
ia_post_transcriptional <- import_miRNAtarget_Interactions() %>% as_tibble()
# downloading the host-pathogen interactions from the paper
human_sarscov2_raw <- read.xlsx(url_s2, startRow = 2) %>% as_tibble()
# downloading the compound-host-pathogen interactions from the paper
# here we don't use it but if you are interested combine with the other
# interactions a similar way as the host-pathogen ones
human_sarscov2_compounds_raw <- read.xlsx(url_s3) %>% as_tibble()
# combining all the interactions to one data frame
ia_human_sarscov2 <- human_sarscov2_raw %>%
select(
source = Bait,
target = Preys,
source_genesymbol = Bait,
target_genesymbol = PreyGene,
MIST,
Saint_BFDR,
AvgSpec,
FoldChange
) %>%
# manually adding the known S--ACE2 and S--BSG interactions
add_row(
source = 'SARS-CoV2 Spike',
target = 'Q9BYF1',
source_genesymbol = 'Spike',
target_genesymbol = 'ACE2'
) %>%
add_row(
source = 'SARS-CoV2 Spike',
target = 'P35613',
source_genesymbol = 'Spike',
target_genesymbol = 'BSG'
)
interactions <- as_tibble(
bind_rows(
ia_omnipath %>% mutate(type = 'ppi'),
ia_pwextra %>% mutate(type = 'ppi'),
ia_kinaseextra %>% mutate(type = 'ppi'),
ia_ligrec %>% mutate(type = 'ppi'),
ia_transcriptional %>% mutate(type = 'transcriptional'),
ia_human_sarscov2 %>% mutate(
source_genesymbol = sub('SARS-CoV2 ', '', source_genesymbol),
type = 'host_pathogen',
# the direction or effect of these interactions is unknown
is_directed = 0,
is_stimulation = 0,
is_inhibition = 0,
consensus_direction = 0,
consensus_stimulation = 0,
consensus_inhibition = 0,
)
)
)
# creating an igraph network from the interactions data frame
net_human_sarscov2 <- interaction_graph(interactions = interactions) %>%
simplify(remove.multiple = FALSE, remove.loops = TRUE)
# labeling the proteins by organism
sarscov2_proteins <- ia_human_sarscov2 %>% pull(source) %>% unique()
V(net_human_sarscov2)$organism <- ifelse(
V(net_human_sarscov2)$up_ids %in% sarscov2_proteins,
'SARS-CoV2',
'human'
)
# labeling direct viral targets and transcription factors
V(net_human_sarscov2)$viral_target <- (
V(net_human_sarscov2)$up_ids %in% (
ia_human_sarscov2 %>% pull(target) %>% unique()
)
)
V(net_human_sarscov2)$tf <- (
V(net_human_sarscov2)$up_ids %in% (
ia_transcriptional %>% pull(source) %>% unique()
)
)
# node indices of the SARS-CoV2 proteins
nodes_sarscov2 <- which(V(net_human_sarscov2)$organism == 'SARS-CoV2')
# creating subgraphs of the neighborhood of each virus protein
neighborhoods_human_sarscov2_1 <- make_ego_graph(
net_human_sarscov2,
order = 1,
nodes = nodes_sarscov2,
mode = 'all'
)
nodes_in_neighborhoods <- neighborhoods_human_sarscov2_1 %>%
map(function(g){V(g)$name}) %>%
unlist() %>%
unique()
# reducing the network to the neighborhoods
net_human_sarscov2_1 <- net_human_sarscov2 %>%
delete_vertices(
which(
!V(net_human_sarscov2)$name %in% nodes_in_neighborhoods
)
)
net_human_sarscov2_1 <- net_human_sarscov2_1 %>%
delete_vertices(
which(!(
V(net_human_sarscov2_1)$viral_target |
V(net_human_sarscov2_1)$organism == 'SARS-CoV2'
))
)
nodes_having_ppi <- net_human_sarscov2_1 %>%
get.edges(
E(net_human_sarscov2_1)[
E(net_human_sarscov2_1)$type %in% c('ppi', 'transcriptional')
]
) %>%
c() %>%
unique()
sarscov2_nodes <- which(V(net_human_sarscov2_1)$organism == 'SARS-CoV2')
nodes_to_keep <- c(nodes_having_ppi, sarscov2_nodes) %>% unique()
net_human_sarscov2_1 <- net_human_sarscov2_1 %>%
induced_subgraph(nodes_to_keep)
net_human_sarscov2_1 <- net_human_sarscov2_1 %>%
delete_vertices(degree(.) == 0)
# creating a figure of the direct neighborhood network
fr_layout <- qgraph.layout.fruchtermanreingold(
get.edgelist(net_human_sarscov2_1, names = FALSE),
vcount = vcount(net_human_sarscov2_1),
area = vcount(net_human_sarscov2_1) ** 2.3,
repulse.rad = vcount(net_human_sarscov2_1) ** 2.1,
niter = 3000
)
png(
filename = 'SARS-CoV2_OmniPath_neighborhood.png',
width = 7,
height = 7,
units = 'in',
res = 600
)
plot(
net_human_sarscov2_1,
layout = fr_layout,
vertex.size = 5,
vertex.label.cex = .33,
vertex.color = ifelse(
V(net_human_sarscov2_1)$organism == 'SARS-CoV2',
'#FCCC06',
ifelse(
V(net_human_sarscov2_1)$viral_target,
'#97BE73',
'#B6B7B9'
)
),
vertex.label.family = 'DINPro',
vertex.label.color = '#454447',
vertex.frame.width = 0,
vertex.frame.color = NA,
edge.color = ifelse(
E(net_human_sarscov2_1)$type == 'host_pathogen',
'#FCCC06',
ifelse(
E(net_human_sarscov2_1)$is_inhibition,
'#E25C49AA',
ifelse(
E(net_human_sarscov2_1)$is_stimulation,
'#49969AAA',
'#646567AA'
)
)
),
edge.arrow.size = ifelse(
E(net_human_sarscov2_1)$is_directed,
.2,
.0
),
# edge.lty = ifelse(
# E(net_human_sarscov2_1)$type == 'transcriptional',
# 'dashed',
# ifelse(
# E(net_human_sarscov2_1)$type == 'host_pathogen',
# 'dotted',
# 'solid'
# )
# ),
edge.width = .2
)
dev.off()
|
You can clone a snippet to your computer for local editing. Learn more.