prioritize_condition_specific_sender: prioritize_condition_specific_sender

View source: R/condition_specific_celltypes.R

prioritize_condition_specific_senderR Documentation

prioritize_condition_specific_sender

Description

prioritize_condition_specific_sender Perform the MultiNicheNet prioritization of cell-cell interactions. Focus on including condition-specific cell types as sender cells. This implies no DE information will be used for prioritization of ligands.

Usage

prioritize_condition_specific_sender(abundance_info, abundance_expression_info, condition_specific_celltypes, grouping_tbl, fraction_cutoff, contrast_tbl, sender_receiver_de, lr_network, ligand_activities_targets_DEgenes, scenario = "regular", ligand_activity_down = FALSE)

Arguments

abundance_info

Output from 'make_abundance_plots'

abundance_expression_info

Output from 'get_abundance_expression_info'

condition_specific_celltypes

Character vector of condition-specific cell types

grouping_tbl

Data frame showing the groups of each sample (and batches per sample if applicable) (columns: sample and group; and if applicable all batches of interest)

fraction_cutoff

Cutoff indicating the minimum fraction of cells of a cell type in a specific sample that are necessary to consider a gene (e.g. ligand/receptor) as expressed in a sample.

contrast_tbl

Data frame providing names for each of the contrasts in contrasts_oi in the 'contrast' column, and the corresponding group of interest in the 'group' column. Entries in the 'group' column should thus be present in the group_id column in the metadata. Example for ‘contrasts_oi = c("’A-(B+C+D)/3', 'B-(A+C+D)/3'")': 'contrast_tbl = tibble(contrast = c("A-(B+C+D)/3","B-(A+C+D)/3"), group = c("A","B"))'

sender_receiver_de

Output of 'combine_sender_receiver_de'

lr_network

Prior knowledge Ligand-Receptor network (columns: ligand, receptor)

ligand_activities_targets_DEgenes

Output of 'get_ligand_activities_targets_DEgenes'

scenario

Character vector indicating which prioritization weights should be used during the MultiNicheNet analysis. Currently 3 settings are implemented: "regular" (default), "lower_DE", and "no_frac_LR_expr". The setting "regular" is strongly recommended and gives each criterion equal weight. The setting "lower_DE" is recommended in cases your hypothesis is that the differential CCC patterns in your data are less likely to be driven by DE (eg in cases of differential migration into a niche). It halves the weight for DE criteria, and doubles the weight for ligand activity. "no_frac_LR_expr" is the scenario that will exclude the criterion "fraction of samples expressing the LR pair'. This may be beneficial in case of few samples per group.

ligand_activity_down

For prioritization based on ligand activity: consider the max of up- and downregulation ('TRUE') or consider only upregulated activity ('FALSE', default from version 2 on).

Value

List containing multiple data frames of prioritized senderLigand-receiverReceptor interactions (with sample- and group-based expression information), ligand activities and ligand-target links.

Examples

## Not run: 
library(dplyr)
lr_network = readRDS(url("https://zenodo.org/record/3260758/files/lr_network.rds"))
lr_network = lr_network %>% dplyr::rename(ligand = from, receptor = to) %>% dplyr::distinct(ligand, receptor)
ligand_target_matrix = readRDS(url("https://zenodo.org/record/3260758/files/ligand_target_matrix.rds"))
sample_id = "tumor"
group_id = "pEMT"
celltype_id = "celltype"
batches = NA
contrasts_oi = c("'High-Low','Low-High'")
contrast_tbl = tibble(contrast = c("High-Low","Low-High"), group = c("High","Low"))
min_cells = 10
metadata_abundance = SummarizedExperiment::colData(sce)[,c(sample_id, group_id, celltype_id)] 
colnames(metadata_abundance) =c("sample_id", "group_id", "celltype_id")
abundance_data = metadata_abundance %>% tibble::as_tibble() %>% dplyr::group_by(sample_id , celltype_id) %>% dplyr::count() %>% dplyr::inner_join(metadata_abundance %>% tibble::as_tibble() %>% dplyr::distinct(sample_id , group_id ))
abundance_data = abundance_data %>% dplyr::mutate(keep = n >= min_cells) %>% dplyr::mutate(keep = factor(keep, levels = c(TRUE,FALSE)))
abundance_data_receiver = process_info_to_ic(abund_data = abundance_data, ic_type = "receiver")
abundance_data_sender = process_info_to_ic(abund_data = abundance_data, ic_type = "sender")


celltype_info = get_avg_frac_exprs_abund(sce = sce, sample_id = sample_id, celltype_id =  celltype_id, group_id = group_id)

receiver_info_ic = process_info_to_ic(info_object = celltype_info, ic_type = "receiver", lr_network = lr_network)
sender_info_ic = process_info_to_ic(info_object = celltype_info, ic_type = "sender", lr_network = lr_network)
senders_oi = SummarizedExperiment::colData(sce)[,celltype_id] %>% unique()
receivers_oi = SummarizedExperiment::colData(sce)[,celltype_id] %>% unique()
sender_receiver_info = combine_sender_receiver_info_ic(sender_info = sender_info_ic,receiver_info = receiver_info_ic,senders_oi = senders_oi,receivers_oi = receivers_oi,lr_network = lr_network)

celltype_de = perform_muscat_de_analysis(
   sce = sce,
   sample_id = sample_id,
   celltype_id = celltype_id,
   group_id = group_id,
   batches = batches,
   contrasts = contrasts_oi)
   
sender_receiver_de = combine_sender_receiver_de(
 sender_de = celltype_de,
 receiver_de = celltype_de,
 senders_oi = senders_oi,
 receivers_oi = receivers_oi,
 lr_network = lr_network)
 
ligand_activities_targets_DEgenes = get_ligand_activities_targets_DEgenes(
   receiver_de = celltype_de,
   receivers_oi = receivers_oi,
   receiver_frq_df_group = celltype_info$frq_df_group,
   ligand_target_matrix = ligand_target_matrix)


sender_receiver_tbl = sender_receiver_de %>% dplyr::distinct(sender, receiver)
metadata_combined = SummarizedExperiment::colData(sce) %>% tibble::as_tibble() 
grouping_tbl = metadata_combined[,c(sample_id, group_id)] %>% tibble::as_tibble() %>% dplyr::distinct()
colnames(grouping_tbl) = c("sample","group") 

frac_cutoff = 0.05
prioritization_tables = generate_prioritization_tables(
    sender_receiver_info = sender_receiver_info,
    sender_receiver_de = sender_receiver_de,
    ligand_activities_targets_DEgenes = ligand_activities_targets_DEgenes,
    contrast_tbl = contrast_tbl,
    sender_receiver_tbl = sender_receiver_tbl,
    grouping_tbl = grouping_tbl,
    fraction_cutoff = frac_cutoff, abundance_data_receiver, abundance_data_sender)
    
condition_specific_celltypes = "CAFs"
abundance_info = make_abundance_plots(sce = sce, sample_id = sample_id, group_id = group_id, celltype_id =  celltype_id, min_cells = 10, senders_oi = senders_oi, receivers_oi = receivers_oi)
prioritization_tables_with_condition_specific_celltype_sender = prioritize_condition_specific_sender(
abundance_info = abundance_info
abundance_expression_info = abundance_expression_info, 
condition_specific_celltypes = condition_specific_celltypes, 
grouping_tbl = grouping_tbl, 
fraction_cutoff = fraction_cutoff, 
contrast_tbl = contrast_tbl, 
sender_receiver_de = sender_receiver_de, 
lr_network = lr_network, 
ligand_activities_targets_DEgenes = ligand_activities_targets_DEgenes,
scenario = "regular",
ligand_activity_down = FALSE
) 

   

## End(Not run)


saeyslab/multinichenetr documentation built on Jan. 15, 2025, 7:55 p.m.