Skip to content

Commit a894902

Browse files
committed
added legend size to archi plot
1 parent d18886c commit a894902

File tree

6 files changed

+71
-49
lines changed

6 files changed

+71
-49
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: PhyloProfile
2-
Version: 1.99.6
3-
Date: 2024-03-10
2+
Version: 1.99.7
3+
Date: 2024-03-21
44
Title: PhyloProfile
55
Authors@R: c(
66
person("Vinh", "Tran", role = c("aut", "cre"), email = "[email protected]", comment=c(ORCID="0000-0001-6772-7595")),

R/createDomainPlot.R

+37-28
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#' which normally is also the orthologous group ID.
66
#' @export
77
#' @usage createArchiPlot(info, domainDf, labelArchiSize, titleArchiSize,
8-
#' showScore, showWeight, namePosition, firstDist, nameType, nameSize,
9-
#' segmentSize, nameColor, labelPos, colorType, ignoreInstanceNo,
10-
#' currentNCBIinfo, featureClassSort, featureClassOrder, colorPalette,
11-
#' resolveOverlap, font)
8+
#' legendArchiSize, showScore, showWeight, namePosition, firstDist,
9+
#' nameType, nameSize, segmentSize, nameColor, labelPos, colorType,
10+
#' ignoreInstanceNo, currentNCBIinfo, featureClassSort, featureClassOrder,
11+
#' colorPalette, resolveOverlap, font)
1212
#' @param info A list contains seed and ortholog's IDs
1313
#' @param domainDf Dataframe contains domain info for the seed and ortholog.
1414
#' This including the seed ID, orthologs IDs, sequence lengths, feature names,
@@ -17,6 +17,7 @@
1717
#' between 2 proteins* (e.g. seed protein vs ortholog) (optional).
1818
#' @param labelArchiSize Lable size (in px). Default = 12.
1919
#' @param titleArchiSize Title size (in px). Default = 12.
20+
#' @param legendArchiSize Title size (in px). Default = 12.
2021
#' @param showScore Show/hide E-values and Bit-scores. Default = NULL (hide)
2122
#' @param showWeight Show/hide feature weights. Default = NULL (hide)
2223
#' @param namePosition list of positions for domain names, choose from "plot",
@@ -64,13 +65,13 @@
6465
#' grid::grid.draw(plot)
6566

6667
createArchiPlot <- function(
67-
info = NULL, domainDf = NULL, labelArchiSize = 12, titleArchiSize = 12,
68-
showScore = NULL, showWeight = NULL, namePosition = "plot",
69-
firstDist = 0.5, nameType = "Labels", nameSize = 3, segmentSize = 5,
70-
nameColor = "#000000", labelPos = "Above", colorType = "Unique",
71-
ignoreInstanceNo = FALSE, currentNCBIinfo = NULL,
72-
featureClassSort = "Yes", featureClassOrder = NULL,
73-
colorPalette = "Paired", resolveOverlap = "Yes", font = "Arial"
68+
info = NULL, domainDf = NULL, labelArchiSize = 12, titleArchiSize = 12,
69+
legendArchiSize = 12, showScore = NULL, showWeight = NULL,
70+
namePosition = "plot", firstDist = 0.5, nameType = "Labels",
71+
nameSize = 3, segmentSize = 5,nameColor = "#000000", labelPos = "Above",
72+
colorType = "Unique", ignoreInstanceNo = FALSE, currentNCBIinfo = NULL,
73+
featureClassSort = "Yes", featureClassOrder = NULL,
74+
colorPalette = "Paired", resolveOverlap = "Yes", font = "Arial"
7475
){
7576
if (is.null(info) | is.null(domainDf)) return(ggplot() + theme_void())
7677
group <- as.character(info[1])
@@ -164,17 +165,17 @@ createArchiPlot <- function(
164165
# plotting
165166
g <- pairDomainPlotting(
166167
seed, ortho, orderedSeedDf, orderedOrthoDf, minStart, maxEnd,
167-
labelArchiSize, titleArchiSize, showScore, showWeight,
168-
namePosition, firstDist, nameType, nameSize, segmentSize,
169-
nameColor, labelPos, colorPalette, font)
168+
labelArchiSize, titleArchiSize, legendArchiSize, showScore,
169+
showWeight, namePosition, firstDist, nameType, nameSize,
170+
segmentSize, nameColor, labelPos, colorPalette, font)
170171
} else {
171172
orderedSeedDf <- sortDomainsByList(seedDf, featureClassOrder)
172173
# plotting
173174
g <- pairDomainPlotting(
174175
seed, seed, orderedSeedDf, orderedSeedDf, minStart, maxEnd,
175-
labelArchiSize, titleArchiSize, showScore, showWeight,
176-
namePosition, firstDist, nameType, nameSize, segmentSize,
177-
nameColor, labelPos, colorPalette, font)
176+
labelArchiSize, titleArchiSize, legendArchiSize, showScore,
177+
showWeight, namePosition, firstDist, nameType, nameSize,
178+
segmentSize, nameColor, labelPos, colorPalette, font)
178179
}
179180
return(g)
180181
}
@@ -421,8 +422,9 @@ singleDomainPlotting <- function(
421422

422423
#' Create architecure plot for a pair of seed and ortholog protein
423424
#' @usage pairDomainPlotting(seed, ortho, seedDf, orthoDf, minStart, maxEnd,
424-
#' labelSize, titleSize, showScore, showWeight, namePosition, firstDist,
425-
#' nameType, nameSize, segmentSize, nameColor, labelPos, colorPalette, font)
425+
#' labelSize, titleSize, legendSize, showScore, showWeight, namePosition,
426+
#' firstDist, nameType, nameSize, segmentSize, nameColor, labelPos,
427+
#' colorPalette, font)
426428
#' @param seed Seed ID
427429
#' @param ortho Ortho ID
428430
#' @param seedDf domain dataframe for seed domains containing the seed ID,
@@ -435,6 +437,7 @@ singleDomainPlotting <- function(
435437
#' @param maxEnd the highest stop position of all domains
436438
#' @param labelSize lable size. Default = 12
437439
#' @param titleSize title size. Default = 12
440+
#' @param legendSize legend size. Default = 12
438441
#' @param showScore show/hide E-values and Bit-scores. Default = NULL (hide)
439442
#' @param showWeight Show/hide feature weights. Default = NULL (hide)
440443
#' @param namePosition list of positions for domain names, choose from "plot",
@@ -486,10 +489,10 @@ singleDomainPlotting <- function(
486489
pairDomainPlotting <- function(
487490
seed = NULL, ortho = NULL, seedDf = NULL, orthoDf = NULL,
488491
minStart = 0, maxEnd = 999, labelSize = 12, titleSize = 12,
489-
showScore = NULL, showWeight = NULL, namePosition = "plot",
490-
firstDist = 0.5, nameType = "Labels", nameSize = 3, segmentSize = 5,
491-
nameColor = "#000000", labelPos = "Above", colorPalette = "Paired",
492-
font = "Arial"
492+
legendSize = 12, showScore = NULL, showWeight = NULL,
493+
namePosition = "plot", firstDist = 0.5, nameType = "Labels",
494+
nameSize = 3, segmentSize = 5, nameColor = "#000000",
495+
labelPos = "Above", colorPalette = "Paired", font = "Arial"
493496
) {
494497
if(is.null(seed) | is.null(ortho) | is.null(seedDf) | is.null(orthoDf))
495498
stop("Seed/Ortho ID or domain dataframe is NULL!")
@@ -510,7 +513,8 @@ pairDomainPlotting <- function(
510513
)
511514
if ("legend" %in% namePosition) {
512515
g <- joinPlotMergeLegends(
513-
seedDf, orthoDf, plotSeed, plotOrtho, position = "bottom", font
516+
seedDf, orthoDf, plotSeed, plotOrtho, position = "bottom", font,
517+
legendSize
514518
)
515519
} else {
516520
seedHeight <- length(levels(as.factor(seedDf$feature)))
@@ -652,6 +656,7 @@ modifyFeatureName <- function(domainDf = NULL) {
652656
#' @param plot2 ggplot object of plot 2
653657
#' @param position position of legend (bottom or right)
654658
#' @param font font of text
659+
#' @param legendSize font size
655660
#' @return joined plots with merged legend as a grid object
656661
#' @author Vinh Tran [email protected]
657662
#' @importFrom gridExtra grid.arrange
@@ -688,11 +693,12 @@ modifyFeatureName <- function(domainDf = NULL) {
688693
#' )
689694
#' # merge plots
690695
#' PhyloProfile:::joinPlotMergeLegends(
691-
#' seedDf, orthoDf, plotSeed, plotOrtho, "bottom", font = "sans")
696+
#' seedDf, orthoDf, plotSeed, plotOrtho, "bottom", font = "sans",
697+
#' legendSize = 12)
692698

693699
joinPlotMergeLegends <- function(
694-
df1 = NULL, df2 = NULL, plot1 = NULL, plot2 = NULL,
695-
position = c("bottom", "right"), font = "Arial")
700+
df1 = NULL, df2 = NULL, plot1 = NULL, plot2 = NULL,
701+
position = c("bottom", "right"), font = "Arial", legendSize = 12)
696702
{
697703
if (is.null(plot1) | is.null(df1)) stop("No plot data given!")
698704
if (is.null(plot2) | is.null(df2))
@@ -726,7 +732,10 @@ joinPlotMergeLegends <- function(
726732
scale_color_manual(values = colorScheme) +
727733
labs(color = "Feature") +
728734
theme_minimal() +
729-
theme(legend.position = position, text = element_text(family = font))
735+
theme(
736+
legend.position = position,
737+
text = element_text(family = font, size = legendSize)
738+
)
730739
# extract legend from the temp plot above
731740
getOnlyLegend <- function(plot) {
732741
plotTable <- ggplot_gtable(ggplot_build(plot))

inst/PhyloProfile/R/createArchitecturePlot.R

+15-11
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ createArchitecturePlotUI <- function(id) {
183183
),
184184
createTextSize(
185185
ns("labelArchiSize"), "Axis label size(px)", 12, 200
186+
),
187+
createTextSize(
188+
ns("legendArchiSize"), "Legend font size(px)", 12, 200
186189
)
187190
),
188191
column(
@@ -422,12 +425,13 @@ createArchitecturePlot <- function(
422425
df <- df[!(df$feature_id %in% input$featureList),]
423426
g <- createArchiPlot(
424427
pointInfo(), df,
425-
input$labelArchiSize, input$titleArchiSize, input$showScore,
426-
input$showWeight, input$namePostion, input$firstDist,input$nameType,
427-
input$nameSize, input$segmentSize, input$nameColor, input$labelPos,
428-
input$colorType, input$ignoreInstanceNo, currentNCBIinfo(),
429-
input$featureClassSort, input$featureClassOrder, input$colorPallete,
430-
input$resolveOverlap, font()
428+
input$labelArchiSize, input$titleArchiSize, input$legendArchiSize,
429+
input$showScore, input$showWeight, input$namePostion,
430+
input$firstDist,input$nameType, input$nameSize, input$segmentSize,
431+
input$nameColor, input$labelPos, input$colorType,
432+
input$ignoreInstanceNo, currentNCBIinfo(), input$featureClassSort,
433+
input$featureClassOrder, input$colorPallete, input$resolveOverlap,
434+
font()
431435
)
432436
if (any(g == "No domain info available!")) {
433437
msgPlot()
@@ -469,11 +473,11 @@ createArchitecturePlot <- function(
469473
df <- df[!(df$feature_id %in% input$featureList),]
470474
g <- createArchiPlot(
471475
pointInfo(), df,
472-
input$labelArchiSize, input$titleArchiSize, input$showScore,
473-
input$showWeight, input$namePostion, input$firstDist,
474-
input$nameType, input$nameSize, input$segmentSize,
475-
input$nameColor, input$labelPos, input$colorType,
476-
input$ignoreInstanceNo, currentNCBIinfo(),
476+
input$labelArchiSize,input$titleArchiSize,input$legendArchiSize,
477+
input$showScore, input$showWeight, input$namePostion,
478+
input$firstDist, input$nameType, input$nameSize,
479+
input$segmentSize, input$nameColor, input$labelPos,
480+
input$colorType, input$ignoreInstanceNo, currentNCBIinfo(),
477481
input$featureClassSort, input$featureClassOrder,
478482
input$colorPallete, input$resolveOverlap, font()
479483
)

man/createArchiPlot.Rd

+6-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/joinPlotMergeLegends.Rd

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/pairDomainPlotting.Rd

+5-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)