Skip to content

Commit

Permalink
opt to upload gene names
Browse files Browse the repository at this point in the history
  • Loading branch information
trvinh committed Sep 2, 2024
1 parent aca3ac1 commit a2ffbd7
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 18 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.19.9
Date: 2024-08-29
Version: 1.19.10
Date: 2024-09-02
Title: PhyloProfile
Authors@R: c(
person("Vinh", "Tran", role = c("aut", "cre"), email = "[email protected]", comment=c(ORCID="0000-0001-6772-7595")),
Expand Down
1 change: 1 addition & 0 deletions R/parsePhyloProfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ parseInfoProfile <- function(
fullMdData$fullName <- as.vector(fullMdData$fullName)
names(fullMdData)[names(fullMdData) == "orthoID.x"] <- "orthoID"
fullMdData <- fullMdData[!duplicated(fullMdData), ]
# add geneName column if not yet exist
if (!("geneName" %in% colnames(fullMdData)))
fullMdData$geneName <- fullMdData$geneID
# sort geneName based on the order of geneID
Expand Down
65 changes: 52 additions & 13 deletions inst/PhyloProfile/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ shinyServer(function(input, output, session) {
i_cluster <- FALSE
i_profileType <- i_distMethod <- i_clusterMethod <- NULL
i_xAxis <- NULL
i_colorByGroup <- i_orderGenes <- i_geneCategory <- NULL
i_colorByGroup <- i_orderGenes <- i_geneCategory <- i_geneName <- NULL
if (!is.null(configFile)) {
if (file.exists(configFile)) {
configs <- yaml::read_yaml(configFile)
Expand All @@ -178,6 +178,7 @@ shinyServer(function(input, output, session) {
i_colorByGroup <- configs$colorByGroup
i_orderGenes <- configs$orderGenes
i_geneCategory <- configs$geneCategory
i_geneName <- configs$geneName
} else configFile <- NULL

if (!file.exists(i_mainInput))
Expand Down Expand Up @@ -256,10 +257,14 @@ shinyServer(function(input, output, session) {
)
}
})
# * prepare gene categories-------------------------------------------------
# * prepare gene categories ------------------------------------------------
if (!is.null(i_geneCategory) && !file.exists(i_geneCategory)){
stop(paste("Gene categories file ", i_geneCategory ,"not found!"))
}
# * prepare gene names -----------------------------------------------------
if (!is.null(i_geneName) && !file.exists(i_geneName)){
stop(paste("Gene names file ", i_geneName ,"not found!"))
}
# * apply clustering profiles ----------------------------------------------
if (is.null(i_profileType) ||
(i_profileType != "binary" && i_profileType != "var1" &&
Expand Down Expand Up @@ -450,12 +455,18 @@ shinyServer(function(input, output, session) {
} else {
if (input$annoLocation == "from file") {
fileInput("fileDomainInput", "")
} else textInput("domainPath", "", "")
} else textInput(
"domainPath", "", "",
placeholder = "Give full path to domain directory"
)
}
} else {
if (input$annoLocation == "from file") {
fileInput("fileDomainInput", "")
} else textInput("domainPath", "", "")
} else textInput(
"domainPath", "", "",
placeholder = "Give full path to domain directory"
)
}
})

Expand Down Expand Up @@ -2177,6 +2188,33 @@ shinyServer(function(input, output, session) {
taxaCount <- sortedtaxaList() %>% dplyr::count(supertaxon)
return(taxaCount)
})

# * get gene names (if provided) -------------------------------------------
getGeneNames <- reactive({
geneNameFile <- input$geneName
if (!is.null(geneNameFile)) {
inputNameDt <- read.table(
file = geneNameFile$datapath,
sep = "\t",
header = FALSE,
check.names = FALSE,
comment.char = "",
fill = TRUE
)
colnames(inputNameDt) <- c("geneID","geneName")
} else if (!is.null(i_geneName)){
inputNameDt <- read.table(
file = i_geneName,
sep = "\t",
header = FALSE,
check.names = FALSE,
comment.char = "",
fill = TRUE
)
colnames(inputNameDt) <- c("geneID","geneName")
} else inputNameDt <- NULL
return(inputNameDt)
})

# * get subset data for plotting (default 30 genes if > 50 genes) ----------
preData <- reactive({
Expand Down Expand Up @@ -2304,6 +2342,13 @@ shinyServer(function(input, output, session) {
taxaCount = getCountTaxa(),
coorthoCOMax = coorthologCutoffMax
)
# add gene names if specified by uploaded file
if (!(is.null(getGeneNames()))) {
fullMdData <- fullMdData %>% select(-geneName) %>%
left_join(getGeneNames(), by = "geneID")
fullMdData$geneName[is.na(fullMdData$geneName)] <-
fullMdData$geneID[is.na(fullMdData$geneName)]
}
return(fullMdData)
})
}
Expand Down Expand Up @@ -2470,16 +2515,10 @@ shinyServer(function(input, output, session) {

# =========================== MAIN PROFILE TAB =============================

# * update choices for geneIdType ------------------------------------------
# # * update choices for geneIdType ------------------------------------------
observe({
df <- dataHeat()
if (all(as.character(df$geneID) == as.character(df$geneName))) {
updateRadioButtons(
session, inputId = "geneIdType",
choices = list("Gene IDs" = "geneID"),
selected = "geneID"
)
}
if (!(is.null(getGeneNames())))
updateRadioButtons(session, "geneIdType", selected = "geneName")
})

# * render popup for selecting rank and return list of subset taxa ---------
Expand Down
25 changes: 22 additions & 3 deletions inst/PhyloProfile/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ shinyUI(
radioButtons(
inputId = "geneIdType",
label = "Display genes using:",
choices = list("Gene IDs" = "geneID","Gene names" = "geneName"),
selected = "geneName",
choices = list(
"Gene IDs" = "geneID","Gene names" = "geneName"
),
selected = "geneID",
inline = TRUE
),
checkboxInput(
Expand Down Expand Up @@ -447,6 +449,9 @@ shinyUI(
h5(""),

shinyBS::bsButton("uploadGeneCategory", "Gene categories"),
h5(""),

shinyBS::bsButton("uploadGeneName", "Gene names"),
hr(),

strong(h4("General configuration:")),
Expand Down Expand Up @@ -1859,7 +1864,21 @@ shinyUI(
size = "small",
fileInput("geneCategory", "")
),


# * popup for upload gene names ----------------------------------------
shinyBS::bsModal(
"uploadGeneNameBs",
"Upload gene names",
"uploadGeneName",
size = "medium",
em(paste(
"Upload gene names in tab-delimited format! Please check",
"https://github.com/BIONF/PhyloProfile/wiki/Input-Data#gene-names",
"for more info."
)),
br(),
fileInput("geneName", "")
),

# * popup for setting ortholog ID format -------------------------------
shinyBS::bsModal(
Expand Down

0 comments on commit a2ffbd7

Please sign in to comment.