5
5
# ' which normally is also the orthologous group ID.
6
6
# ' @export
7
7
# ' @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)
12
12
# ' @param info A list contains seed and ortholog's IDs
13
13
# ' @param domainDf Dataframe contains domain info for the seed and ortholog.
14
14
# ' This including the seed ID, orthologs IDs, sequence lengths, feature names,
17
17
# ' between 2 proteins* (e.g. seed protein vs ortholog) (optional).
18
18
# ' @param labelArchiSize Lable size (in px). Default = 12.
19
19
# ' @param titleArchiSize Title size (in px). Default = 12.
20
+ # ' @param legendArchiSize Title size (in px). Default = 12.
20
21
# ' @param showScore Show/hide E-values and Bit-scores. Default = NULL (hide)
21
22
# ' @param showWeight Show/hide feature weights. Default = NULL (hide)
22
23
# ' @param namePosition list of positions for domain names, choose from "plot",
64
65
# ' grid::grid.draw(plot)
65
66
66
67
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"
74
75
){
75
76
if (is.null(info ) | is.null(domainDf )) return (ggplot() + theme_void())
76
77
group <- as.character(info [1 ])
@@ -164,17 +165,17 @@ createArchiPlot <- function(
164
165
# plotting
165
166
g <- pairDomainPlotting(
166
167
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 )
170
171
} else {
171
172
orderedSeedDf <- sortDomainsByList(seedDf , featureClassOrder )
172
173
# plotting
173
174
g <- pairDomainPlotting(
174
175
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 )
178
179
}
179
180
return (g )
180
181
}
@@ -421,8 +422,9 @@ singleDomainPlotting <- function(
421
422
422
423
# ' Create architecure plot for a pair of seed and ortholog protein
423
424
# ' @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)
426
428
# ' @param seed Seed ID
427
429
# ' @param ortho Ortho ID
428
430
# ' @param seedDf domain dataframe for seed domains containing the seed ID,
@@ -435,6 +437,7 @@ singleDomainPlotting <- function(
435
437
# ' @param maxEnd the highest stop position of all domains
436
438
# ' @param labelSize lable size. Default = 12
437
439
# ' @param titleSize title size. Default = 12
440
+ # ' @param legendSize legend size. Default = 12
438
441
# ' @param showScore show/hide E-values and Bit-scores. Default = NULL (hide)
439
442
# ' @param showWeight Show/hide feature weights. Default = NULL (hide)
440
443
# ' @param namePosition list of positions for domain names, choose from "plot",
@@ -486,10 +489,10 @@ singleDomainPlotting <- function(
486
489
pairDomainPlotting <- function (
487
490
seed = NULL , ortho = NULL , seedDf = NULL , orthoDf = NULL ,
488
491
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"
493
496
) {
494
497
if (is.null(seed ) | is.null(ortho ) | is.null(seedDf ) | is.null(orthoDf ))
495
498
stop(" Seed/Ortho ID or domain dataframe is NULL!" )
@@ -510,7 +513,8 @@ pairDomainPlotting <- function(
510
513
)
511
514
if (" legend" %in% namePosition ) {
512
515
g <- joinPlotMergeLegends(
513
- seedDf , orthoDf , plotSeed , plotOrtho , position = " bottom" , font
516
+ seedDf , orthoDf , plotSeed , plotOrtho , position = " bottom" , font ,
517
+ legendSize
514
518
)
515
519
} else {
516
520
seedHeight <- length(levels(as.factor(seedDf $ feature )))
@@ -652,6 +656,7 @@ modifyFeatureName <- function(domainDf = NULL) {
652
656
# ' @param plot2 ggplot object of plot 2
653
657
# ' @param position position of legend (bottom or right)
654
658
# ' @param font font of text
659
+ # ' @param legendSize font size
655
660
# ' @return joined plots with merged legend as a grid object
656
661
# ' @author Vinh Tran [email protected]
657
662
# ' @importFrom gridExtra grid.arrange
@@ -688,11 +693,12 @@ modifyFeatureName <- function(domainDf = NULL) {
688
693
# ' )
689
694
# ' # merge plots
690
695
# ' PhyloProfile:::joinPlotMergeLegends(
691
- # ' seedDf, orthoDf, plotSeed, plotOrtho, "bottom", font = "sans")
696
+ # ' seedDf, orthoDf, plotSeed, plotOrtho, "bottom", font = "sans",
697
+ # ' legendSize = 12)
692
698
693
699
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 )
696
702
{
697
703
if (is.null(plot1 ) | is.null(df1 )) stop(" No plot data given!" )
698
704
if (is.null(plot2 ) | is.null(df2 ))
@@ -726,7 +732,10 @@ joinPlotMergeLegends <- function(
726
732
scale_color_manual(values = colorScheme ) +
727
733
labs(color = " Feature" ) +
728
734
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
+ )
730
739
# extract legend from the temp plot above
731
740
getOnlyLegend <- function (plot ) {
732
741
plotTable <- ggplot_gtable(ggplot_build(plot ))
0 commit comments