Skip to content

Commit

Permalink
tutorial cci
Browse files Browse the repository at this point in the history
  • Loading branch information
L7991-lian committed May 14, 2024
1 parent 638f492 commit 402afab
Show file tree
Hide file tree
Showing 107 changed files with 4,251 additions and 477 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Imports:
pheatmap,
pbapply,
Expand Down
15 changes: 13 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(CACIMAR_cols)
export(Caculate_cell_pair_cci_score)
export(Caculate_cell_pair_cci_score2)
export(ChordDiagram)
export(FormatConservedMarkers)
export(Format_Markers_Frac)
Expand All @@ -10,25 +12,34 @@ export(Identify_ConservedCellTypes)
export(Identify_ConservedMarkers)
export(Identify_ConservedNetworks)
export(Identify_Conserved_CCI)
export(Identify_Conserved_CCI1)
export(Identify_Conserved_CCI2)
export(Identify_Conserved_LR)
export(Identify_Markers)
export(Merge_data_for_heatmap)
export(Make_ChordDiagram_data)
export(Make_ChordDiagram_data2)
export(Plot_Celltype.Communication)
export(Plot_MarkersHeatmap)
export(Plot_Species_CellType_Tree)
export(Plot_phylogenetic_tree)
export(add_cellchat_prob)
export(buildHomDatabase)
export(calculate_Weights)
export(conserved_interaction_score)
export(create_sankey)
export(get_average_expression)
export(identify_conserved_gene)
export(identify_conserved_marker)
export(identify_conserved_pair)
export(identify_ct_ConservedNetworks)
export(identify_network_relationships)
export(make_pheatmap_LR_data)
export(make_pheatmap_LR_data1)
export(perform_CCI_analysis)
export(pheatmap_LR)
export(pheatmap_LR1)
export(pheatmap_LR_multi)
export(phylogenetic_tree_circle)
export(plot_interaction_heatmap)
import(igraph)
importFrom(Seurat,FindAllMarkers)
importFrom(Seurat,GetAssayData)
Expand Down
158 changes: 0 additions & 158 deletions R/Average_expression_heatmap.R

This file was deleted.

12 changes: 8 additions & 4 deletions R/Cell_Cell_interaction_sankey.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ create_sankey <- function(links,
#' @param select_DB character, databased used for analysis, more option can run liana::show_resources()
#' @param target_organism ncbi_taxid' or 'name' of the target organism. See ‘show_homologene' for available organisms via OmnipathR’s 'HomoloGene'
#' @param method character, method use for cell-cell interaction analysis. By default, we set it to SingleCellSignalR
#' @param LRscore_threshold numeric, the threshold the filter the cell-cell interactions, the larger the lesser interactions left
#' @param scale_score logical, whether scale the score of the interaction,default is TRUE
#'
#' @return data frame of cell cell interaction analysis result
#' @export
Expand All @@ -164,14 +166,18 @@ create_sankey <- function(links,
#'
# Zebrafish analysis
#'SingleCellSignalR_zebrafish_result <- perform_CCI_analysis(seurat_obj=Zf_seurat, target_organism=7955)
perform_CCI_analysis <- function(seurat_obj, expre_cell = 10, select_DB = "Consensus", target_organism, method = 'sca') {
perform_CCI_analysis <- function(seurat_obj, expre_cell = 10, select_DB = "Consensus", target_organism, method = 'sca', LRscore_threshold = 0.5, scale_score = TRUE) {
seurat_obj <- seurat_obj[apply(GetAssayData(seurat_obj, slot = "counts"), 1, function(x) sum(x > 0) > expre_cell),]
op_resource <- liana::select_resource(select_DB)[[1]]
ortholog_resource <- liana::generate_homologs(op_resource = op_resource, target_organism = target_organism)
liana_result <- liana::liana_wrap(seurat_obj,
method = method,
resource = 'custom',
external_resource = ortholog_resource)
liana_result <- liana_result[, LRscore > LRscore_threshold]
if (scale_score) {
liana_result$LRscore_scale <- liana_result$LRscore/sum(liana_result$LRscore)
}
return(liana_result)
}

Expand Down Expand Up @@ -206,7 +212,6 @@ calculate_Weights <- function(
specie_name = specie_name1)
species2_all_weight_df_long <- calculateWeights(data = species2_cci,
specie_name = specie_name2)
# bind df
all_weight_df_long <- rbind(species1_all_weight_df_long, species2_all_weight_df_long)
all_weight_df_long <- subset(all_weight_df_long, weight > 0)
all_weight_df_long$Source <- paste0(all_weight_df_long$species, all_weight_df_long$source)
Expand All @@ -219,9 +224,8 @@ calculate_Weights <- function(
all_weight_df_long$target[which(all_weight_df_long$species == specie_name2)] <- edit_target
return(all_weight_df_long)
}

calculateWeights <- function(data, specie_name) {
ccc_weight <- reshape2::dcast(data[, c(2, 3, 11)],
ccc_weight <- reshape2::dcast(data[, c("source", "target", "LRscore")],
source ~ target,
sum,
value.var = 'LRscore')
Expand Down
Loading

0 comments on commit 402afab

Please sign in to comment.