You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# We advise to instal from github to get the latest version of the tool.
# if (!requireNamespace("devtools", quietly = TRUE))
# install.packages("devtools")
#
# devtools::install_github("saezlab/cosmosR")
library(cosmosR)
library(reshape2)
library(readr)
data("meta_network")
meta_network <- meta_network_cleanup(meta_network)
## Warning: `summarise_each()` was deprecated in dplyr 0.7.0.
## ℹ Please use `across()` instead.
## ℹ The deprecated feature was likely used in the cosmosR package.
## Please report the issue at <https://github.com/saezlab/COSMOSR/issues>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: `funs()` was deprecated in dplyr 0.8.0.
## ℹ Please use a list of either functions or lambdas:
##
## # Simple named list: list(mean = mean, median = median)
##
## # Auto named with `tibble::lst()`: tibble::lst(mean, median)
##
## # Using lambdas list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
## ℹ The deprecated feature was likely used in the cosmosR package.
## Please report the issue at <https://github.com/saezlab/COSMOSR/issues>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
load("data/cosmos/cosmos_inputs.RData")
names(cosmos_inputs)
## [1] "786-0" "A498" "A549/ATCC" "ACHN" "BT-549"
## [6] "CAKI-1" "CCRF-CEM" "COLO 205" "DU-145" "EKVX"
## [11] "HCC-2998" "HCT-116" "HCT-15" "HL-60(TB)" "HOP-62"
## [16] "HOP-92" "HS 578T" "HT29" "IGROV1" "K-562"
## [21] "KM12" "LOX IMVI" "M14" "MALME-3M" "MCF7"
## [26] "MDA-MB-435" "MOLT-4" "NCI-H226" "NCI-H23" "NCI-H322M"
## [31] "NCI-H460" "NCI-H522" "NCI/ADR-RES" "OVCAR-3" "OVCAR-4"
## [36] "OVCAR-5" "OVCAR-8" "PC-3" "RPMI-8226" "SF-268"
## [41] "SF-295" "SF-539" "SK-MEL-28" "SK-MEL-5" "SK-OV-3"
## [46] "SN12C" "SNB-19" "SNB-75" "SR" "SW-620"
## [51] "T-47D" "TK-10" "U251" "UACC-257" "UACC-62"
## [56] "UO-31"
cell_line <- "786-0"
#see scripts/prepare_cosmos_inputs.R
sig_input <- cosmos_inputs[[cell_line]]$TF_scores
metab_input <- cosmos_inputs[[cell_line]]$metabolomic
RNA_input <- cosmos_inputs[[cell_line]]$RNA
#Choose which compartment to assign to the metabolic measurments
metab_input <- prepare_metab_inputs(metab_input, c("c","m"))
## [1] "Adding compartment codes."
##Filter significant inputs
sig_input <- sig_input[abs(sig_input) > 2]
# metab_input <- metab_input[abs(metab_input) > 2]
Filter inputs and prior knowledge network
#Remove genes that are not expressed from the meta_network
meta_network <- cosmosR:::filter_pkn_expressed_genes(names(RNA_input), meta_pkn = meta_network)
## [1] "COSMOS: removing unexpressed nodes from PKN..."
## [1] "COSMOS: 20357 interactions removed"
#Filter inputs and prune the meta_network to only keep nodes that can be found downstream of the inputs
#The number of step is quite flexible, 7 steps already covers most of the network
n_steps <- 6
# in this step we prune the network to keep only the relevant part between upstream and downstream nodes
sig_input <- cosmosR:::filter_input_nodes_not_in_pkn(sig_input, meta_network)
## [1] "COSMOS: 12 input/measured nodes are not in PKN any more: CEBPA, ESR1, FOS, FOXA1, GATA3, HNF4A and 6 more."
meta_network <- cosmosR:::keep_controllable_neighbours(meta_network, n_steps, names(sig_input))
## [1] "COSMOS: removing nodes that are not reachable from inputs within 6 steps"
## [1] "COSMOS: 26540 from 37740 interactions are removed from the PKN"
metab_input <- cosmosR:::filter_input_nodes_not_in_pkn(metab_input, meta_network)
## [1] "COSMOS: 195 input/measured nodes are not in PKN any more: Metab__HMDB0011747_c, Metab__HMDB0000755_c, Metab__HMDB0000905_c, Metab__HMDB0001191_c, Metab__HMDB0000355_c, Metab__HMDB0000479_c and 189 more."
meta_network <- cosmosR:::keep_observable_neighbours(meta_network, n_steps, names(metab_input))
## [1] "COSMOS: removing nodes that are not observable by measurements within 6 steps"
## [1] "COSMOS: 3657 from 11200 interactions are removed from the PKN"
sig_input <- cosmosR:::filter_input_nodes_not_in_pkn(sig_input, meta_network)
## [1] "COSMOS: 4 input/measured nodes are not in PKN any more: CTCF, EPAS1, ETS1, USF1 and 0 more."
#compress the network
meta_network_compressed_list <- compress_same_children(meta_network, sig_input = sig_input, metab_input = metab_input)
meta_network_compressed <- meta_network_compressed_list$compressed_network
node_signatures <- meta_network_compressed_list$node_signatures
duplicated_parents <- meta_network_compressed_list$duplicated_signatures
meta_network_compressed <- meta_network_cleanup(meta_network_compressed)