forked from Elisseeff-Lab/domino
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge master branch so pkgdown will be up to date
- Loading branch information
Showing
243 changed files
with
28,454 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,3 @@ | |
^old\.README\.md$ | ||
^readme_images$ | ||
^scenic_bash$ | ||
^_pkgdown\.yml$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: Update Bioconductor package files | ||
|
||
on: | ||
workflow_dispatch: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: r-build-check | ||
on: | ||
push: | ||
branches: ['v0.2.2_development'] | ||
pull_request: | ||
branches: ['master', 'v0.2.2'] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-check: | ||
uses: FertigLab/actions/.github/workflows/r-build-check.yml@v1 | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,3 @@ R/.Rhistory | |
scenic/* | ||
|
||
scratch/ | ||
|
||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(add_rl_column) | ||
export(build_domino) | ||
export(circos_ligand_receptor) | ||
export(cor_heatmap) | ||
export(cor_scatter) | ||
export(count_linkage) | ||
export(create_domino) | ||
export(create_regulon_list_scenic) | ||
export(create_rl_map_cellphonedb) | ||
export(dom_clusters) | ||
export(dom_correlations) | ||
export(dom_counts) | ||
export(dom_database) | ||
export(dom_de) | ||
export(dom_info) | ||
export(dom_linkages) | ||
export(dom_network_items) | ||
export(dom_signaling) | ||
export(dom_tf_activation) | ||
export(dom_zscores) | ||
export(feat_heatmap) | ||
export(gene_network) | ||
export(incoming_signaling_heatmap) | ||
export(mean_ligand_expression) | ||
export(plot_differential_linkages) | ||
export(rename_clusters) | ||
export(signaling_heatmap) | ||
export(signaling_network) | ||
export(summarize_linkages) | ||
export(test_differential_linkages) | ||
exportClasses(domino) | ||
exportClasses(linkage_summary) | ||
import(ComplexHeatmap) | ||
import(biomaRt) | ||
import(circlize) | ||
import(grDevices) | ||
import(grid) | ||
import(methods) | ||
import(plyr) | ||
import(stats) | ||
importClassesFrom(Matrix,dgCMatrix) | ||
importFrom(Matrix,rowSums) | ||
importFrom(ggpubr,ggscatter) | ||
importFrom(igraph,E) | ||
importFrom(igraph,V) | ||
importFrom(igraph,graph) | ||
importFrom(igraph,layout_in_circle) | ||
importFrom(igraph,layout_on_sphere) | ||
importFrom(igraph,layout_randomly) | ||
importFrom(igraph,layout_with_fr) | ||
importFrom(igraph,layout_with_kk) | ||
importFrom(igraph,simplify) | ||
importFrom(utils,read.csv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# domino2 v0.2.2 | ||
|
||
## Linkage functions | ||
- Addition of new class to summarize linkages in objects | ||
- Addition of helper functions to count linkages and compare between objects | ||
- Plotting function for differential linkages | ||
|
||
## Package structure | ||
- Adjustments made to meet BioConductor standards | ||
|
||
# domino2 v0.2.1 | ||
|
||
## Updates to domino object construction | ||
- Uniform formats for inputs of receptor-ligand interaction databases, transcription factor activity features, and regulon gene lists for operability with alternative databases and transcription factor activation inference methods | ||
- Helper functions for reformatting pySCENIC outputs and CellPhoneDB database files to domino-readable uniform formats | ||
- Assessment of transcription factor linkage with receptors that function as a heteromeric complex based on correlation between transcription factor activity and all receptor component genes | ||
- Assessment of complex ligand expression as the mean of component gene expression for plotting functions | ||
- Minimum threshold for the percentage of cells in a cluster expressing a receptor gene for the receptor to be called active within the cluster | ||
- Additional linkage slots for active receptors in each cluster, transcription factor-receptor linkages for each cluster, and incoming ligands for active receptors on each cluster | ||
|
||
## Plotting functions | ||
- Chord plot of ligand expression targeting a specified receptor where chord widths correspond to the quantity of ligand expression by each cell cluster | ||
- Signaling networks showing only outgoing signaling from specified cell clusters | ||
- Gene networks between two cell clusters | ||
|
||
## Bugfixes | ||
- Added host option for gene ortholog conversions using `{biomaRt}` for access to maintained mirrors | ||
- Transcription factor-target linkages are now properly stored so that receptors in a transcription factor's regulon are excluded from linkage | ||
- Ligand nodes sizes in gene networks correspond to quantity of ligand expression | ||
- `create_domino()` can be run without providing a regulon list | ||
- References to the host GitHub repository have been updated to [Elisseeff-Lab](https://github.com/Elisseeff-Lab/domino) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#' @import methods | ||
#' @importClassesFrom Matrix dgCMatrix | ||
#' | ||
NULL | ||
#' The domino Class | ||
#' | ||
#' The domino class contains all information necessary to calculate receptor-ligand | ||
#' signaling. It contains z-scored expression, cell cluster labels, feature values, | ||
#' and a referenced receptor-ligand database formatted as a receptor-ligand map. | ||
#' Calculated intermediate values are also stored. | ||
#' | ||
#' @slot db_info List of data sets from lr database. | ||
#' @slot counts Raw count gene expression data | ||
#' @slot z_scores Matrix of z-scored expression data with cells as columns | ||
#' @slot clusters Named factor with cluster identity of each cell | ||
#' @slot features Matrix of features to correlate receptor-ligand expression with. Cells are columns and features are rows. | ||
#' @slot cor Correlation matrix of receptor expression to features. | ||
#' @slot linkages List of lists containing info linking cluster->tf->rec->lig | ||
#' @slot clust_de Data frame containing differential expression results for features by cluster. | ||
#' @slot misc List of miscellaneous info pertaining to run parameters etc. | ||
#' @slot cl_signaling_matrices Incoming signaling matrix for each cluster | ||
#' @slot signaling Signaling matrix between all clusters. | ||
#' @name domino-class | ||
#' @rdname domino-class | ||
#' @exportClass domino | ||
#' | ||
domino <- methods::setClass( | ||
Class = "domino", | ||
slots = c( | ||
db_info = "list", | ||
z_scores = "matrix", | ||
counts = "dgCMatrix", | ||
clusters = "factor", | ||
features = "matrix", | ||
cor = "matrix", | ||
linkages = "list", | ||
clust_de = "matrix", | ||
misc = "list", | ||
cl_signaling_matrices = "list", | ||
signaling = "matrix" | ||
), | ||
prototype = list( | ||
misc = list("build" = FALSE) | ||
) | ||
) | ||
#' The domino linkage summary class | ||
#' | ||
#' The linkage summary class contains linkages established in multiple domino | ||
#' objects through gene regulatory network inference and reference to receptor- | ||
#' ligand data bases. A data frame summarizing meta features that describe the | ||
#' domino objects compared in the linkage summary facilitates comparisons of | ||
#' established linkages and differential signaling interactions across categorical | ||
#' sample covariates. | ||
#' | ||
#' @slot subject_names unique names for each domino result included in the summary | ||
#' @slot subject_meta data.frame with each row describing one subject and columns describing features of the subjects by which to draw comparisons of signaling networks | ||
#' @slot subject_linkages nested list of linkages inferred for each subject. Lists are stored in a heirarchical structure of subject-cluster-linkage where linkages include transcription factors (tfs), linkages between transcription factors and receptors (tfs_rec), active receptors (rec), possible receptor-ligand interactions (rec_lig), and incoming ligands (incoming_lig) | ||
#' @name linkage_summary-class | ||
#' @rdname linkage_summary-class | ||
#' @exportClass linkage_summary | ||
#' | ||
linkage_summary <- setClass( | ||
Class = "linkage_summary", | ||
slots = c( | ||
subject_names = "factor", | ||
subject_meta = "data.frame", | ||
subject_linkages = "list" | ||
) | ||
) | ||
|
||
#' Print domino object | ||
#' | ||
#' Prints a summary of a domino object | ||
#' | ||
#' @param x Domino object | ||
#' @return a printed description of the number of cell clusters in the object | ||
#' @keywords internal | ||
#' @examples | ||
#' print(domino2:::pbmc_dom_built_tiny) | ||
#' | ||
setMethod("print", "domino", function(x, ...) { | ||
if (x@misc$build) { | ||
message( | ||
"A domino object of ", length(x@clusters), " cells | ||
Contains signaling between", | ||
length(levels(x@clusters)), "clusters | ||
Built with a maximum of", as.integer(x@misc$build_vars["max_tf_per_clust"]), | ||
"TFs per cluster | ||
and a maximum of", as.integer(x@misc$build_vars["max_rec_per_tf"]), | ||
"receptors per TF\n" | ||
) | ||
} else { | ||
message(c("A domino object of ", length(x@clusters), " cells\n", "A signaling network has not been built\n"), | ||
sep = "" | ||
) | ||
} | ||
}) | ||
#' Show domino object information | ||
#' | ||
#' Shows content overview of domino object | ||
#' | ||
#' @param object Domino object | ||
#' @return a printed description of the number of cells in a domino object and its build status | ||
#' @keywords internal | ||
#' @examples | ||
#' domino2:::pbmc_dom_built_tiny | ||
#' | ||
#' show(domino2:::pbmc_dom_built_tiny) | ||
#' | ||
setMethod("show", "domino", function(object) { | ||
if (object@misc$build) { | ||
cat(c( | ||
"A domino object of ", length(object@clusters), " cells\n", "Built with signaling between ", | ||
length(levels(object@clusters)), " clusters\n" | ||
), sep = "") | ||
} else { | ||
cat(c("A domino object of ", length(object@clusters), " cells\n", "A signaling network has not been built\n"), | ||
sep = "" | ||
) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#' @import plyr | ||
#' @import methods | ||
#' | ||
NULL | ||
|
||
#' Renames clusters in a domino object | ||
#' | ||
#' This function reads in a receptor ligand signaling database, cell level | ||
#' features of some kind (ie. output from pySCENIC), z-scored single cell data, | ||
#' and cluster id for single cell data, calculates a correlation matrix between | ||
#' receptors and other features (this is transcription factor module scores if | ||
#' using pySCENIC), and finds features enriched by cluster. It will return a | ||
#' domino object prepared for [build_domino()], which will calculate a signaling | ||
#' network. | ||
#' | ||
#' @param dom Domino object to rename clusters in | ||
#' @param clust_conv Named vector of conversions from old to new clusters. Values are taken as new clusters IDs and names as old cluster IDs. | ||
#' @return A domino object with clusters renamed in all applicable slots. | ||
#' @keywords internal | ||
#' @export | ||
#' @examples | ||
#' new_clust <- c("CD8_T_cell" = "CD8+ T Cells", | ||
#' "CD14_monocyte" = "CD14+ Monocytes", "B_cell" = "B Cells") | ||
#' pbmc_dom_built_tiny <- rename_clusters(domino2:::pbmc_dom_built_tiny, new_clust) | ||
#' | ||
rename_clusters <- function(dom, clust_conv) { | ||
if (is.null(dom@clusters)) { | ||
stop("There are no clusters in this domino object") | ||
} | ||
if (dom@misc$create) { | ||
dom@clusters <- revalue(dom@clusters, clust_conv) | ||
colnames(dom@clust_de) <- clust_conv | ||
names(colnames(dom@clust_de)) <- c() | ||
colnames(dom@misc$cl_rec_percent) <- clust_conv | ||
} | ||
if (dom@misc$build) { | ||
names(dom@linkages$clust_tf) <- clust_conv | ||
names(dom@linkages$clust_rec) <- clust_conv | ||
names(dom@linkages$clust_incoming_lig) <- clust_conv | ||
names(dom@linkages$clust_tf_rec) <- clust_conv | ||
colnames(dom@signaling) <- paste0("L_", clust_conv) | ||
rownames(dom@signaling) <- paste0("R_", clust_conv) | ||
names(dom@cl_signaling_matrices) <- clust_conv | ||
for (cl in clust_conv) { | ||
colnames(dom@cl_signaling_matrices[[cl]]) <- paste0("L_", clust_conv) | ||
} | ||
} | ||
return(dom) | ||
} | ||
|
||
#' Convert Genes Using Table | ||
#' | ||
#' Takes a vector of gene inputs and a conversion table and returns a | ||
#' converted gene table | ||
#' | ||
#' @param genes The genes to convert. | ||
#' @param from Gene symbol type of the input (ENSG, ENSMUSG, HGNC, MGI) | ||
#' @param to Desired gene symbol type for the output (HGNC, MGI) | ||
#' @param conversion_table A data.frame with column names corresponding to gene symbol types (mm.ens, hs.ens, mgi, hgnc) | ||
#' and rows corresponding to the gene symbols themselves | ||
#' @return Data frame of genes with original and corresponding converted symbols | ||
#' @keywords internal | ||
#' | ||
table_convert_genes <- function(genes, from, to, conversion_table) { | ||
# Check inputs: | ||
stopifnot(`Genes must be a vector of characters` = (is(genes, "character") & is(genes, "vector"))) | ||
stopifnot(`From must be one of ENSMUSG, ENSG, MGI, or HGNC` = from %in% c( | ||
"ENSMUSG", "ENSG", "MGI", | ||
"HGNC" | ||
)) | ||
stopifnot(`To must be one of MGI or HGNC` = to %in% c("MGI", "HGNC")) | ||
stopifnot(`Conversion table must be provided with at least two of column names mm.ens, hs.ens, mgi and/or hgnc` = (is( | ||
conversion_table, | ||
"data.frame" | ||
) & length(which(colnames(conversion_table) %in% c( | ||
"mm.ens", "hs.ens", "mgi", | ||
"hgnc" | ||
))) > 1)) | ||
if (from == "ENSMUSG") { | ||
col1 <- conversion_table$mm.ens | ||
} | ||
if (from == "ENSG") { | ||
col1 <- conversion_table$hs.ens | ||
} | ||
if (from == "MGI") { | ||
col1 <- conversion_table$mgi | ||
} | ||
if (from == "HGNC") { | ||
col1 <- conversion_table$hgnc | ||
} | ||
if (to == "MGI") { | ||
col2 <- conversion_table$mgi | ||
} | ||
if (to == "HGNC") { | ||
col2 <- conversion_table$hgnc | ||
} | ||
genesV2 <- cbind(col1[which(col1 %in% genes)], col2[which(col1 %in% genes)]) | ||
return(genesV2) | ||
} |
Oops, something went wrong.