library(LRLoop)
lr_network_nichenet = readRDS("Networks/NicheNet_lr_network.rds") # The ligand-receptor network collected in NicheNet
lr_network_NATMI = read.csv("Networks/NATMI_lrc2p.csv") # The ligand-receptor network collected in connectomeDB2020 for NATMI (Network Analysis Toolkit for the Multicellular Interactions)
lr_network_NATMI = cbind(lr_network_NATMI, rep('NATMI', nrow(lr_network_NATMI)), rep('NATMI', nrow(lr_network_NATMI)))
colnames(lr_network_NATMI) = c('from', 'to', 'source', 'database')
lr_network_NATMI = tibble(lr_network_NATMI)
lr_network_large = rbind(lr_network_nichenet, lr_network_NATMI) # Combine the ligand-receptor networks of interest
# Remark: as another example, we use the pre-filtered literature supported lr_network with the ligands and recepros filtered by the annotations in NATMI and CelltalkDB:
# lr_network = read.table("Networks/LR_network_202103.txt", header = TRUE)
# lr_network_large = tibble(lr_network[,c(1:4)])
new_network_weights_df = tibble(source = 'NATMI', weight = 1)
source_weights_df = source_weights_df %>% bind_rows(new_network_weights_df)
new_annotation_data_source = tibble(source = 'NATMI', database = 'NATMI', type_db = 'NATMI',
type_interaction = 'NATMI', network = 'ligand_receptor')
annotation_data_sources = rbind(annotation_data_sources, new_annotation_data_source)
sig_network = readRDS("Networks/NicheNet_signaling_network.rds")
gr_network = readRDS("Networks/NicheNet_gr_network.rds")
gr_network = mygr_network
new_network_weights_df = tibble(source = 'mygr', weight = 1)
source_weights_df = source_weights_df %>% bind_rows(new_network_weights_df)
new_annotation_data_source = tibble(source = 'mygr', database = 'mygr', type_db = 'mygr',
type_interaction = 'mygr', network = 'gene_regulatory')
annotation_data_sources = rbind(annotation_data_sources, new_annotation_data_source)
Remark: If mygr_network is prefered, also remove the original gr_network's data sources from source_weights_df in the next step
In this example, we remove the ppi predicted ligand-receptor pairs from the ligand-receptor network
data_sources_to_remove = annotation_data_sources %>% filter(database %in% c("ppi_prediction","ppi_prediction_go")) %>% pull(source)
data_sources_to_keep = annotation_data_sources$source %>% setdiff(data_sources_to_remove)
source_weights_df = source_weights_df %>% filter(source %in% data_sources_to_keep)
lr_network = lr_network_large %>% filter(source %in% data_sources_to_keep)
weighted_networks = construct_weighted_networks(lr_network = lr_network, sig_network = sig_network, gr_network = gr_network,
source_weights_df = source_weights_df)
weighted_networks = apply_hub_corrections(weighted_networks = weighted_networks,
lr_sig_hub = hyperparameter_list$lr_sig_hub, gr_hub = hyperparameter_list$gr_hub)
ligands = unique(as.list(as.data.frame(lr_network)[,'from']))
ligand_target_matrix = construct_ligand_target_matrix(weighted_networks = weighted_networks, ligands = ligands,
algorithm = "PPR",
damping_factor = hyperparameter_list$damping_factor,
ltf_cutoff = hyperparameter_list$ltf_cutoff)
weighted_networks = construct_weighted_networks(lr_network = lr_network, sig_network = sig_network, gr_network = gr_network,
source_weights_df = source_weights_df, n_output_networks = 3)
weighted_networks = apply_hub_corrections_noligand(weighted_networks = weighted_networks,
sig_hub = hyperparameter_list$lr_sig_hub, gr_hub = hyperparameter_list$gr_hub)
signaling_network = weighted_networks$sig
regulatory_network = weighted_networks$gr
allgenes = unique(c(signaling_network$from, signaling_network$to, regulatory_network$from, regulatory_network$to))
receptors = unique(as.list(intersect(as.data.frame(lr_network)[,'to'], allgenes)))
receptor_target_matrix = construct_receptor_target_matrix(weighted_networks = weighted_networks, receptors = receptors,
damping_factor = hyperparameter_list$damping_factor,
rtf_cutoff = hyperparameter_list$ltf_cutoff)
lr_network = lr_network %>% mutate(from = convert_human_to_mouse_symbols(from), to = convert_human_to_mouse_symbols(to)) %>% drop_na()
colnames(ligand_target_matrix) = ligand_target_matrix %>% colnames() %>% convert_human_to_mouse_symbols()
rownames(ligand_target_matrix) = ligand_target_matrix %>% rownames() %>% convert_human_to_mouse_symbols()
ligand_target_matrix = ligand_target_matrix %>% .[!is.na(rownames(ligand_target_matrix)), !is.na(colnames(ligand_target_matrix))]
colnames(receptor_target_matrix) = receptor_target_matrix %>% colnames() %>% convert_human_to_mouse_symbols()
rownames(receptor_target_matrix) = receptor_target_matrix %>% rownames() %>% convert_human_to_mouse_symbols()
receptor_target_matrix = receptor_target_matrix %>% .[!is.na(rownames(receptor_target_matrix)), !is.na(colnames(receptor_target_matrix))]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.