Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrh.dev #90

Draft
wants to merge 25 commits into
base: bioconductor
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0061099
Long commit, forgot to commit while working.
weshorton Feb 22, 2024
d4ea351
Update man for circos plot to include title
weshorton Feb 23, 2024
cfe736f
Update incoming_signaling_heatmap man to have the new display argumen…
weshorton Feb 23, 2024
805e565
Forgot to add the descriptions to incoming_signaling_heatmap
weshorton Feb 23, 2024
4813629
Update signaling_network man to have offset_sides option
weshorton Feb 23, 2024
062008d
Fix display_top/display_method mixup between signaling_heatmap and in…
weshorton Feb 23, 2024
d67b9f3
Add 'cr_signaling_matrices' and 'rec_signaling' slots to domino class…
weshorton Feb 26, 2024
0f34cf1
New function make_rl_reading that takes the rl_reading construction o…
weshorton Feb 26, 2024
e6168ce
Revert "New function make_rl_reading that takes the rl_reading constr…
weshorton Feb 26, 2024
50c876c
Add new function that is reverse of circos_ligand_receptor. To do: co…
weshorton Feb 26, 2024
80228a2
Update dom_linkages access function to recognize lig_rec
weshorton Feb 26, 2024
660128b
New function that takes a built domino object and calculates receptor…
weshorton Feb 26, 2024
508517b
Updated man file for linkages script
weshorton Feb 26, 2024
c62d516
Update feature heatmap to subset for specific clusters
weshorton Feb 26, 2024
a530ef4
Update namespace with new functions
weshorton Feb 26, 2024
479d764
Part 1 of large update to Sushma's outgoing_network code.
weshorton Feb 28, 2024
5fc194b
Part 2 of large update to Sushma's outgoing_network code.
weshorton Feb 28, 2024
42e5fd4
Add lig_rec to dom@linkages in create_domino
weshorton Feb 28, 2024
2c9f97c
Combined both circos plot versions into one generalized plot. Remove …
weshorton Feb 28, 2024
a8575ba
Add note to build_domino about possibly getting list of expressed lig…
weshorton Feb 28, 2024
b588a44
Add circos_ligand_receptor_general to NAMESPACE and remove circos_rec…
weshorton Feb 28, 2024
3fc3cb3
Add verbose option to outgoign_network to update which cluster is bei…
weshorton Feb 28, 2024
1f0d945
Add help markdown to circos_ligand_receptor_general. Also add multi_p…
weshorton Feb 29, 2024
bf09d03
Update gene_network function. Fixed the L_ substitution because it ge…
weshorton Mar 1, 2024
bb93e16
Changed stop()'s to warnings()'s for expression check so I can run ci…
weshorton Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Generated by roxygen2: do not edit by hand

export(add_rl_column)
export(avg_exp_for_complexes)
export(avg_reclig_expr)
export(build_domino)
export(circos_ligand_receptor)
export(circos_ligand_receptor_general)
export(cor_heatmap)
export(cor_scatter)
export(count_linkage)
Expand All @@ -23,9 +26,14 @@ export(dom_zscores)
export(feat_heatmap)
export(gene_network)
export(incoming_signaling_heatmap)
export(invert_rec_lig_expr)
export(invert_rec_lig_linkages)
export(mean_ligand_expression)
export(outgoing_network)
export(plot_differential_linkages)
export(rename_clusters)
export(resolve_complexes)
export(resolve_names)
export(signaling_heatmap)
export(signaling_network)
export(summarize_linkages)
Expand Down
4 changes: 3 additions & 1 deletion R/class_definitions.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ domino <- methods::setClass(
clust_de = "matrix",
misc = "list",
cl_signaling_matrices = "list",
signaling = "matrix"
cr_signaling_matrices = "list",
signaling = "matrix",
rec_signaling = "matrix"
),
prototype = list(
misc = list("build" = FALSE)
Expand Down
102 changes: 102 additions & 0 deletions R/convenience_fxns.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,105 @@ table_convert_genes <- function(genes, from, to, conversion_table) {
genesV2 <- cbind(col1[which(col1 %in% genes)], col2[which(col1 %in% genes)])
return(genesV2)
}

#' Resolve Names
#' @description
#' Return gene names of ligands with non-standard names
#' @param dom domino object
#' @param genes vector of gene names to resolve
#' @details Ligand names (which are stored in dom@linkages$rec_lig) do not always match the gene name
#' Search all provided names and output the gene name if the ligand name is non-standard
#' @return vector of length(genes) with applicable values replaced using dom@misc$rl_map information
#' @export
#'
resolve_names <- function(dom, genes, rec_lig = "lig") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sushma function, updated it to take either receptor or ligand

rl_map = dom@misc[["rl_map"]]
if (rec_lig == "lig") {
gene <- "L.gene"
name <- "L.name"
} else if (rec_lig == "rec") {
gene <- "R.gene"
name <- "R.name"
} else {
stop("rec_lig must be one of 'lig' or 'rec'.\n")
}

genes_resolved <- sapply(genes, function(l){
int <- rl_map[rl_map[[name]] == l, ][1,]
if((int[[name]] != int[[gene]]) & !grepl("\\,", int[[gene]])){
int[[gene]]
} else {
int[[name]]
}
})
return(genes_resolved)
} # resolve_names

#' Resolve Complexes
#' @description
#' Expand any complex names into their component gene names
#' @param dom domino object
#' @param genes vector of complex names to resolve
#' @details Ligand names (which are stored in dom@linkages$rec_lig) can refer to complexes that are
#' detailed in dom@linkages$complexes. Search all provided names and if the name is a complex, output component genes, otherwise output the name
#' @return list of length(genes), with names(list) == genes. List values are the same as the names if not in a complex and are the complex genes if they are in a complex.
#' @export
#'
resolve_complexes <- function(dom, genes) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sushma function

genes_list <- lapply(genes, function(l){
if(l %in% names(dom@linkages$complexes)){
return(dom@linkages$complexes[[l]])
} else {
return(l)
}
})
names(genes_list) <- genes
return(genes_list)
}

#' Get All Ligands
#' @description
#' Get all unique ligands present in dom@linkages$rec_lig
#' @param dom domino object
#' @param expressed_only logical indicating whether to subset ligands based on expression in dom@z_scores
#' @details Get all unique ligands in a domino object, expanding all ligand complexes as well. Optionally subset by expression.
#' @return vector of ligands if expressed_only = T, list if F
get_all_reclig <- function(dom, expressed_only = T, rec_lig = "rec") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code originally in Sushma's outgoing_network. Extracted here


### Vector of all ligands expressed
if (rec_lig == "rec") {
all <- unlist(dom@linkages$rec_lig)
resolve_rec_lig <- "lig"
} else if (rec_lig == "lig") {
if (!"lig_rec" %in% names(dom@linkages)) stop("Must run invert_rec_lig_linkages if rec_lig is set to 'lig'.\n")
all <- unlist(dom@linkages$lig_rec)
resolve_rec_lig <- "rec"
} else {
stop("lig_rec must be one of 'lig' or 'rec")
}

all <- unique(all)
all <- all[!all == ""]

### Resolve non-standard ligand names
all_names_resolved <- resolve_names(dom, all, rec_lig = resolve_rec_lig)
all_names_resolved <- unique(all_names_resolved)

### Resolve complexes
if(length(dom@linkages$complexes) > 0){
all_complexes_resolved_list <- resolve_complexes(dom, all_names_resolved)
all_names_resolved <- unlist(all_complexes_resolved_list)
}

if (expressed_only) {
### Subset for ligands expressed in the data
genes <- intersect(all_names_resolved, rownames(dom@z_scores))
} else {
genes <- all_names_resolved
#genes <- all_complexes_resolved_list
}

out_ls <- list("genes" = genes, "complex" = all_complexes_resolved_list)
return(out_ls)

} # get_all_reclig
1 change: 1 addition & 0 deletions R/import_fxns.R
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ create_domino <- function(
}
dom@linkages[["rec_lig"]] <- rec_lig_linkage
dom@misc[["rl_map"]] <- rl_reading
dom <- invert_rec_lig_linkages(dom) # untested
# Get z-score and cluster info
if (verbose) {
message("Getting z_scores, clusters, and counts")
Expand Down
Loading