Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ Imports:
stats,
tidyr,
utils,
yulab.utils (>= 0.2.3)
yulab.utils (>= 0.2.3),
ggplot2
Suggests:
AnnotationHub,
BiocManager,
DOSE,
fanyi (>= 0.1.0),
ggtangle,
jsonlite,
readr,
org.Hs.eg.db,
quarto,
Expand Down
10 changes: 8 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,16 @@ importFrom(enrichplot,goplot)
importFrom(enrichplot,gseaplot)
importFrom(enrichplot,heatplot)
importFrom(enrichplot,ridgeplot)
importFrom(ggplot2,aes)
importFrom(ggplot2,geom_label)
importFrom(ggplot2,geom_point)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggtitle)
importFrom(ggplot2,scale_color_manual)
importFrom(ggplot2,theme_void)
importFrom(gson,gson)
importFrom(gson,read.gmt)
importFrom(gson,read.gmt.wp)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,toJSON)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(methods,is)
Expand All @@ -166,6 +171,7 @@ importFrom(rlang,"%||%")
importFrom(rlang,.data)
importFrom(rlang,check_installed)
importFrom(rlang,quos)
importFrom(rlang,sym)
importFrom(stats,formula)
importFrom(stats,setNames)
importFrom(tidyr,gather)
Expand Down
4 changes: 2 additions & 2 deletions R/gson.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ gson_WP <- function(organism) {
#'
#' @examples
#' data = data.frame(gene_id = "gene1",
#' go_id = c("GO:0035492", "GO:0009764", "GO:0031063", "GO:0033714", "GO:0036349"))
#' go_id = c("GO:0035492", "GO:0009764", "GO:0031040", "GO:0033714", "GO:0036349"))
#' gson_GO_local(data, species = "E. coli")
gson_GO_local <- function(data,
ont = c("ALL", "BP", "CC", "MF"),
Expand Down Expand Up @@ -424,4 +424,4 @@ kegg_release = function(db){
y = readLines(url)
release <- sub("\\w+\\s+", "", y[grep('Release', y)])
return(release)
}
}
5 changes: 4 additions & 1 deletion R/interpret.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ run_agent_synthesizer <- function(pathways, detective_report, context, model, ap
#' @param n_pathways Number of top significant pathways to include in the analysis. Default is 20.
#' @param model The LLM model to use. Default is "deepseek-chat". Supported models include "deepseek-chat", "glm-4", "qwen-turbo" etc.
#' @param api_key The API key for the LLM. If NULL, it tries to fetch from `getOption('yulab_translate')` based on the model.
#' @param task Task type, default is "interpretation". Other options include "cell_type"/"annotation" and "phenotype"/"phenotyping".
#' @param prior Optional prior knowledge (e.g., a biological hypothesis) to guide the task.
#' @param add_ppi Boolean, whether to use PPI network integration.
#' @param gene_fold_change Named vector of logFC for expression context.
#' @return A character string containing the LLM-generated interpretation.
#' @author Guangchuang Yu
#' @export
Expand Down Expand Up @@ -847,7 +851,6 @@ Ensure the response is a valid JSON object. Do not include any markdown formatti
return(base_prompt)
}

#' @importFrom jsonlite toJSON fromJSON
call_llm_fanyi <- function(prompt, model, api_key) {
if (!requireNamespace("fanyi", quietly = TRUE)) {
stop("Package 'fanyi' is required for interpret(). Please install it.")
Expand Down
15 changes: 9 additions & 6 deletions R/plot_interpret.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
#' @title plot
#' @param x An `interpretation` object.
#' @param layout Graph layout, default is "nicely".
#' @param ... Additional arguments passed to `ggtangle::ggtangle`.
#' @param ... Additional arguments passed to `ggplot2::ggplot`.
#' @importFrom ggplot2 ggplot geom_label geom_point aes scale_color_manual
#' @importFrom ggplot2 theme_void ggtitle
#' @importFrom rlang sym
#' @export
plot.interpretation <- function(x, layout = "nicely", ...) {

Expand All @@ -26,8 +29,8 @@ plot.interpretation <- function(x, layout = "nicely", ...) {
# Add edges
# We try to map interaction type to color if available
if ("interaction" %in% igraph::edge_attr_names(g)) {
p <- p + ggtangle::geom_edge(ggplot2::aes(color = interaction)) +
ggplot2::scale_color_manual(values = c(
p <- p + ggtangle::geom_edge(aes(color = !!sym("interaction"))) +
scale_color_manual(values = c(
activation = "green3",
inhibition = "red3",
repression = "red3",
Expand All @@ -40,15 +43,15 @@ plot.interpretation <- function(x, layout = "nicely", ...) {

# Add nodes and labels
p <- p + geom_point(size = 5, color = "lightblue") +
geom_label(ggplot2::aes(label = name)) +
ggplot2::theme_void()
geom_label(aes(label = !!sym("name"))) +
theme_void()

main_title <- "Refined Regulatory Network"
if (!is.null(x$cluster)) {
main_title <- paste0(main_title, " (", x$cluster, ")")
}

p <- p + ggplot2::ggtitle(main_title)
p <- p + ggtitle(main_title)

return(p)
}
Expand Down
2 changes: 1 addition & 1 deletion man/gson_GO_local.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/interpret.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/plot.interpretation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.