Title: | InterCellar: an R-Shiny app for interactive analysis and exploration of cell-cell communication in single-cell transcriptomics |
---|---|
Description: | InterCellar is implemented as an R/Bioconductor Package containing a Shiny app that allows users to interactively analyze cell-cell communication from scRNA-seq data. Starting from precomputed ligand-receptor interactions, InterCellar provides filtering options, annotations and multiple visualizations to explore clusters, genes and functions. Finally, based on functional annotation from Gene Ontology and pathway databases, InterCellar implements data-driven analyses to investigate cell-cell communication in one or multiple conditions. |
Authors: | Marta Interlandi [cre, aut] |
Maintainer: | Marta Interlandi <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.13.0 |
Built: | 2024-11-30 05:21:49 UTC |
Source: | https://github.com/bioc/InterCellar |
Perform GO annotation of input data
annotateGO( input_select_ensembl, input_go_evidence_exclude, input_go_sources_checkbox, input.data )
annotateGO( input_select_ensembl, input_go_evidence_exclude, input_go_sources_checkbox, input.data )
input_select_ensembl |
ensembl version selected by user |
input_go_evidence_exclude |
evidence codes to exclude by user |
input_go_sources_checkbox |
GO sources to use by user |
input.data |
preprocessed input data |
GO_annotation
Annotate pathways for input data
annotatePathways(selected.db, input.data)
annotatePathways(selected.db, input.data)
selected.db |
pathways sources to use |
input.data |
filtered input data |
pathways_annotation
Build binary matrix with int-pairs in rows, functions in cols
buildPairsbyFunctionMatrix(functions_df)
buildPairsbyFunctionMatrix(functions_df)
functions_df |
annotated df (GO/path/combined) |
binary matrix
Manually change the annotation of L-L and R-R pairs
checkLL_RR(input.data)
checkLL_RR(input.data)
input.data |
preprocessed table |
input.data
data(input.data) checked.input.data <- checkLL_RR(input.data)
data(input.data) checked.input.data <- checkLL_RR(input.data)
Plot circle plot
circlePlot(data, cluster_colors, ipm_color, int_flow, link.color)
circlePlot(data, cluster_colors, ipm_color, int_flow, link.color)
data |
subset of input data by flow / intpair module |
cluster_colors |
global |
ipm_color |
single color for chosen int-pair module |
int_flow |
string specifying the flow |
link.color |
string specifying variable by which to color links |
circle plot
Combine GO annotation and pathways in a unique object
combineAnnotations(GO_annotation, pathways_annotation)
combineAnnotations(GO_annotation, pathways_annotation)
GO_annotation |
data |
pathways_annotation |
data |
combined annotation dataframe
Create Barplot cluster-verse
createBarPlot_CV( barplotDF, input_cluster_selected_checkbox, input_num_or_weight_bar1 )
createBarPlot_CV( barplotDF, input_cluster_selected_checkbox, input_num_or_weight_bar1 )
barplotDF |
dataframe with N interactions per cluster (auto/para) |
input_cluster_selected_checkbox |
checkbox input |
input_num_or_weight_bar1 |
number of int or weighted number by score |
plotly barplot
Create ggplot barplot to be saved in tiff
createBarPlot1_ggplot( barplotDF, input_cluster_selected_checkbox, input_num_or_weight_bar1 )
createBarPlot1_ggplot( barplotDF, input_cluster_selected_checkbox, input_num_or_weight_bar1 )
barplotDF |
dataframe with N interactions per cluster (auto/para) |
input_cluster_selected_checkbox |
checkbox input |
input_num_or_weight_bar1 |
number of int or weighted number by score |
ggplot barplot
Create barplot of number of interaction for selected cluster
createBarPlot2_CV( barplotDF2, input_cluster_selected_checkbox, input_clust_barplot2 )
createBarPlot2_CV( barplotDF2, input_cluster_selected_checkbox, input_clust_barplot2 )
barplotDF2 |
dataframe with barplot data |
input_cluster_selected_checkbox |
selected clusters to keep |
input_clust_barplot2 |
selected cluster to plot |
plotly fig
Create ggplot barplot of Nint per cluster selected
createBarPlot2_ggplot( barplotDF2, input_cluster_selected_checkbox, input_clust_barplot2 )
createBarPlot2_ggplot( barplotDF2, input_cluster_selected_checkbox, input_clust_barplot2 )
barplotDF2 |
dataframe with barplot data |
input_cluster_selected_checkbox |
selected clusters to keep |
input_clust_barplot2 |
selected cluster to plot |
ggplot barplot
Create Network of clusters
createNetwork(data.filt.cluster, input_num_or_weight_radio, input_edge_weight)
createNetwork(data.filt.cluster, input_num_or_weight_radio, input_edge_weight)
data.filt.cluster |
filtered input data (by clusters) |
input_num_or_weight_radio |
either number of interactions or weighted by score |
input_edge_weight |
small,medium or large from user input |
list containing nodes and edges for network
Get dendrogram of int pair modules
dendroIntPairModules(pairs_func_matrix)
dendroIntPairModules(pairs_func_matrix)
pairs_func_matrix |
binary matrix pairs x functions |
list with dendrogram, hclust and umap
Given a list of x, y coordinates on a curve, function determines the elbow point of the curve.
elbowPoint(x, y)
elbowPoint(x, y)
x |
vector of x coordinates of points on the curve |
y |
vector of y coordinates of points on the curve |
highlight the maximum curvature to identify the elbow point (credit: 'github.com/agentlans')
an x, y coordinates of the elbow point.
Get html link to ensembl
ensemblLink(ensembl)
ensemblLink(ensembl)
ensembl |
symbol |
html link to website
Get back-to-back barplot for 2 conditions comparison
getBack2BackBarplot(tab_c1, tab_c2, lab_c1, lab_c2)
getBack2BackBarplot(tab_c1, tab_c2, lab_c1, lab_c2)
tab_c1 |
barplot dataframe generated by getBarplotDF() for condition 1 |
tab_c2 |
barplot dataframe generated by getBarplotDF() for condition 1 |
lab_c1 |
label for condition 1 |
lab_c2 |
label for condition 2 |
ggplot object
Get dataframe for plotting barplot (all clusters)
getBarplotDF( data.filt.bar, input_cluster_selected_checkbox, input_num_or_weight_bar1 )
getBarplotDF( data.filt.bar, input_cluster_selected_checkbox, input_num_or_weight_bar1 )
data.filt.bar |
filtered object (checkbox auto/para) |
input_cluster_selected_checkbox |
checkbox input |
input_num_or_weight_bar1 |
number of int or weighted number by score |
dataframe with number of interactions per cluster auto/para
Get dataframe for barplot (by cluster)
getBarplotDF2(filt.data, input_cluster_selected_checkbox, input_clust_barplot2)
getBarplotDF2(filt.data, input_cluster_selected_checkbox, input_clust_barplot2)
filt.data |
input data filtered in cluster-verse |
input_cluster_selected_checkbox |
selected clusters to keep |
input_clust_barplot2 |
selected cluster to plot |
dataframe with num int per cluster
Get cluster names only from sender cluster A
getClusterA_Names(input.data)
getClusterA_Names(input.data)
input.data |
preprocessed input data |
named list of clusters
Get colors for clusters
getClusterColors(input.data)
getClusterColors(input.data)
input.data |
preprocessed input data |
named vector with colors per cluster
Get clusters names from initial input data
getClusterNames(input.data)
getClusterNames(input.data)
input.data |
preprocessed input data |
named list of clusters
data(input.data) cluster_list <- getClusterNames(input.data)
data(input.data) cluster_list <- getClusterNames(input.data)
Creating edges dataframe for network of clusters
getClusterNetwork(input.data, input_num_or_weight_radio, input_edge_weight)
getClusterNetwork(input.data, input_num_or_weight_radio, input_edge_weight)
input.data |
preprocessed input data |
input_num_or_weight_radio |
either num of interactions or weighted by score |
input_edge_weight |
small,medium or large from user input |
edges dataframe
Get Clusters size
getClusterSize(cl, edges.df, input_num_or_weight_radio)
getClusterSize(cl, edges.df, input_num_or_weight_radio)
cl |
cluster name |
edges.df |
dataframe with edges for network |
input_num_or_weight_radio |
either num of interactions or weighted by score |
sum of n interactions or weighted num for that cluster
Get table of unique int-pairs/clust-pairs couplets
getDistinctCouplets( data_cond1, data_cond2, data_cond3 = NULL, lab_c1, lab_c2, lab_c3 = NULL )
getDistinctCouplets( data_cond1, data_cond2, data_cond3 = NULL, lab_c1, lab_c2, lab_c3 = NULL )
data_cond1 |
filt.data() corresponding to chosen condition 1 |
data_cond2 |
filt.data() corresponding to chosen condition 2 |
data_cond3 |
filt.data() corresponding to chosen condition 3 |
lab_c1 |
data label for condition 1 |
lab_c2 |
data label for condition 2 |
lab_c3 |
data label for condition 3 |
modified filt.data containing only unique couplets
Functions to plot DotPlots
getDotPlot_selInt( selected_tab, clust.order, low_color = "aquamarine", high_color = "#131780" )
getDotPlot_selInt( selected_tab, clust.order, low_color = "aquamarine", high_color = "#131780" )
selected_tab |
selected rows of filt.data by selection from gene table |
clust.order |
how to order clusters |
low_color |
of dotplot |
high_color |
of dotplot |
list with modified selected data and ggplot2 dotplot
Get table for gene-verse
getGeneTable(input.data)
getGeneTable(input.data)
input.data |
preprocessed input data |
gene table with unique intpairs (no connection to clusters)
data(input.data) gene_table <- getGeneTable(input.data)
data(input.data) gene_table <- getGeneTable(input.data)
Connection to Ensembl via biomaRt to get GO terms
getGObiomaRt(input_select_ensembl, input.data)
getGObiomaRt(input_select_ensembl, input.data)
input_select_ensembl |
chosen version of Ensembl |
input.data |
filtered input data |
dataframe with GO annotation
Subfunction to calculate significant functions by permutation test
getHitsf(mat, gpModules_assign)
getHitsf(mat, gpModules_assign)
mat |
binary matrix of functional terms by int-pairs |
gpModules_assign |
assignment of intpairs to modules |
matrix with hits
Example
Get subset of interactions corresponding to a certain viewpoint and flow
getIntFlow(vp, input.data, flow)
getIntFlow(vp, input.data, flow)
vp |
viewpoint cluster |
input.data |
preprocessed/filtered input data |
flow |
one among directed_out, directed_in or undirected |
subset of data
data(input.data) caf_out <- getIntFlow(vp = "CAF", input.data, flow = "directed_out")
data(input.data) caf_out <- getIntFlow(vp = "CAF", input.data, flow = "directed_out")
Calculate number of terms of a database
getNtermsBYdb(annotation)
getNtermsBYdb(annotation)
annotation |
data from either pathways, GO or combined |
number of terms by dataset
Get number of unique ligands and receptors
getNumLR(gene.table, type)
getNumLR(gene.table, type)
gene.table |
gene table of unique int-pairs |
type |
either L or R |
number of L or R genes
Get Pie Chart of unique couplets
getPieChart(data_dotplot)
getPieChart(data_dotplot)
data_dotplot |
same data used to generate dotplot |
pie chart
#' Get radar plot of relative numbers of interactions for a certain cell type #' #' @param tab_c1 barplot dataframe from Viewpoint generated by getBarplotDF2() containing data for condition 1 #' @param tab_c2 barplot dataframe from Viewpoint generated by getBarplotDF2() containing data for condition 2 #' @param tab_c3 barplot dataframe from Viewpoint generated by getBarplotDF2() containing data for condition 3 #' @param lab_c1 label for condition 1 #' @param lab_c2 label for condition 2 #' @param lab_c3 label for condition 3 #' @param cell_name label of cell type of interest #' #' @return plot #' @importFrom fmsb radarchart #' @importFrom data.table transpose getRadarPlot <- function(tab_c1, tab_c2, tab_c3, lab_c1, lab_c2, lab_c3, cell_name) if(is.null(tab_c3)) df <- merge(tab_c1, tab_c2, by = "Clusters", all = TRUE) colnames(df) <- c("Clusters", "nint_c1", "nint_c2") else df <- merge(tab_c1, tab_c2, by = "Clusters", all = TRUE) df <- merge(df, tab_c3, by = "Clusters", all = TRUE) colnames(df) <- c("Clusters", "nint_c1", "nint_c2", "nint_c3")
df[is.na(df)] <- 0
cluster_names <- df$Clusters # add max and min max_nint <- max(df[, -1]) df <- add_column(df, max_nint, .after = "Clusters") df <- add_column(df, "min_nint" = 0, .after = "max_nint")
radar_df <- data.table::transpose(df[, -1])
if(is.null(lab_c3)) rownames(radar_df) <- c("max", "min", lab_c1, lab_c2) else rownames(radar_df) <- c("max", "min", lab_c1, lab_c2, lab_c3)
colnames(radar_df) <- cluster_names
color <- c("#438ECC", "#E97778", "#00BA38")
fmsb::radarchart( radar_df, axistype = 1, # Customize the polygon pcol = color, pfcol = scales::alpha(color, 0.5), plwd = 2, plty = 1, # Customize the grid cglcol = "grey", cglty = 1, cglwd = 0.8, # Customize the axis axislabcol = "grey30", # Variable labels vlcex = 1.2, vlabels = colnames(radar_df), caxislabels = round(seq(from = 0, to = radar_df["max",1], length.out = 5)), title = cell_name ) legend( x = "bottomleft", legend = rownames(radar_df[-c(1,2),]), horiz = FALSE, bty = "n", pch = 20 , col = color, text.col = "black", cex = 1, pt.cex = 1.5 )
Get radar df of relative numbers of interactions for a certain cell type
getRadar_df(tab_c1, tab_c2, tab_c3, lab_c1, lab_c2, lab_c3)
getRadar_df(tab_c1, tab_c2, tab_c3, lab_c1, lab_c2, lab_c3)
tab_c1 |
barplot dataframe from Viewpoint generated by getBarplotDF2() containing data for condition 1 |
tab_c2 |
barplot dataframe from Viewpoint generated by getBarplotDF2() containing data for condition 2 |
tab_c3 |
barplot dataframe from Viewpoint generated by getBarplotDF2() containing data for condition 3 |
lab_c1 |
label for condition 1 |
lab_c2 |
label for condition 2 |
lab_c3 |
label for condition 3 |
df to be then used with fmsb radarchart
Get table with ranked functional terms
getRankedTerms(data.fun.annot)
getRankedTerms(data.fun.annot)
data.fun.annot |
annotated df (GO/path/combined) |
table with ranking
Wrapper for other functions to get significant table of func terms
getSignif_table( data_cond1, data_cond2, data_cond3, lab_c1, lab_c2, lab_c3, annot_cond1, annot_cond2, annot_cond3 )
getSignif_table( data_cond1, data_cond2, data_cond3, lab_c1, lab_c2, lab_c3, annot_cond1, annot_cond2, annot_cond3 )
data_cond1 |
filt.data() corresponding to chosen condition 1 |
data_cond2 |
filt.data() corresponding to chosen condition 2 |
data_cond3 |
filt.data() corresponding to chosen condition 3 |
lab_c1 |
data label for condition 1 |
lab_c2 |
data label for condition 2 |
lab_c3 |
data label for condition 3 |
annot_cond1 |
binary matrix int-pair by functions for cond1 |
annot_cond2 |
binary matrix int-pair by functions for cond2 |
annot_cond3 |
binary matrix int-pair by functions for cond3 |
list containing pvalue_df and unique_intpairs df
Calculate significant function per intpair module
getSignificantFunctions( subGenePairs_func_mat, gpModules_assign, rank.terms, input_maxPval )
getSignificantFunctions( subGenePairs_func_mat, gpModules_assign, rank.terms, input_maxPval )
subGenePairs_func_mat |
subset of binary mat |
gpModules_assign |
assignment of intpairs to modules |
rank.terms |
table of ranked functions |
input_maxPval |
threshold of significance |
table with significant functions
Get significance of functional terms related to unique int-pairs per condition
getSignificantFunctions_multiCond(sub_annot, unique_intpairs)
getSignificantFunctions_multiCond(sub_annot, unique_intpairs)
sub_annot |
annotation matrix subset to unique int-pairs |
unique_intpairs |
data.frame with unique int-pairs by condition |
data.frame with calculated pvalue of significance
Get Sunburst plot of selected functional terms
getSunburst( sel.data, func_selected, int_p_fun, cluster.colors, input_num_or_weight_radio )
getSunburst( sel.data, func_selected, int_p_fun, cluster.colors, input_num_or_weight_radio )
sel.data |
dataframe of selected functions |
func_selected |
the selected functional term |
int_p_fun |
dataframe with int pairs annotated to this function |
cluster.colors |
for plotting |
input_num_or_weight_radio |
either num of interactions or weighted by score |
plotly figure
Get UMAP for IP modules
getUMAPipModules(intPairs.dendro, gpModules_assign, ipm_colors)
getUMAPipModules(intPairs.dendro, gpModules_assign, ipm_colors)
intPairs.dendro |
list output of dendrogram |
gpModules_assign |
named vector of module assignment |
ipm_colors |
for intpair modules |
plotly umap
Plot dotplot containing only unique int-pair/cluster pairs with many conditions
getUniqueDotplot(data_dotplot, clust.order)
getUniqueDotplot(data_dotplot, clust.order)
data_dotplot |
table with selected int_pairs for multiple conditions |
clust.order |
how to order clusters |
ggplot object
Get table of unique int-pairs by condition
getUniqueIntpairs_byCond( data_cond1, data_cond2, data_cond3 = NULL, lab_c1, lab_c2, lab_c3 = NULL )
getUniqueIntpairs_byCond( data_cond1, data_cond2, data_cond3 = NULL, lab_c1, lab_c2, lab_c3 = NULL )
data_cond1 |
filt.data() corresponding to chosen condition 1 |
data_cond2 |
filt.data() corresponding to chosen condition 2 |
data_cond3 |
filt.data() corresponding to chosen condition 3 |
lab_c1 |
data label for condition 1 |
lab_c2 |
data label for condition 2 |
lab_c3 |
data label for condition 3 |
modified merged filt.data containing only unique intpairs
Get GO link
goLink(go_id)
goLink(go_id)
go_id |
string |
html link to website
A dataset obtained from Tirosh et al melanoma dataset, running CellPhoneDBv2. This data is generated by InterCellar running read.CPDBv2()
input.data
input.data
A data frame with 5638 rows and 11 variables:
interaction pair name, geneA & geneB
name, hgnc_symbol
name, hgnc_symbol
molecular type of geneA, either L (ligand) or R (receptor)
molecular type of geneB, either L (ligand) or R (receptor)
name of first cluster, either character or number
name of second cluster, either character or number
int-pair score as avg expression of geneA and geneB over clustA and clustB, decimal
int-pair pvalue, decimal
database from which the int-pair was retrieved
either autocrine or paracrine
Read dataframe of cell-cell communication from CellChat (ligand/receptor)
read.cellchat(file_tab)
read.cellchat(file_tab)
file_tab |
dataframe from cellchat |
input.data formatted for InterCellar
Output is a folder containing 4 .txt files - deconvoluted.txt: containing list of single genes and their mean expression in each cluster (not considered); - means.txt: containing list of interacting pairs with info regarding L/R, annotation strategy and mean value of all pairs over cluster couples. - pvalues.txt: same as means, but containing pvalue of each pair, for each cluster couple. - significant_means.txt: only means of those pairs that have pvalue < 0.05. Has one more column:rank. If the statistical analysis is not run, the folder would contain only deconvoluted and means
read.CPDBv2(folder)
read.CPDBv2(folder)
folder |
folder containing output |
input.data which is the pre-processed object with annotated L-R pairs
Read custom input file and re-structure it with InterCellar format
read.customInput(tab, separator)
read.customInput(tab, separator)
tab |
custom input table |
separator |
character that separates two elements of an interaction pair |
preprocessed table
Read ICELLNET dataframe
read.icellnet(tab, input_icellnet_CC, input_icellnet_dir)
read.icellnet(tab, input_icellnet_CC, input_icellnet_dir)
tab |
dataframe with int-pairs in "X" column, other columns as cell types |
input_icellnet_CC |
central cell name |
input_icellnet_dir |
direction of interaction either out or in |
pre-processed input data
SCSR description: the output folder is a collection of txt files, one for each clusters pair considered. The "paracrine" option looks for ligands expressed in cluster A and their associated receptors according to LRdb that are expressed in any other cluster but A. These interactions are labelled "paracrine". The interactions that involve a ligand and a receptor, both differentially expressed in their respective cell clusters according to the **edgeR** analysis performed by the **cluster_analysis()** function, are labelled "specific". The "autocrine" option searches for ligands expressed in cell cluster A and their associated receptors also expressed in A. These interactions are labelled "autocrine". Additionally, it searches for those associated receptors in the other cell clusters (not A) to cover the part of the signaling that is "autocrine" and "paracrine" simultaneously. These interactions are labelled "autocrine/paracrine". This file is a 4-column table: ligands, receptors, interaction types ("paracrine", "autocrine", "autocrine/paracrine" and "specific"), and the associated LRscore. InterCellar: rename autocrine|paracrine to paracrine
read.SCsignalR(folder)
read.SCsignalR(folder)
folder |
containing output from SingleCellSignalR, named cell-signaling |
input.data: preprocessed object with annotated L-R pairs
Run the Shiny Application
run_app(reproducible = TRUE)
run_app(reproducible = TRUE)
reproducible |
boolean for setting a seed, making plots reproducible |
a running instance of InterCellar
## Not run: run_app() ## End(Not run)
## Not run: run_app() ## End(Not run)
Subset int-pair by function matrices to unique int-pairs by condition
subsetAnnot_multiCond( annot_cond1, annot_cond2, annot_cond3, unique_intpairs, lab_c1, lab_c2, lab_c3 )
subsetAnnot_multiCond( annot_cond1, annot_cond2, annot_cond3, unique_intpairs, lab_c1, lab_c2, lab_c3 )
annot_cond1 |
binary matrix int-pair by functions for cond1 |
annot_cond2 |
binary matrix int-pair by functions for cond2 |
annot_cond3 |
binary matrix int-pair by functions for cond3 |
unique_intpairs |
table of unique int-pairs by condition |
lab_c1 |
label cond1 |
lab_c2 |
label cond2 |
lab_c3 |
label cond3 |
subset merged matrix
Subset pairs-function matrix by selected flow
subsetFuncMatBYFlow(pairs_func_matrix, flow_df)
subsetFuncMatBYFlow(pairs_func_matrix, flow_df)
pairs_func_matrix |
binary |
flow_df |
subset of input data by flow |
subset of binary mat
Swaps interaction pairs that are R-L to L-R
swap.RLint(RLint)
swap.RLint(RLint)
RLint |
subset of R-L interactions |
input data with ordered L-R pairs and L-L/R-R
Get html link to uniprot
uniprotLink(uniprot)
uniprotLink(uniprot)
uniprot |
symbol |
html link to website
Function that orders all interaction pairs as L-R. Leaves unchanged the R-R and L-L
updateInputLR(input.data)
updateInputLR(input.data)
input.data |
uploaded data |
ordered input data