Graphical options with plot_fullsibQTL
In this short tutorial we show how to plot different graphics using function plot_fullsibQTL
. A complete description can be obtained with ?plot_fullsibQTL
.
As an example we will use the example data that comes with the package, and the using the QTL model. The following steps, preceding the graphical part, are detailed in the vignette fullsibQTL
Tutorial.
library( "fullsibQTL" )
data( "example_QTLfullsib" )
fullsib <- create_fullsib( example_QTLfullsib,
list( LG1_final, LG2_final, LG3_final, LG4_final ),
step = 1,
map.function = "kosambi",
condIndex = 3.5 )
## IM
im <- im_scan( fullsib )
qtls.im <- r2_ls( fullsib,
pheno.col = 1,
lg = c( 1, 1, 2, 2, 2, 3, 3, 4 ),
pos = c( "loc13", "M12", "loc45", "loc77", "loc108", "M33", "loc65", "M52" ) )
## CIM
cofs.fs <- cof_selection( fullsib,
pheno.col = 1,
k=log(300),
n.cofactor = 10)
cim <- cim_scan( cofs.fs )
qtls.cim <- r2_ls( fullsib,
pheno.col = 1,
lg = c( 1, 1, 2, 2, 2, 3, 3, 4 ),
pos = c( "loc13", "M12", "loc45", "loc77", "loc108", "M33", "loc65", "M52" ) )
## Getting im and cim peaks for alpha 0.05.
im.peak1 <- summary( im_perm, alpha = 0.05 )[ 1, 1 ]
im.peak2 <- summary( im_perm, alpha = 0.05 )[ 1, 2 ]
cim.peak1 <- summary( cim_perm, alpha = 0.05 )[ 1, 1 ]
cim.peak2 <- summary( cim_perm, alpha = 0.05 )[ 1, 2 ]
Customizing the Graphics
The minimal plot requires a fullsib object, and at least one result of doing a genome scan with fullsib_scan
. The genetic map is on the X axis.
We can set the legend of the QTL mapping including the qtlmapping
option:
Graphical comparision between im_scan
and cim_scan
It is possible to plot a graphic with both strategies. To do this, one should use a list with previous analysis with each model. (see the list()
in the arguments). Those multiple results can be, for example, different models (IM and CIM), traits, the same trait in different environments, etc.
For example, to include results of IM and CIM:
Of course, both models were adjusted on previous rounds of analysis.
Adding QTL location
You can insert the QTLs position from the r2_ls
function for each one of the models. This is done with argument r2ls.out
. For example, in two different situations:
For multiple QTLs mappings:
plot_fullsibQTL( fullsib = fullsib,
fullsib.scan = list( cim, im ),
r2ls.out = list( qtls.cim, qtls.im ),
qtlmapping = c( "CIM", "IM" ) )
To show the threshold lines, based for example on the summary( cim_perm )
peaks 1 and 2 with $=0.05):
summary( cim_perm )
#> Threshold considering 1000 permutations
#> peak.1 peak.2 peak.3 peak.4
#> 0.05 4.023724 2.900906 2.300657 1.860476
#> 0.1 3.707559 2.650663 2.140063 1.692707
plot_fullsibQTL( fullsib = fullsib,
fullsib.scan = list ( cim, im ),
qtlmapping = c( "CIM", "IM" ),
thr = c(4.023724, 2.900906 ) )
It is also possible to use a grayscale:
plot_fullsibQTL( fullsib = fullsib,
fullsib.scan = list( cim, im ),
r2ls.out = list( qtls.cim, qtls.im ),
qtlmapping = c( "CIM", "IM" ),
thr = c( 4.023724, 2.900906 ),
grayscale = TRUE )
Moreover, one might want to see only selected linkage groups. For example, for LG 2:
plot_fullsibQTL( fullsib = fullsib,
fullsib.scan = list( cim, im ),
r2ls.out = list( qtls.cim, qtls.im ),
qtlmapping = c( "CIM", "IM" ),
thr = c( 4.023724, 2.900906 ),
lgs = 2 )
For LGs 2 and 4:
plot_fullsibQTL( fullsib = fullsib,
fullsib.scan = list( cim, im ),
r2ls.out = list( qtls.cim, qtls.im ),
qtlmapping = c( "CIM", "IM" ),
thr = c( 4.023724, 2.900906 ),
lgs = c( 2, 4 ) )
Interactive plots
A very useful feature is to plot interactive graphics. Function ‘plot_fullsibQTL’ uses internally the great package plotly
as its engine. With option interact=TRUE
, an interactive html
graphic will be created in the working directory (or any arbitrary one defined by the user). The plot will automatically open in the default browser (for not doing so, set browser=FALSE
).
## Setting the file name
plot_fullsibQTL( fullsib = fullsib,
fullsib.scan = list( cim, im ),
r2ls.out = list( qtls.cim, qtls.im ),
qtlmapping = c ( "CIM", "IM" ),
thr = c( 4.023724, 2.900906 ),
interact = TRUE,
file = "cim_im.html" )
## Setting the folder name
plot_fullsibQTL( fullsib = fullsib,
fullsib.scan = list( cim, im ),
r2ls.out = list( qtls.cim, qtls.im ),
qtlmapping = c( "CIM", "IM" ),
thr = c( 4.023724, 2.900906 ),
interact = TRUE,
file = "cim_im.html",
folder = "/home/your_user_name/graphics" )
## Setting to not open the browser
plot_fullsibQTL( fullsib = fullsib,
fullsib.scan = list( cim, im ),
r2ls.out = list( qtls.cim, qtls.im ),
qtlmapping = c( "CIM", "IM" ),
thr = c( 4.023724, 2.900906 ),
interact = TRUE,
file = "cim_im.html",
folder = "/home/your_user_name/Pictures",
browser = FALSE )
The script above creates a graphic that can be visualized clicking here. It is a interactive plotly
graphic. Click on legend entries to toggle traces, click-and-drag on the chart to zoom, double-click to autoscale, shift-and-drag to pan (from plotly website). Additionally, it also has in the tooltip the LOD score, the QTL estimated effect, and marker names in the genetic map.
The user can also set the height and width of the interactive plot, with arguments height
and width
(they are the same as the arguments of plotly
function). The default of height
is 500 pixels and for width
is 250 \(\times\) the number of LGs to be plot. All the arguments can be combined in the interactive plot.
Changing colors
There is and option to choose the colors for each linkage group, with argument lg.colors
, that will pass its values to the ggplot2::scale_colour_manual
function. You can check more colors options at cheatsheet or at this color guide.
Here we plot an interactive plot in order to compare the CIM and IM models, setting two different thresholds: darkgreen
for CIM and green
for IM, and choosing to plot just LGs 2 and 3.
plot_fullsibQTL( fullsib = fullsib,
fullsib.scan = list( cim, im ),
r2ls.out = list( qtls.cim, qtls.im ),
qtlmapping = c( "CIM", "IM" ),
thr = c( 4.023724, 2.900906 ),
lgs = c( 2, 4 ),
interact = TRUE,
lg.colors = c( "darkgreen", "green" ),
height = 600,
width = 800,
file = "cim_im_greens.html",
folder="/home/your_user_name/graphics" )
The graphic is here: cim_im_greens.html
Session Info
sessionInfo()
#> R version 3.6.3 (2020-02-29)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 19.10
#>
#> Matrix products: default
#> BLAS: /usr/local/lib/R/lib/libRblas.so
#> LAPACK: /usr/local/lib/R/lib/libRlapack.so
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] fullsibQTL_0.0.9007 onemap_2.1.3 rmdformats_0.3.7
#> [4] knitr_1.28
#>
#> loaded via a namespace (and not attached):
#> [1] colorspace_1.4-1 ellipsis_0.3.1 class_7.3-15
#> [4] rio_0.5.16 htmlTable_1.13.3 base64enc_0.1-3
#> [7] rstudioapi_0.11 mice_3.9.0 farver_2.0.3
#> [10] codetools_0.2-16 splines_3.6.3 doParallel_1.0.15
#> [13] Formula_1.2-3 polynom_1.4-0 jsonlite_1.6.1
#> [16] MDSMap_1.1 broom_0.5.6 cluster_2.1.0
#> [19] png_0.1-7 shiny_1.4.0.2 httr_1.4.1
#> [22] compiler_3.6.3 backports_1.1.7 lazyeval_0.2.2
#> [25] assertthat_0.2.1 Matrix_1.2-18 fastmap_1.0.1
#> [28] later_1.0.0 acepack_1.4.1 htmltools_0.4.0
#> [31] tools_3.6.3 gtable_0.3.0 glue_1.4.1
#> [34] dplyr_0.8.5 Rcpp_1.0.4.6 carData_3.0-3
#> [37] cellranger_1.1.0 vctrs_0.3.0 gdata_2.18.0
#> [40] nlme_3.1-144 iterators_1.0.12 crosstalk_1.1.0.1
#> [43] xfun_0.13 stringr_1.4.0 openxlsx_4.1.5
#> [46] mime_0.9 miniUI_0.1.1.1 lifecycle_0.2.0
#> [49] weights_1.0.1 gtools_3.8.2 princurve_2.1.4
#> [52] candisc_0.8-3 MASS_7.3-51.5 scales_1.1.1
#> [55] heplots_1.3-5 hms_0.5.3 promises_1.1.0
#> [58] parallel_3.6.3 smacof_2.1-0 RColorBrewer_1.1-2
#> [61] yaml_2.2.1 curl_4.3 gridExtra_2.3
#> [64] ggplot2_3.3.0 rpart_4.1-15 reshape_0.8.8
#> [67] latticeExtra_0.6-29 stringi_1.4.6 foreach_1.5.0
#> [70] plotrix_3.7-8 e1071_1.7-3 checkmate_2.0.0
#> [73] zip_2.0.4 manipulateWidget_0.10.1 rlang_0.4.6
#> [76] pkgconfig_2.0.3 rgl_0.100.54 evaluate_0.14
#> [79] lattice_0.20-38 purrr_0.3.4 labeling_0.3
#> [82] htmlwidgets_1.5.1 tidyselect_1.1.0 plyr_1.8.6
#> [85] magrittr_1.5 bookdown_0.19 R6_2.4.1
#> [88] generics_0.0.2 nnls_1.4 Hmisc_4.4-0
#> [91] pillar_1.4.4 haven_2.2.0 foreign_0.8-75
#> [94] survival_3.1-8 abind_1.4-5 nnet_7.3-12
#> [97] tibble_3.0.1 crayon_1.3.4 car_3.0-7
#> [100] wordcloud_2.6 plotly_4.9.2.1 ellipse_0.4.1
#> [103] rmarkdown_2.1 jpeg_0.1-8.1 grid_3.6.3
#> [106] readxl_1.3.1 data.table_1.12.8 forcats_0.5.0
#> [109] digest_0.6.25 webshot_0.5.2 xtable_1.8-4
#> [112] tidyr_1.0.3 httpuv_1.5.2 munsell_0.5.0
#> [115] viridisLite_0.3.0