Skip to content

Commit

Permalink
fixed cusomized profile
Browse files Browse the repository at this point in the history
  • Loading branch information
trvinh committed Nov 1, 2024
1 parent c9627c9 commit 766be22
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 100 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: PhyloProfile
Version: 1.21.0
Date: 2024-10-28
Version: 1.21.1
Date: 2024-11-01
Title: PhyloProfile
Authors@R: c(
person("Vinh", "Tran", role = c("aut", "cre"), email = "[email protected]", comment=c(ORCID="0000-0001-6772-7595")),
Expand Down
12 changes: 8 additions & 4 deletions R/umapClustering.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,16 @@ createUmapPlotData <- function(
#' Create UMAP cluster plot
#' @export
#' @usage plotUmap(plotDf = NULL, legendPos = "bottom", colorPalette = "Set2",
#' transparent = 0, textSize = 12, font = "Arial", highlightTaxa = NULL)
#' transparent = 0, textSize = 12, font = "Arial", highlightTaxa = NULL,
#' dotZoom = 0)
#' @param plotDf data for UMAP plot
#' @param legendPos position of legend. Default: "right"
#' @param colorPalette color palette. Default: "Set2"
#' @param transparent transparent level (from 0 to 1). Default: 0
#' @param textSize size of axis and legend text. Default: 12
#' @param font font of text. Default = Arial"
#' @param highlightTaxa list of taxa to be highlighted
#' @param dotZoom dot size zooming factor. Default: 0
#' @return A plot as ggplot object
#' @author Vinh Tran [email protected]
#' @seealso \code{\link{prepareUmapData}}, \code{\link{umapClustering}},
Expand All @@ -280,7 +282,8 @@ createUmapPlotData <- function(

plotUmap <- function(
plotDf = NULL, legendPos = "bottom", colorPalette = "Set2",
transparent = 0, textSize = 12, font = "Arial", highlightTaxa = NULL
transparent = 0, textSize = 12, font = "Arial", highlightTaxa = NULL,
dotZoom = 0
) {
if (is.null(plotDf)) stop("Input data cannot be NULL!")
X <- Y <- Label <- Freq <- NULL
Expand All @@ -302,13 +305,14 @@ plotUmap <- function(
)
}
# adapt plot height based on number of labels

# generate plot
plot <- ggplot(plotDf, aes(x = X, y = Y, color = Label)) +
geom_point(aes(size = Freq), alpha = 1 - transparent) +
geom_rug(alpha = 1) +
theme_minimal() +
labs(x = "", y = "")
labs(x = "", y = "")+
scale_radius(range = c(1 + dotZoom, 6 + dotZoom))
# change legend title
if ("ncbiID" %in% colnames(plotDf)) {
plot <- plot + guides(
Expand Down
8 changes: 8 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
\title{PhyloProfile news}
\encoding{UTF-8}

\section{Version 1.20.1}{
\itemize{
\item auto identify refspec
\item fixed subsetting data using a list of gene IDs
}
}


\section{Version 1.20.0}{
\itemize{
\item added UMAP clustering
Expand Down
7 changes: 5 additions & 2 deletions inst/PhyloProfile/R/createProfilePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ createProfilePlot <- function(
if (length(inSeq()) == 0 || length(inTaxa()) == 0) return()
if ("all" %in% inSeq() & "all" %in% inTaxa()) return()
}
if (mode() == "fast")
if (mode() == "fast" & typeProfile() != "customizedProfile")
return(heatmapPlottingFast(dataHeat(), parameters()))
return(heatmapPlotting(dataHeat(), parameters()))
})
Expand Down Expand Up @@ -337,6 +337,9 @@ createProfilePlot <- function(

# get info of clicked point on heatmap plot --------------------------------
selectedpointInfo <- reactive({
req(dataHeat)
req(inSeq())
req(inTaxa())
# get selected supertaxon name
taxaList <- getNameList(taxDB())
rankName <- rankSelect()
Expand All @@ -346,7 +349,7 @@ createProfilePlot <- function(
if (mode() == "fast")
dataHeat <- brushedData()

if (is.null(dataHeat)) {
if (is.null(dataHeat) | nrow(dataHeat) == 0) {
message("WARNING: Data for heatmap is NULL!")
return()
}
Expand Down
2 changes: 1 addition & 1 deletion inst/PhyloProfile/global.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Startup script for PhyloProfile
#' 1) install and load packages
#' 2) start the PhyloProfile app

library(PhyloProfile)
source("R/functions.R")

# List of dependent packages --------------------------------------------------
Expand Down
Loading

0 comments on commit 766be22

Please sign in to comment.