Skip to content

Commit

Permalink
Merge pull request #128 from FertigLab/123-triple-col-is-bad-for-exam…
Browse files Browse the repository at this point in the history
…ples

123 triple col is bad for examples
  • Loading branch information
jmitchell81 authored Jul 2, 2024
2 parents 5bf6447 + 95a9490 commit b577a50
Show file tree
Hide file tree
Showing 57 changed files with 823 additions and 561 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dominoSignal
Title: Cell Communication Analysis for Single Cell RNA Sequencing
Version: 0.99.2
Version: 0.99.3
Authors@R: c(
person("Christopher", "Cherry", role = c("aut"), email = "[email protected]", comment = c(ORCID = "0000-0002-5481-0055")),
person("Jacob T", "Mitchell", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-5370-9692")),
Expand Down Expand Up @@ -31,7 +31,7 @@ Imports:
License: GPL-3 | file LICENSE
Encoding: UTF-8
LazyData: false
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
biocViews:
SystemsBiology,
SingleCell,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export(feat_heatmap)
export(gene_network)
export(incoming_signaling_heatmap)
export(mean_ligand_expression)
export(mock_linkage_summary)
export(plot_differential_linkages)
export(rename_clusters)
export(signaling_heatmap)
Expand Down
10 changes: 5 additions & 5 deletions R/class_definitions.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ linkage_summary <- setClass(
#' @return A printed description of the number of cells and clusters in the domino object
#' @export
#' @examples
#' print(dominoSignal:::pbmc_dom_built_tiny)
#'
#' example(build_domino)
#' print(pbmc_dom_built_tiny)
#'
setMethod("print", "domino", function(x, ...) {
if (x@misc$build) {
message(
Expand All @@ -106,9 +107,8 @@ setMethod("print", "domino", function(x, ...) {
#' @return A printed description of cell numbers and clusters in the object
#' @export
#' @examples
#' dominoSignal:::pbmc_dom_built_tiny
#'
#' show(dominoSignal:::pbmc_dom_built_tiny)
#' example(build_domino)
#' show(pbmc_dom_built_tiny)
#'
setMethod("show", "domino", function(object) {
if (object@misc$build) {
Expand Down
3 changes: 2 additions & 1 deletion R/convenience_fxns.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ NULL
#' @return A domino object with clusters renamed in all applicable slots.
#' @export
#' @examples
#' example(build_domino)
#' new_clust <- c("CD8_T_cell" = "CD8+ T Cells",
#' "CD14_monocyte" = "CD14+ Monocytes", "B_cell" = "B Cells")
#' pbmc_dom_built_tiny <- rename_clusters(dominoSignal:::pbmc_dom_built_tiny, new_clust)
#' pbmc_dom_built_tiny <- rename_clusters(pbmc_dom_built_tiny, new_clust)
#'
rename_clusters <- function(dom, clust_conv, warning = FALSE) {
if (is.null(dom@clusters)) {
Expand Down
47 changes: 47 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#' SCENIC AUC subset
#'
#' A subset of SCENIC AUCs as applied to PBMC data.
#'
#' @format A list of:
#' \describe{
#' \item{auc_tiny}{A subset of SCENIC AUCs}
#' \item{regulons_tiny}{A subset of SCENIC regulons}
#' }
#'
#' @source <https://zenodo.org/records/10951634/files>
#' @usage data("SCENIC")
"SCENIC"


#' PBMC RNAseq data subset
#'
#' A subset of the results of PBMC RNA-seq data.
#'
#' @format A list of::
#' \describe{
#' \item{RNA_count_tiny}{A subset of PBMC RNA-seq data: counts assay}
#' \item{RNA_zscore_tiny}{A subset of PBMC RNA-seq data: zscore assay}
#' \item{clusters_tiny}{A subset of PBMC RNA-seq data: clusters as defined by cell_type}
#' }
#'
#' @source <https://zenodo.org/records/10951634/files/pbmc3k_sce.rds>
#' @usage data("PBMC")
"PBMC"


#' CellPhoneDB subset
#'
#' A list of four subsets of CellPhoneDB data.
#'
#'
#' @format A list of:
#' \describe{
#' \item{genes_tiny}{A subet of CellPhoneDB gene_input.csv}
#' \item{proteins_tiny}{A subset of CellPhoneDB protein_input.csv}
#' \item{complexes_tiny}{A subset of CellPhoneDB complex_input.csv}
#' \item{interactions_tiny}{A subset of CellPhoneDB interaction_input.csv}
#' }
#'
#' @source <https://github.com/ventolab/cellphonedb-data/archive/refs/tags/v4.0.0.tar.gz>
#' @usage data("CellPhoneDB")
"CellPhoneDB"
47 changes: 40 additions & 7 deletions R/differential_fxns.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,47 @@ NULL
#' @param subject_names vector of subject names in domino_results. If NULL, defaults to first column of subject_meta.
#' @return A linkage summary class object consisting of nested lists of the active transcription factors, active receptors, and incoming ligands for each cluster across multiple domino results
#' @export
#' @examples
#' dom_ls <- dominoSignal:::dom_ls_tiny
#' @examples
#' example(build_domino)
#'
#' #create alternative clustering
#' clusters_tiny_alt <- setNames(c(121:240, 1:120, 241:360), names(PBMC$clusters_tiny))
#' clusters_tiny_alt <- as.factor(clusters_tiny_alt)
#'
#' #build an alternative domino object
#' pbmc_dom_tiny_alt <- create_domino(
#' rl_map = rl_map_tiny,
#' features = SCENIC$auc_tiny,
#' counts = PBMC$RNA_count_tiny,
#' z_scores = PBMC$RNA_zscore_tiny,
#' clusters = clusters_tiny_alt,
#' tf_targets = regulon_list_tiny,
#' use_clusters = TRUE,
#' use_complexes = TRUE,
#' remove_rec_dropout = FALSE
#' )
#'
#' pbmc_dom_built_tiny_alt <- build_domino(
#' dom = pbmc_dom_tiny_alt,
#' min_tf_pval = .05,
#' max_tf_per_clust = Inf,
#' max_rec_per_tf = Inf,
#' rec_tf_cor_threshold = .1,
#' min_rec_percentage = 0.01
#' )
#'
#' #create a list of domino objects
#' dom_ls <- list(
#' dom1 = pbmc_dom_built_tiny,
#' dom2 = pbmc_dom_built_tiny_alt
#')
#'
#' #compare the linkages across the two domino objects
#' meta_df <- data.frame("ID" = c("dom1", "dom2"), "group" = c("A", "B"))
#' summarize_linkages(
#' domino_results = dom_ls, subject_meta = meta_df,
#' domino_results = dom_ls, subject_meta = meta_df,
#' subject_names = meta_df$ID
#')
#'
summarize_linkages <- function(domino_results, subject_meta, subject_names = NULL) {
if (!is(domino_results, "list")) {
stop("domino_results must be provided as a named list where names correspond to subject names")
Expand Down Expand Up @@ -108,7 +141,7 @@ summarize_linkages <- function(domino_results, subject_meta, subject_names = NUL
#' @export
#' @examples
#' count_linkage(
#' linkage_summary = dominoSignal:::linkage_sum_tiny, cluster = "C1",
#' linkage_summary = mock_linkage_summary(), cluster = "C1",
#' group.by = "group", linkage = "rec")
#'
count_linkage <- function(linkage_summary, cluster, group.by = NULL, linkage = "rec_lig", subject_names = NULL) {
Expand Down Expand Up @@ -169,8 +202,8 @@ count_linkage <- function(linkage_summary, cluster, group.by = NULL, linkage = "
#' }
#' @export
#' @examples
#' test_differential_linkages(
#' linkage_summary = dominoSignal:::linkage_sum_tiny, cluster = "C1", group.by = "group",
#' tiny_differential_linkage_c1 <- test_differential_linkages(
#' linkage_summary = mock_linkage_summary(), cluster = "C1", group.by = "group",
#' linkage = "rec", test_name = "fishers.exact"
#' )
#'
Expand Down
50 changes: 30 additions & 20 deletions R/import_fxns.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ NULL
#' @return Data frame where each row describes a possible receptor-ligand interaction
#' @export create_rl_map_cellphonedb
#' @examples
#' rl_map_tiny <- create_rl_map_cellphonedb(genes = dominoSignal:::genes_tiny,
#' proteins = dominoSignal:::proteins_tiny, interactions = dominoSignal:::interactions_tiny,
#' complexes = dominoSignal:::complexes_tiny)
#' data(CellPhoneDB)
#' rl_map_tiny <- create_rl_map_cellphonedb(genes = CellPhoneDB$genes_tiny,
#' proteins = CellPhoneDB$proteins_tiny,
#' interactions = CellPhoneDB$interactions_tiny,
#' complexes =CellPhoneDB$complexes_tiny)
#'
create_rl_map_cellphonedb <- function(
genes, proteins, interactions, complexes = NULL, database_name = "CellPhoneDB",
Expand Down Expand Up @@ -242,7 +244,8 @@ create_rl_map_cellphonedb <- function(
#' @return A list where names are transcription factors and the stored values are character vectors of genes in the inferred regulons
#' @export create_regulon_list_scenic
#' @examples
#' regulon_list_tiny <- create_regulon_list_scenic(regulons = dominoSignal:::regulons_tiny)
#' data(SCENIC)
#' regulon_list_tiny <- create_regulon_list_scenic(regulons = SCENIC$regulons_tiny)
#'
create_regulon_list_scenic <- function(regulons) {
if (is(regulons, "character")) {
Expand Down Expand Up @@ -293,21 +296,26 @@ create_regulon_list_scenic <- function(regulons) {
#' @param tf_variance_quantile What proportion of variable features to take if using variance to threshold features. Default is 0.5. Higher numbers will keep more features. Ignored if tf_selection_method is not 'variable'
#' @return A domino object
#' @export create_domino
#' @examples
#' pbmc_dom_tiny_all <- create_domino(
#' rl_map = dominoSignal:::rl_map_tiny, features = dominoSignal:::auc_tiny,
#' counts = dominoSignal:::RNA_count_tiny, z_scores = dominoSignal:::RNA_zscore_tiny,
#' clusters = dominoSignal:::clusters_tiny, tf_targets = dominoSignal:::regulon_list_tiny,
#' use_clusters = FALSE, use_complexes = FALSE,
#' @examples
#' example(create_rl_map_cellphonedb)
#' example(create_regulon_list_scenic)
#' data(SCENIC)
#' data(PBMC)
#'
#' pbmc_dom_tiny <- create_domino(
#' rl_map = rl_map_tiny, features = SCENIC$auc_tiny,
#' counts = PBMC$RNA_count_tiny, z_scores = PBMC$RNA_zscore_tiny,
#' clusters = PBMC$clusters_tiny, tf_targets = regulon_list_tiny,
#' use_clusters = TRUE, use_complexes = TRUE, remove_rec_dropout = FALSE)
#'
#' pbmc_dom_tiny_no_clusters <- create_domino(
#' rl_map = rl_map_tiny, features = SCENIC$auc_tiny,
#' counts = PBMC$RNA_count_tiny, z_scores =PBMC$RNA_zscore_tiny,
#' clusters = PBMC$clusters_tiny, tf_targets = regulon_list_tiny,
#' use_clusters = FALSE, use_complexes = FALSE,
#' rec_min_thresh = 0.1, remove_rec_dropout = TRUE,
#' tf_selection_method = "all")
#'
#' pbmc_dom_tiny_clustered <- create_domino(
#' rl_map = dominoSignal:::rl_map_tiny, features = dominoSignal:::auc_tiny,
#' counts = dominoSignal:::RNA_count_tiny, z_scores = dominoSignal:::RNA_zscore_tiny,
#' clusters = dominoSignal:::clusters_tiny, tf_targets = dominoSignal:::regulon_list_tiny,
#' use_clusters = TRUE, use_complexes = TRUE, remove_rec_dropout = FALSE)
#'
#'
create_domino <- function(
rl_map, features, counts = NULL, z_scores = NULL,
clusters = NULL, use_clusters = TRUE, tf_targets = NULL, verbose = TRUE,
Expand Down Expand Up @@ -633,9 +641,10 @@ convert_genes <- function(
#' @return An updated RL signaling data frame
#' @export
#' @examples
#' example(create_rl_map_cellphonedb)
#' lr_name <- data.frame("abbrev" = c("L", "R"), "full" = c("Ligand", "Receptor"))
#' rl_map_expanded <- add_rl_column(map = dominoSignal:::rl_map_tiny, map_ref = "type_A",
#' conv = lr_name, new_name = "type_A_full")
#' rl_map_expanded <- add_rl_column(map = rl_map_tiny, map_ref = "type_A",
#' conv = lr_name, new_name = "type_A_full")
#'
add_rl_column <- function(map, map_ref, conv, new_name) {
map_in_ref <- match(map[[map_ref]], conv[, 1])
Expand Down Expand Up @@ -676,7 +685,8 @@ add_rl_column <- function(map, map_ref, conv, new_name) {
#' @return A data frame of ligand expression targeting the specified receptor
#' @export
#' @examples
#' counts <- dom_counts(dominoSignal:::pbmc_dom_built_tiny)
#' example(build_domino)
#' counts <- dom_counts(pbmc_dom_built_tiny)
#' mean_exp <- mean_ligand_expression(counts,
#' ligands = c("PTPRC", "FASLG"), cell_ident = "CD14_monocyte",
#' cell_barcodes = colnames(counts), destination = "FAS")
Expand Down
Loading

0 comments on commit b577a50

Please sign in to comment.